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:
Marshall Greenblatt
2024-08-06 11:57:15 -04:00
parent 166eec85e0
commit 9e9ba2c543
9 changed files with 149 additions and 104 deletions

View File

@@ -7,7 +7,7 @@ MACOS_BUNDLE_ID_BASE="org.cef"
CEF_FRAMEWORK_NAME="Chromium Embedded Framework"
#
# Common 'linkopts' for cc_binary targets.
# Common 'linkopts' for macos_application targets.
#
# Standard link frameworks.
@@ -29,34 +29,24 @@ COMMON_LINKOPTS = [
})
#
# Common 'copts' for cc_libary and cc_binary targets.
# Common 'copts' for cc_libary, objc_library and macos_application targets.
# We include defines in 'copts' because objc_library does not support
# 'local_defines'. See https://github.com/bazelbuild/bazel/issues/17482.
#
COMMON_COPTS = [
"-Wno-undefined-var-template",
"-Wno-missing-field-initializers",
"-Wno-deprecated-copy",
# Used by apps to test if the sandbox is enabled
"-DCEF_USE_SANDBOX",
]
COMMON_COPTS_DEBUG = [
]
COMMON_COPTS_RELEASE = [
]
#
# Common 'defines' for cc_libary targets.
#
COMMON_DEFINES = [
# Used by apps to test if the sandbox is enabled
"CEF_USE_SANDBOX",
]
COMMON_DEFINES_DEBUG = [
]
COMMON_DEFINES_RELEASE = [
# Not a debug build
"NDEBUG",
"-DNDEBUG",
]