From e71a509e5b5e2cc3740952639bce8c6be8f4ef83 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Wed, 31 Jul 2024 17:53:27 -0400 Subject: [PATCH] bazel: Add repo for package-local target labels (see #3757) 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(). --- bazel/linux/exe_helpers.bzl | 12 ++--- bazel/linux/variables.bzl | 2 +- bazel/mac/app_helpers.bzl | 8 ++-- bazel/mac/variables.bzl | 2 +- bazel/win/exe_helpers.bzl | 12 ++--- bazel/win/variables.bzl | 4 +- tools/distrib/bazel/BUILD.bazel | 84 ++++++++++++++++----------------- 7 files changed, 62 insertions(+), 62 deletions(-) diff --git a/bazel/linux/exe_helpers.bzl b/bazel/linux/exe_helpers.bzl index b543e99fe..e4f54e21b 100755 --- a/bazel/linux/exe_helpers.bzl +++ b/bazel/linux/exe_helpers.bzl @@ -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", @@ -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, diff --git a/bazel/linux/variables.bzl b/bazel/linux/variables.bzl index 8b2278d68..4b674d3f2 100755 --- a/bazel/linux/variables.bzl +++ b/bazel/linux/variables.bzl @@ -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, }) diff --git a/bazel/mac/app_helpers.bzl b/bazel/mac/app_helpers.bzl index 28e0c5a15..259513b02 100644 --- a/bazel/mac/app_helpers.bzl +++ b/bazel/mac/app_helpers.bzl @@ -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, @@ -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, ) @@ -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. """ @@ -103,6 +103,6 @@ def declare_main_app(name, info_plist, deps, linkopts, resources): "@platforms//os:macos", ], deps = [ - "//:cef_framework", + "@cef//:cef_framework", ] + deps, ) diff --git a/bazel/mac/variables.bzl b/bazel/mac/variables.bzl index acb9310f1..a15230c79 100644 --- a/bazel/mac/variables.bzl +++ b/bazel/mac/variables.bzl @@ -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, }) diff --git a/bazel/win/exe_helpers.bzl b/bazel/win/exe_helpers.bzl index 5664fb535..88b1ff7a2 100644 --- a/bazel/win/exe_helpers.bzl +++ b/bazel/win/exe_helpers.bzl @@ -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", @@ -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, diff --git a/bazel/win/variables.bzl b/bazel/win/variables.bzl index b2556d571..a3dd5742a 100644 --- a/bazel/win/variables.bzl +++ b/bazel/win/variables.bzl @@ -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, }) diff --git a/tools/distrib/bazel/BUILD.bazel b/tools/distrib/bazel/BUILD.bazel index c433e3a65..512685a62 100755 --- a/tools/distrib/bazel/BUILD.bazel +++ b/tools/distrib/bazel/BUILD.bazel @@ -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"], ) # @@ -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 = [ @@ -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"] + @@ -238,8 +238,8 @@ 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", }), ) @@ -247,7 +247,7 @@ 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, }), ) @@ -256,7 +256,7 @@ 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, }), ) @@ -264,8 +264,8 @@ filegroup( alias( name = "dlls", actual = select({ - "//:dbg": ":dlls_dbg", - "//conditions:default": ":dlls_opt", + "@cef//:dbg": "@cef//:dlls_dbg", + "//conditions:default": "@cef//:dlls_opt", }) ) @@ -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", }) ) @@ -300,7 +300,7 @@ filegroup( "Release/snapshot_blob.bin", "Release/v8_context_snapshot.bin", "Release/vk_swiftshader_icd.json", - ":resources_common", + "@cef//:resources_common", ], ) @@ -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", }) ) @@ -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)]), }), )