diff --git a/bazel/mac/app_helpers.bzl b/bazel/mac/app_helpers.bzl index 259513b02..3cfd70fa7 100644 --- a/bazel/mac/app_helpers.bzl +++ b/bazel/mac/app_helpers.bzl @@ -5,10 +5,13 @@ load("@bazel_skylib//rules:expand_template.bzl", "expand_template") load("@build_bazel_rules_apple//apple:macos.bzl", "macos_application") load("//bazel:variables.bzl", "VERSION_PLIST") -load("//bazel/mac:variables.bzl", "MACOS_DEPLOYMENT_TARGET", "MACOS_BUNDLE_ID_BASE", - "COMMON_LINKOPTS") +load("//bazel/mac:variables.bzl", + "MACOS_DEPLOYMENT_TARGET", + "MACOS_BUNDLE_ID_BASE", + "CEF_FRAMEWORK_NAME", + "COMMON_LINKOPTS") -def _declare_helper_app(name, info_plist, deps, helper_base_name, helper_suffix): +def _declare_helper_app(name, info_plist, deps, helper_base_name, helper_suffix, **kwargs): """ Creates a Helper .app target. """ @@ -43,6 +46,7 @@ def _declare_helper_app(name, info_plist, deps, helper_base_name, helper_suffix) deps = [ "@cef//:cef_sandbox", ] + deps, + **kwargs, ) HELPERS = { @@ -53,7 +57,7 @@ HELPERS = { "HelperRenderer": "Renderer", } -def declare_all_helper_apps(name, info_plist, deps): +def declare_all_helper_apps(name, info_plist, deps, **kwargs): """ Creates all Helper .app targets. """ @@ -63,9 +67,10 @@ def declare_all_helper_apps(name, info_plist, deps): deps = deps, helper_base_name = h, helper_suffix = v, + **kwargs, ) for h, v in HELPERS.items()] -def declare_main_app(name, info_plist, deps, resources, linkopts=[]): +def declare_main_app(name, info_plist, deps, resources, linkopts=[], **kwargs): """ Creates the main .app target. """ @@ -92,6 +97,7 @@ def declare_main_app(name, info_plist, deps, resources, linkopts=[]): ":HelperGPU": "Frameworks", ":HelperPlugin": "Frameworks", ":HelperRenderer": "Frameworks", + "@cef//:cef_framework": "Frameworks/{}.framework".format(CEF_FRAMEWORK_NAME), }, bundle_name = name, bundle_id = "{}.{}".format(MACOS_BUNDLE_ID_BASE, name.lower()), @@ -102,7 +108,6 @@ def declare_main_app(name, info_plist, deps, resources, linkopts=[]): target_compatible_with = [ "@platforms//os:macos", ], - deps = [ - "@cef//:cef_framework", - ] + deps, + deps = deps, + **kwargs, ) diff --git a/tools/distrib/bazel/BUILD.bazel b/tools/distrib/bazel/BUILD.bazel index a44b8ba86..1dc25e899 100755 --- a/tools/distrib/bazel/BUILD.bazel +++ b/tools/distrib/bazel/BUILD.bazel @@ -7,8 +7,8 @@ package(default_visibility = [ "//visibility:public", ]) +load("@aspect_bazel_lib//lib:copy_directory.bzl", "copy_directory") load("@bazel_skylib//lib:selects.bzl", "selects") -load("@build_bazel_rules_apple//apple:apple.bzl", "apple_dynamic_framework_import") load("//bazel:library_helpers.bzl", "declare_cc_library", "declare_objc_library") load("//bazel/win:variables.bzl", WIN_DLLS="DLLS", @@ -309,10 +309,15 @@ alias( }), ) -apple_dynamic_framework_import( +# Copy the CEF framework into the app bundle but do not link it. See +# https://groups.google.com/g/cef-announce/c/Fith0A3kWtw/m/6ds_mJVMCQAJ +# for background. Use `copy_directory` instead of `filegroup` to remove +# the Debug/Release path prefix. +copy_directory( name = "cef_framework", - framework_imports = select({ - "@cef//:dbg": glob(["Debug/{}.framework/**".format(CEF_FRAMEWORK_NAME)]), - "//conditions:default": glob(["Release/{}.framework/**".format(CEF_FRAMEWORK_NAME)]), + src = select({ + "@cef//:dbg": "Debug/{}.framework".format(CEF_FRAMEWORK_NAME), + "//conditions:default": "Release/{}.framework".format(CEF_FRAMEWORK_NAME), }), + out = "{}.framework".format(CEF_FRAMEWORK_NAME), ) diff --git a/tools/distrib/bazel/MODULE.bazel.in b/tools/distrib/bazel/MODULE.bazel.in index 24667b8c6..15b8782cd 100644 --- a/tools/distrib/bazel/MODULE.bazel.in +++ b/tools/distrib/bazel/MODULE.bazel.in @@ -15,3 +15,4 @@ bazel_dep(name = "rules_apple", version = "3.6.0", repo_name = "build_bazel_rule bazel_dep(name = "rules_cc", version = "0.0.9") # Add other dependencies here. +bazel_dep(name = "aspect_bazel_lib", version = "2.7.9")