gn2bp: add jni_headers if --sysroot is set in cflags
This is a hack to get jni targets that expect to get jni.h from sysroot
to work.
We should implement proper (whatever that means...) cflag parsing.
Test: //base:base
Change-Id: I8c1f99ea2087284eb1c2950071861db2913fe155
diff --git a/tools/gn2bp/gen_android_bp b/tools/gn2bp/gen_android_bp
index 0fec478..85fdba5 100755
--- a/tools/gn2bp/gen_android_bp
+++ b/tools/gn2bp/gen_android_bp
@@ -824,6 +824,12 @@
if target.type in gn_utils.LINKER_UNIT_TYPES:
module.cflags.update(_get_cflags(target))
+ # HACK! We may have to link against chromium's sysroot instead, but this
+ # seems to work for //base:base.
+ # TODO: implement proper cflag parsing.
+ for flag in target.cflags:
+ if '--sysroot=' in flag:
+ module.header_libs.add('jni_headers')
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')