gn2bp: Cancel -DANDROID if it's not specified
Test: ./update_results.sh
Change-Id: I2aedd1f170d19e6cf66fcfa35a4189eb2c9dcfa9
diff --git a/tools/gn2bp/Android.bp.swp b/tools/gn2bp/Android.bp.swp
index 630e946..376b8f1 100644
--- a/tools/gn2bp/Android.bp.swp
+++ b/tools/gn2bp/Android.bp.swp
@@ -1727,6 +1727,7 @@
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCPP_ENABLE_ASSERTIONS_DEFAULT=1",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-UANDROID",
],
local_include_dirs: [
"./",
@@ -1773,6 +1774,7 @@
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCPP_ENABLE_ASSERTIONS_DEFAULT=1",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-UANDROID",
],
local_include_dirs: [
"./",
@@ -1814,6 +1816,7 @@
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
"-D__STDC_CONSTANT_MACROS",
"-D__STDC_FORMAT_MACROS",
+ "-UANDROID",
],
local_include_dirs: [
"./",
@@ -4379,6 +4382,7 @@
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
"-D__STDC_CONSTANT_MACROS",
"-D__STDC_FORMAT_MACROS",
+ "-UANDROID",
],
local_include_dirs: [
"./",
@@ -6783,6 +6787,7 @@
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
"-D__STDC_CONSTANT_MACROS",
"-D__STDC_FORMAT_MACROS",
+ "-UANDROID",
],
local_include_dirs: [
"./",
diff --git a/tools/gn2bp/gen_android_bp b/tools/gn2bp/gen_android_bp
index 5c3ac46..2644e43 100755
--- a/tools/gn2bp/gen_android_bp
+++ b/tools/gn2bp/gen_android_bp
@@ -1048,6 +1048,11 @@
cflags = {flag for flag in target.cflags if re.match(cflag_allowlist, flag)}
# Consider proper allowlist or denylist if needed
cflags |= set("-D%s" % define.replace("\"", "\\\"") for define in target.defines)
+ # -DANDROID is added by default but target.defines contain -DANDROID if it's required.
+ # So adding -UANDROID to cancel default -DANDROID if it's not specified.
+ # This is needed for some targets(e.g. symbolize)
+ if "ANDROID" not in target.defines:
+ cflags.add("-UANDROID")
return cflags