gn2bp: parse cpp_std from cflags
Chromium is using both c++20 and c++17 (though all of //base:base seems
to use c++20).
Test: //base:base
Change-Id: Ibda3b67e3745d7eda56f260ae8c065512c1f672b
diff --git a/tools/gn2bp/Android.bp.swp b/tools/gn2bp/Android.bp.swp
index 739b2b1..1f88b45 100644
--- a/tools/gn2bp/Android.bp.swp
+++ b/tools/gn2bp/Android.bp.swp
@@ -219,6 +219,7 @@
header_libs: [
"jni_headers",
],
+ cpp_std: "c++20",
}
// GN: //base/allocator/partition_allocator:partition_alloc_buildflags
@@ -968,6 +969,7 @@
header_libs: [
"jni_headers",
],
+ cpp_std: "c++20",
}
// GN: //base:base_jni_headers
@@ -1274,6 +1276,7 @@
header_libs: [
"jni_headers",
],
+ cpp_std: "c++20",
}
// GN: //base:build_date
@@ -1595,6 +1598,7 @@
header_libs: [
"jni_headers",
],
+ cpp_std: "c++20",
}
// GN: //base/third_party/dynamic_annotations:dynamic_annotations
@@ -1629,6 +1633,7 @@
header_libs: [
"jni_headers",
],
+ cpp_std: "c++20",
}
// GN: //base:tracing_buildflags
@@ -2822,6 +2827,7 @@
header_libs: [
"jni_headers",
],
+ cpp_std: "c++20",
}
// GN: //third_party/boringssl:boringssl_asm
@@ -2880,6 +2886,7 @@
header_libs: [
"jni_headers",
],
+ cpp_std: "c++20",
}
// GN: //third_party/icu:icuuc_private
@@ -2931,6 +2938,7 @@
header_libs: [
"jni_headers",
],
+ cpp_std: "c++20",
}
// GN: //third_party/icu:icuuc_public
@@ -2985,6 +2993,7 @@
header_libs: [
"jni_headers",
],
+ cpp_std: "c++20",
}
// GN: //third_party/modp_b64:modp_b64
@@ -3021,5 +3030,6 @@
header_libs: [
"jni_headers",
],
+ cpp_std: "c++20",
}
diff --git a/tools/gn2bp/gen_android_bp b/tools/gn2bp/gen_android_bp
index 40addef..88b2b5a 100755
--- a/tools/gn2bp/gen_android_bp
+++ b/tools/gn2bp/gen_android_bp
@@ -343,6 +343,7 @@
self.android = Target('android')
self.host = Target('host')
self.stl = None
+ self.cpp_std = None
self.dist = dict()
self.strip = dict()
self.data = set()
@@ -391,6 +392,7 @@
self._output_field(output, 'tool_files')
self._output_field(output, 'data')
self._output_field(output, 'stl')
+ self._output_field(output, 'cpp_std')
self._output_field(output, 'apex_available')
self._output_field(output, 'min_sdk_version')
self._output_field(output, 'version_script')
@@ -830,6 +832,9 @@
for flag in target.cflags:
if '--sysroot=' in flag:
module.header_libs.add('jni_headers')
+ if '-std=' in flag:
+ module.cpp_std = flag[len('-std='):]
+
module.local_include_dirs.update(gn_utils.label_to_path(it) for it in target.include_dirs)
module_is_compiled = module.type not in ('genrule', 'filegroup')