gn2bp: add common header dependencies to defaults
Chromium builds get these headers directly from sysroot, so they do
not explicitly list the dependency. While this is probably an upstream
bug (or at least a limitation), it is easiest to just add them to
cc_defaults.
This also adds jni_headers which are required by multiple targets.
Test: //components/cronet/android:cronet
Change-Id: Ifb8843aaa60b2454544886b3e60aae42f9a5388e
diff --git a/tools/gn2bp/Android.bp.swp b/tools/gn2bp/Android.bp.swp
index 87f3931..9c29144 100644
--- a/tools/gn2bp/Android.bp.swp
+++ b/tools/gn2bp/Android.bp.swp
@@ -931,7 +931,6 @@
],
header_libs: [
"jni_headers",
- "media_ndk_headers",
],
cpp_std: "c++20",
target: {
@@ -3379,6 +3378,12 @@
],
stl: "none",
target: {
+ android: {
+ header_libs: [
+ "jni_headers",
+ "media_ndk_headers",
+ ],
+ },
host: {
cflags: [
"-UANDROID",
diff --git a/tools/gn2bp/gen_android_bp b/tools/gn2bp/gen_android_bp
index ac54f64..d2c824d 100755
--- a/tools/gn2bp/gen_android_bp
+++ b/tools/gn2bp/gen_android_bp
@@ -131,9 +131,6 @@
# that doesn't depend on rtti. undefined symbol: typeinfo 'class' errors appears.
('rtti', True), # go/undefined-symbol-typeinfo
],
- 'cronet_aml_base_base': [
- ('header_libs', {"media_ndk_headers"}),
- ],
}
# Android equivalents for third-party libraries that the upstream project
@@ -206,6 +203,7 @@
self.shared_libs = set()
self.static_libs = set()
self.whole_static_libs = set()
+ self.header_libs = set()
self.cflags = set()
self.dist = dict()
self.strip = dict()
@@ -220,6 +218,7 @@
self._output_field(nested_out, 'shared_libs')
self._output_field(nested_out, 'static_libs')
self._output_field(nested_out, 'whole_static_libs')
+ self._output_field(nested_out, 'header_libs')
self._output_field(nested_out, 'cflags')
self._output_field(nested_out, 'stl')
self._output_field(nested_out, 'dist')
@@ -1216,6 +1215,12 @@
'-Wno-unreachable-code-loop-increment', # needed for icui18n
'-O2',
]
+ # Chromium builds do not add a dependency for headers found inside the
+ # sysroot, so they are added globally via defaults.
+ defaults.target['android'].header_libs = [
+ 'media_ndk_headers',
+ 'jni_headers',
+ ]
defaults.target['host'].cflags = [
# -DANDROID is added by default but target.defines contain -DANDROID if
# it's required. So adding -UANDROID to cancel default -DANDROID if it's