Merge changes I2aedd1f1,I9bdf8d07
* changes:
gn2bp: Cancel -DANDROID if it's not specified
gn2bp: Added required include PATH
diff --git a/tools/gn2bp/Android.bp.swp b/tools/gn2bp/Android.bp.swp
index 62afa61..376b8f1 100644
--- a/tools/gn2bp/Android.bp.swp
+++ b/tools/gn2bp/Android.bp.swp
@@ -1727,12 +1727,14 @@
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCPP_ENABLE_ASSERTIONS_DEFAULT=1",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-UANDROID",
],
local_include_dirs: [
"./",
"buildtools/third_party/libc++/",
"buildtools/third_party/libc++/trunk/include",
"buildtools/third_party/libc++abi/trunk/include",
+ "build/linux/debian_bullseye_amd64-sysroot/usr/include/x86_64-linux-gnu",
"build/linux/debian_bullseye_amd64-sysroot/usr/include",
],
cpp_std: "c++20",
@@ -1772,12 +1774,14 @@
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCPP_ENABLE_ASSERTIONS_DEFAULT=1",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-UANDROID",
],
local_include_dirs: [
"./",
"buildtools/third_party/libc++/",
"buildtools/third_party/libc++/trunk/include",
"buildtools/third_party/libc++abi/trunk/include",
+ "build/linux/debian_bullseye_amd64-sysroot/usr/include/x86_64-linux-gnu",
"build/linux/debian_bullseye_amd64-sysroot/usr/include",
],
cpp_std: "c++20",
@@ -1812,12 +1816,14 @@
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
"-D__STDC_CONSTANT_MACROS",
"-D__STDC_FORMAT_MACROS",
+ "-UANDROID",
],
local_include_dirs: [
"./",
"buildtools/third_party/libc++/",
"buildtools/third_party/libc++/trunk/include",
"buildtools/third_party/libc++abi/trunk/include",
+ "build/linux/debian_bullseye_amd64-sysroot/usr/include/x86_64-linux-gnu",
"build/linux/debian_bullseye_amd64-sysroot/usr/include",
],
cpp_std: "c++20",
@@ -4376,6 +4382,7 @@
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
"-D__STDC_CONSTANT_MACROS",
"-D__STDC_FORMAT_MACROS",
+ "-UANDROID",
],
local_include_dirs: [
"./",
@@ -4385,6 +4392,7 @@
"buildtools/third_party/libc++abi/trunk/include",
"third_party/abseil-cpp/",
"third_party/boringssl/src/include/",
+ "build/linux/debian_bullseye_amd64-sysroot/usr/include/x86_64-linux-gnu",
"build/linux/debian_bullseye_amd64-sysroot/usr/include",
],
cpp_std: "c++20",
@@ -6779,6 +6787,7 @@
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
"-D__STDC_CONSTANT_MACROS",
"-D__STDC_FORMAT_MACROS",
+ "-UANDROID",
],
local_include_dirs: [
"./",
@@ -6786,6 +6795,7 @@
"buildtools/third_party/libc++/trunk/include",
"buildtools/third_party/libc++abi/trunk/include",
"third_party/zlib/",
+ "build/linux/debian_bullseye_amd64-sysroot/usr/include/x86_64-linux-gnu",
"build/linux/debian_bullseye_amd64-sysroot/usr/include",
],
cpp_std: "c++20",
diff --git a/tools/gn2bp/gen_android_bp b/tools/gn2bp/gen_android_bp
index 4bd2479..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
@@ -1153,7 +1158,10 @@
# include. So adding sysroot include at the end.
for flag in target.cflags:
if '--sysroot' in flag:
- module.local_include_dirs.append(flag[len('--sysroot=../../'):] + "/usr/include")
+ sysroot = flag[len('--sysroot=../../'):]
+ if sysroot == "build/linux/debian_bullseye_amd64-sysroot":
+ module.local_include_dirs.append(sysroot + "/usr/include/x86_64-linux-gnu")
+ module.local_include_dirs.append(sysroot + "/usr/include")
module_is_compiled = module.type not in ('genrule', 'filegroup')
if module_is_compiled: