Skip to content

Commit

Permalink
bazel: Add repo for package-local target labels (see #3757)
Browse files Browse the repository at this point in the history
Unqualified target labels don't resolve correctly when the
disribution is loaded as an external repo. Mapping, if necessary,
can be performed using the `repo_mapping` parameter to
http_archive() or local_repository().
  • Loading branch information
magreenblatt committed Jul 31, 2024
1 parent c234e7f commit 2b5cb6a
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 62 deletions.
12 changes: 6 additions & 6 deletions bazel/linux/exe_helpers.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ def declare_exe(name, srcs=[], deps=[], linkopts=[], copts=[], defines=[], data=
copy_filegroups(
name = copy_target,
filegroups = [
"//:sos",
"//:resources",
"@cef//:sos",
"@cef//:resources",
],
remove_prefixes = [
"Debug",
Expand All @@ -31,13 +31,13 @@ def declare_exe(name, srcs=[], deps=[], linkopts=[], copts=[], defines=[], data=
name = binary_target,
srcs = srcs,
deps = [
"//:cef_wrapper",
"//:cef",
"//:cef_sandbox",
"@cef//:cef_wrapper",
"@cef//:cef",
"@cef//:cef_sandbox",
] + deps,
linkopts = COMMON_LINKOPTS + linkopts,
copts = select({
"//:linux_dbg": COMMON_COPTS_DEBUG,
"@cef//:linux_dbg": COMMON_COPTS_DEBUG,
"//conditions:default": COMMON_COPTS_RELEASE,
}) + COMMON_COPTS + copts,
defines = defines,
Expand Down
2 changes: 1 addition & 1 deletion bazel/linux/variables.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ COMMON_LINKOPTS_RELEASE = [
COMMON_LINKOPTS = [
"-l{}".format(lib) for lib in STANDARD_LIBS
] + select({
"//:linux_dbg": COMMON_LINKOPTS_DEBUG,
"@cef//:linux_dbg": COMMON_LINKOPTS_DEBUG,
"//conditions:default": COMMON_LINKOPTS_RELEASE,
})

Expand Down
8 changes: 4 additions & 4 deletions bazel/mac/app_helpers.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def _declare_helper_app(name, info_plist, deps, helper_base_name, helper_suffix)
out = "{}Info.plist".format(helper_base_name),
substitutions = {
"${EXECUTABLE_NAME}": helper_name,
"${PRODUCT_NAME}": helper_name,
"${PRODUCT_NAME}": name,
"${BUNDLE_ID_SUFFIX}": bundle_id_suffix,
"${VERSION_SHORT}": VERSION_PLIST,
"${VERSION_LONG}": VERSION_PLIST,
Expand All @@ -41,7 +41,7 @@ def _declare_helper_app(name, info_plist, deps, helper_base_name, helper_suffix)
infoplists = [":{}_InfoPList".format(helper_base_name)],
minimum_os_version = MACOS_DEPLOYMENT_TARGET,
deps = [
"//:cef_sandbox",
"@cef//:cef_sandbox",
] + deps,
)

Expand All @@ -65,7 +65,7 @@ def declare_all_helper_apps(name, info_plist, deps):
helper_suffix = v,
) for h, v in HELPERS.items()]

def declare_main_app(name, info_plist, deps, linkopts, resources):
def declare_main_app(name, info_plist, deps, resources, linkopts=[]):
"""
Creates the main .app target.
"""
Expand Down Expand Up @@ -103,6 +103,6 @@ def declare_main_app(name, info_plist, deps, linkopts, resources):
"@platforms//os:macos",
],
deps = [
"//:cef_framework",
"@cef//:cef_framework",
] + deps,
)
2 changes: 1 addition & 1 deletion bazel/mac/variables.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ COMMON_LINKOPTS_RELEASE = [
COMMON_LINKOPTS = [
"-framework {}".format(lib) for lib in STANDARD_FRAMEWORKS
] + select({
"//:macos_dbg": COMMON_LINKOPTS_DEBUG,
"@cef//:macos_dbg": COMMON_LINKOPTS_DEBUG,
"//conditions:default": COMMON_LINKOPTS_RELEASE,
})

Expand Down
12 changes: 6 additions & 6 deletions bazel/win/exe_helpers.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ def declare_exe(name, srcs, manifest_srcs, rc_file, resources_srcs, resources_de
copy_filegroups(
name = copy_target,
filegroups = [
"//:dlls",
"//:resources",
"@cef//:dlls",
"@cef//:resources",
],
remove_prefixes = [
"Debug",
Expand All @@ -44,15 +44,15 @@ def declare_exe(name, srcs, manifest_srcs, rc_file, resources_srcs, resources_de
name = binary_target,
srcs = srcs,
deps = [
"//:cef_wrapper",
"//:cef",
"//:cef_sandbox",
"@cef//:cef_wrapper",
"@cef//:cef",
"@cef//:cef_sandbox",
] + deps,
linkopts = [
"$(location :{})".format(res_target),
] + COMMON_LINKOPTS + linkopts,
copts = select({
"//:windows_dbg": COMMON_COPTS_DEBUG,
"@cef//:windows_dbg": COMMON_COPTS_DEBUG,
"//conditions:default": COMMON_COPTS_RELEASE,
}) + COMMON_COPTS + copts,
defines = defines,
Expand Down
4 changes: 2 additions & 2 deletions bazel/win/variables.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,11 @@ COMMON_LINKOPTS = [
# can only control through this setting. The main thread (in 32-bit builds
# only) uses fibers to switch to a 4MiB stack at runtime via
# CefRunWinMainWithPreferredStackSize().
"//:windows_32": ["/STACK:0x80000"],
"@cef//:windows_32": ["/STACK:0x80000"],
# Increase the initial stack size to 8MiB from the default 1MiB.
"//conditions:default": ["/STACK:0x800000"],
}) + select({
"//:windows_dbg": COMMON_LINKOPTS_DEBUG,
"@cef//:windows_dbg": COMMON_LINKOPTS_DEBUG,
"//conditions:default": COMMON_LINKOPTS_RELEASE,
})

Expand Down
84 changes: 42 additions & 42 deletions tools/distrib/bazel/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -75,47 +75,47 @@ selects.config_setting_group(

selects.config_setting_group(
name = "windows_dbg",
match_all = ["@platforms//os:windows", ":dbg"],
match_all = ["@platforms//os:windows", "@cef//:dbg"],
)

selects.config_setting_group(
name = "windows_fastbuild",
match_all = ["@platforms//os:windows", ":fastbuild"],
match_all = ["@platforms//os:windows", "@cef//:fastbuild"],
)

selects.config_setting_group(
name = "windows_opt",
match_all = ["@platforms//os:windows", ":opt"],
match_all = ["@platforms//os:windows", "@cef//:opt"],
)

selects.config_setting_group(
name = "linux_dbg",
match_all = ["@platforms//os:linux", ":dbg"],
match_all = ["@platforms//os:linux", "@cef//:dbg"],
)

selects.config_setting_group(
name = "linux_fastbuild",
match_all = ["@platforms//os:linux", ":fastbuild"],
match_all = ["@platforms//os:linux", "@cef//:fastbuild"],
)

selects.config_setting_group(
name = "linux_opt",
match_all = ["@platforms//os:linux", ":opt"],
match_all = ["@platforms//os:linux", "@cef//:opt"],
)

selects.config_setting_group(
name = "macos_dbg",
match_all = ["@platforms//os:macos", ":dbg"],
match_all = ["@platforms//os:macos", "@cef//:dbg"],
)

selects.config_setting_group(
name = "macos_fastbuild",
match_all = ["@platforms//os:macos", ":fastbuild"],
match_all = ["@platforms//os:macos", "@cef//:fastbuild"],
)

selects.config_setting_group(
name = "macos_opt",
match_all = ["@platforms//os:macos", ":opt"],
match_all = ["@platforms//os:macos", "@cef//:opt"],
)

#
Expand Down Expand Up @@ -165,15 +165,15 @@ cc_library(
"@platforms//os:macos": MAC_COMMON_COPTS,
"//conditions:default": None,
}) + select({
":windows_opt": WIN_COMMON_COPTS_RELEASE,
":windows_dbg": WIN_COMMON_COPTS_DEBUG,
":windows_fastbuild": WIN_COMMON_COPTS_RELEASE,
":linux_opt": LINUX_COMMON_COPTS_RELEASE,
":linux_dbg": LINUX_COMMON_COPTS_DEBUG,
":linux_fastbuild": LINUX_COMMON_COPTS_RELEASE,
":macos_opt": MAC_COMMON_COPTS_RELEASE,
":macos_dbg": MAC_COMMON_COPTS_DEBUG,
":macos_fastbuild": MAC_COMMON_COPTS_RELEASE,
"@cef//:windows_opt": WIN_COMMON_COPTS_RELEASE,
"@cef//:windows_dbg": WIN_COMMON_COPTS_DEBUG,
"@cef//:windows_fastbuild": WIN_COMMON_COPTS_RELEASE,
"@cef//:linux_opt": LINUX_COMMON_COPTS_RELEASE,
"@cef//:linux_dbg": LINUX_COMMON_COPTS_DEBUG,
"@cef//:linux_fastbuild": LINUX_COMMON_COPTS_RELEASE,
"@cef//:macos_opt": MAC_COMMON_COPTS_RELEASE,
"@cef//:macos_dbg": MAC_COMMON_COPTS_DEBUG,
"@cef//:macos_fastbuild": MAC_COMMON_COPTS_RELEASE,
"//conditions:default": None,
}),
defines = [
Expand All @@ -184,15 +184,15 @@ cc_library(
"@platforms//os:macos": MAC_COMMON_DEFINES,
"//conditions:default": None,
}) + select({
":windows_opt": WIN_COMMON_DEFINES_RELEASE,
":windows_dbg": WIN_COMMON_DEFINES_DEBUG,
":windows_fastbuild": WIN_COMMON_DEFINES_RELEASE,
":linux_opt": LINUX_COMMON_DEFINES_RELEASE,
":linux_dbg": LINUX_COMMON_DEFINES_DEBUG,
":linux_fastbuild": LINUX_COMMON_DEFINES_RELEASE,
":macos_opt": MAC_COMMON_DEFINES_RELEASE,
":macos_dbg": MAC_COMMON_DEFINES_DEBUG,
":macos_fastbuild": MAC_COMMON_DEFINES_RELEASE,
"@cef//:windows_opt": WIN_COMMON_DEFINES_RELEASE,
"@cef//:windows_dbg": WIN_COMMON_DEFINES_DEBUG,
"@cef//:windows_fastbuild": WIN_COMMON_DEFINES_RELEASE,
"@cef//:linux_opt": LINUX_COMMON_DEFINES_RELEASE,
"@cef//:linux_dbg": LINUX_COMMON_DEFINES_DEBUG,
"@cef//:linux_fastbuild": LINUX_COMMON_DEFINES_RELEASE,
"@cef//:macos_opt": MAC_COMMON_DEFINES_RELEASE,
"@cef//:macos_dbg": MAC_COMMON_DEFINES_DEBUG,
"@cef//:macos_fastbuild": MAC_COMMON_DEFINES_RELEASE,
"//conditions:default": None,
}),
deps = [":cef_wrapper_headers"] +
Expand Down Expand Up @@ -238,16 +238,16 @@ cc_import(
alias(
name = "cef_sandbox",
actual = select({
"//:dbg": ":cef_sandbox_debug",
"//conditions:default": ":cef_sandbox_release",
"@cef//:dbg": "@cef//:cef_sandbox_debug",
"//conditions:default": "@cef//:cef_sandbox_release",
}),
)

filegroup(
name = "dlls_opt",
srcs = ["Release/{}".format(name) for name in WIN_DLLS] +
select({
"//:windows_64": ["Release/{}".format(name) for name in WIN_DLLS_X64],
"@cef//:windows_64": ["Release/{}".format(name) for name in WIN_DLLS_X64],
"//conditions:default": None,
}),
)
Expand All @@ -256,16 +256,16 @@ filegroup(
name = "dlls_dbg",
srcs = ["Debug/{}".format(name) for name in WIN_DLLS] +
select({
"//:windows_64": ["Debug/{}".format(name) for name in WIN_DLLS_X64],
"@cef//:windows_64": ["Debug/{}".format(name) for name in WIN_DLLS_X64],
"//conditions:default": None,
}),
)

alias(
name = "dlls",
actual = select({
"//:dbg": ":dlls_dbg",
"//conditions:default": ":dlls_opt",
"@cef//:dbg": "@cef//:dlls_dbg",
"//conditions:default": "@cef//:dlls_opt",
})
)

Expand All @@ -282,8 +282,8 @@ filegroup(
alias(
name = "sos",
actual = select({
"//:dbg": ":sos_dbg",
"//conditions:default": ":sos_opt",
"@cef//:dbg": "@cef//:sos_dbg",
"//conditions:default": "@cef//:sos_opt",
})
)

Expand All @@ -300,7 +300,7 @@ filegroup(
"Release/snapshot_blob.bin",
"Release/v8_context_snapshot.bin",
"Release/vk_swiftshader_icd.json",
":resources_common",
"@cef//:resources_common",
],
)

Expand All @@ -310,15 +310,15 @@ filegroup(
"Debug/snapshot_blob.bin",
"Debug/v8_context_snapshot.bin",
"Debug/vk_swiftshader_icd.json",
":resources_common",
"@cef//:resources_common",
],
)

alias(
name = "resources",
actual = select({
"//:opt": ":resources_opt",
"//conditions:default": ":resources_dbg",
"@cef//:opt": "@cef//:resources_opt",
"//conditions:default": "@cef//:resources_dbg",
})
)

Expand Down Expand Up @@ -352,15 +352,15 @@ cc_import(
alias(
name = "cef",
actual = select({
"//:dbg": ":cef_dbg",
"//conditions:default": ":cef_opt",
"@cef//:dbg": "@cef//:cef_dbg",
"//conditions:default": "@cef//:cef_opt",
}),
)

apple_dynamic_framework_import(
name = "cef_framework",
framework_imports = select({
"//:dbg": glob(["Debug/{}.framework/**".format(CEF_FRAMEWORK_NAME)]),
"@cef//:dbg": glob(["Debug/{}.framework/**".format(CEF_FRAMEWORK_NAME)]),
"//conditions:default": glob(["Release/{}.framework/**".format(CEF_FRAMEWORK_NAME)]),
}),
)

0 comments on commit 2b5cb6a

Please sign in to comment.