aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLiz Kammer <eakammer@google.com>2022-05-05 10:59:59 -0400
committerLiz Kammer <eakammer@google.com>2022-05-05 14:25:12 -0400
commit2974bf57982767e6675a34efd454debac93ee942 (patch)
treefedb9bd7a2cae25e58992205e680d64b40c1f2f7
parentb8372800e1be24190dfe7f96606f308282e9267a (diff)
downloadbazel-2974bf57982767e6675a34efd454debac93ee942.tar.gz
Ensure apex defines are defined.
When compiling a cc artifact for an apex, we need to add apex-related defines: https://cs.android.com/android/platform/superproject/+/master:build/soong/cc/compiler.go;l=414-419;drc=7309742728063ebea25eff41df6ce0483fbe7f84. This is an interim solution; however, the long term solution requires implementing equivalents to the image mutator and min_sdk_version, sdk_version and sdk mutator. Test: b aquery deps(//b/b/examples/apex/minimal:build.bazel.examples.apex.minimal) and verify -D__ANDROID__APEX__ and -D__ANDROID_APEX_MIN_SDK_VERSION__=10000 exist Test: b aquery deps(//b/b/ex/apex/minimal:build.bazel.examples.apex.cc_binary) and verify -D__ANDROID__APEX__ and -D__ANDROID_APEX_MIN_SDK_VERSION__=10000 do not exist Bug: 197078967 Change-Id: If783ebd60dca3e6955d6403cdb0e81337cb4be98
-rw-r--r--rules/apex/BUILD7
-rw-r--r--rules/cc/cc_library_static.bzl11
2 files changed, 18 insertions, 0 deletions
diff --git a/rules/apex/BUILD b/rules/apex/BUILD
index e5051bcb..c3d6b9bf 100644
--- a/rules/apex/BUILD
+++ b/rules/apex/BUILD
@@ -7,6 +7,13 @@ string_setting(
visibility = ["//visibility:public"],
)
+config_setting(
+ name = "non_apex",
+ flag_values = {
+ ":apex_name": "",
+ },
+)
+
string_setting(
name = "min_sdk_version",
build_setting_default = "",
diff --git a/rules/cc/cc_library_static.bzl b/rules/cc/cc_library_static.bzl
index f994490c..4526900e 100644
--- a/rules/cc/cc_library_static.bzl
+++ b/rules/cc/cc_library_static.bzl
@@ -144,6 +144,17 @@ def cc_library_static(
],
)
+ # TODO(b/231574899): restructure this to handle other images
+ copts += select({
+ "//build/bazel/rules/apex:non_apex": [],
+ "//conditions:default": [
+ "-D__ANDROID_APEX__",
+ # TODO(b/231322772): sdk_version/min_sdk_version if not finalized
+ "-D__ANDROID_APEX_MIN_SDK_VERSION__=10000",
+ ],
+ })
+
+
native.cc_library(
name = cpp_name,
srcs = srcs,