mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
bazel: Limit define scope to specific cc targets (see #3757)
- Add `declare_[cc|objc]_library` macros to configure common `copts` and `local_defines` (where supported) on `[cc|objc]_library` targets. This limits the scope of defines to the specific target without inheritance by dependent targets. - `objc_library` does not currently support `local_defines` so we use `copts` instead of MacOS. - Use `**kwargs` to pass all other arguments to the actual cc target declaration.
This commit is contained in:
@ -6,10 +6,11 @@ load("//bazel:copy_filegroups.bzl", "copy_filegroups")
|
||||
load("//bazel/linux:fix_rpath.bzl", "fix_rpath")
|
||||
load("//bazel/linux:variables.bzl",
|
||||
"COMMON_LINKOPTS",
|
||||
"COMMON_COPTS", "COMMON_COPTS_RELEASE", "COMMON_COPTS_DEBUG")
|
||||
"COMMON_COPTS", "COMMON_COPTS_RELEASE", "COMMON_COPTS_DEBUG",
|
||||
"COMMON_DEFINES", "COMMON_DEFINES_RELEASE", "COMMON_DEFINES_DEBUG")
|
||||
load("@rules_cc//cc:defs.bzl", "cc_binary")
|
||||
|
||||
def declare_exe(name, srcs=[], deps=[], linkopts=[], copts=[], defines=[], data=[]):
|
||||
def declare_exe(name, srcs=[], deps=[], linkopts=[], copts=[], local_defines=[], data=[], **kwargs):
|
||||
# Copy SOs and resources into the current project.
|
||||
copy_target = "{}_sos_and_resources".format(name)
|
||||
copy_filegroups(
|
||||
@ -36,15 +37,19 @@ def declare_exe(name, srcs=[], deps=[], linkopts=[], copts=[], defines=[], data=
|
||||
"@cef//:cef_sandbox",
|
||||
] + deps,
|
||||
linkopts = COMMON_LINKOPTS + linkopts,
|
||||
copts = select({
|
||||
copts = COMMON_COPTS + select({
|
||||
"@cef//:linux_dbg": COMMON_COPTS_DEBUG,
|
||||
"//conditions:default": COMMON_COPTS_RELEASE,
|
||||
}) + COMMON_COPTS + copts,
|
||||
defines = defines,
|
||||
}) + copts,
|
||||
local_defines = COMMON_DEFINES + select({
|
||||
"@cef//:linux_dbg": COMMON_DEFINES_DEBUG,
|
||||
"//conditions:default": COMMON_DEFINES_RELEASE,
|
||||
}) + local_defines,
|
||||
data = [
|
||||
":{}".format(copy_target),
|
||||
] + data,
|
||||
target_compatible_with = ["@platforms//os:linux"],
|
||||
**kwargs
|
||||
)
|
||||
|
||||
# Set rpath to $ORIGIN so that libraries can be loaded from next to the
|
||||
|
Reference in New Issue
Block a user