Skip to content

Commit

Permalink
bazel: mac: Copy but don't link the CEF framework (see #3757)
Browse files Browse the repository at this point in the history
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 `**kwargs` to pass all other arguments to the actual
`macos_application` target declaration.
  • Loading branch information
magreenblatt committed Aug 9, 2024
1 parent 62b2b5a commit e9e2e14
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
21 changes: 13 additions & 8 deletions bazel/mac/app_helpers.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""
Expand Down Expand Up @@ -43,6 +46,7 @@ def _declare_helper_app(name, info_plist, deps, helper_base_name, helper_suffix)
deps = [
"@cef//:cef_sandbox",
] + deps,
**kwargs,
)

HELPERS = {
Expand All @@ -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.
"""
Expand All @@ -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.
"""
Expand All @@ -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()),
Expand All @@ -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,
)
15 changes: 10 additions & 5 deletions tools/distrib/bazel/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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),
)
1 change: 1 addition & 0 deletions tools/distrib/bazel/MODULE.bazel.in
Original file line number Diff line number Diff line change
Expand Up @@ -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")

0 comments on commit e9e2e14

Please sign in to comment.