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/Android.bp.swp b/tools/gn2bp/Android.bp.swp
index f2bffc4..cbfc048 100644
--- a/tools/gn2bp/Android.bp.swp
+++ b/tools/gn2bp/Android.bp.swp
@@ -216,6 +216,9 @@
         "out/test/gen/",
         "third_party/android_ndk/sources/android/cpufeatures/",
     ],
+    header_libs: [
+        "jni_headers",
+    ],
 }
 
 // GN: //base/allocator/partition_allocator:partition_alloc_buildflags
@@ -962,6 +965,9 @@
         "third_party/icu/source/common/",
         "third_party/icu/source/i18n/",
     ],
+    header_libs: [
+        "jni_headers",
+    ],
 }
 
 // GN: //base:base_jni_headers
@@ -1265,6 +1271,9 @@
         "buildtools/third_party/libc++/",
         "out/test/gen/",
     ],
+    header_libs: [
+        "jni_headers",
+    ],
 }
 
 // GN: //base:build_date
@@ -1583,6 +1592,9 @@
         "buildtools/third_party/libc++/",
         "out/test/gen/",
     ],
+    header_libs: [
+        "jni_headers",
+    ],
 }
 
 // GN: //base/third_party/dynamic_annotations:dynamic_annotations
@@ -1614,6 +1626,9 @@
         "buildtools/third_party/libc++/",
         "out/test/gen/",
     ],
+    header_libs: [
+        "jni_headers",
+    ],
 }
 
 // GN: //base:tracing_buildflags
@@ -2804,6 +2819,9 @@
         "out/test/gen/",
         "third_party/boringssl/src/include/",
     ],
+    header_libs: [
+        "jni_headers",
+    ],
 }
 
 // GN: //third_party/boringssl:boringssl_asm
@@ -2859,6 +2877,9 @@
         "third_party/icu/source/common/",
         "third_party/icu/source/i18n/",
     ],
+    header_libs: [
+        "jni_headers",
+    ],
 }
 
 // GN: //third_party/icu:icuuc_private
@@ -2907,6 +2928,9 @@
         "third_party/icu/source/common/",
         "third_party/icu/source/i18n/",
     ],
+    header_libs: [
+        "jni_headers",
+    ],
 }
 
 // GN: //third_party/icu:icuuc_public
@@ -2958,6 +2982,9 @@
         "out/test/gen/",
         "third_party/libevent/android/",
     ],
+    header_libs: [
+        "jni_headers",
+    ],
 }
 
 // GN: //third_party/modp_b64:modp_b64
@@ -2991,5 +3018,8 @@
         "buildtools/third_party/libc++/",
         "out/test/gen/",
     ],
+    header_libs: [
+        "jni_headers",
+    ],
 }
 
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')