gn2bp: properly forward jni_headers dependency

Gets rid of a hack that used to look at the presence of --sysroot and
blindly added a jni_headers dependency.

Test: //base:base
Change-Id: I629dcf2725f70c7beb87735086f54e01b7d63b86
diff --git a/tools/gn2bp/Android.bp.swp b/tools/gn2bp/Android.bp.swp
index 1f88b45..bb89e23 100644
--- a/tools/gn2bp/Android.bp.swp
+++ b/tools/gn2bp/Android.bp.swp
@@ -216,9 +216,6 @@
         "out/test/gen/",
         "third_party/android_ndk/sources/android/cpufeatures/",
     ],
-    header_libs: [
-        "jni_headers",
-    ],
     cpp_std: "c++20",
 }
 
@@ -1273,9 +1270,6 @@
         "buildtools/third_party/libc++/",
         "out/test/gen/",
     ],
-    header_libs: [
-        "jni_headers",
-    ],
     cpp_std: "c++20",
 }
 
@@ -1595,9 +1589,6 @@
         "buildtools/third_party/libc++/",
         "out/test/gen/",
     ],
-    header_libs: [
-        "jni_headers",
-    ],
     cpp_std: "c++20",
 }
 
@@ -1630,9 +1621,6 @@
         "buildtools/third_party/libc++/",
         "out/test/gen/",
     ],
-    header_libs: [
-        "jni_headers",
-    ],
     cpp_std: "c++20",
 }
 
@@ -2824,9 +2812,6 @@
         "out/test/gen/",
         "third_party/boringssl/src/include/",
     ],
-    header_libs: [
-        "jni_headers",
-    ],
     cpp_std: "c++20",
 }
 
@@ -2883,9 +2868,6 @@
         "third_party/icu/source/common/",
         "third_party/icu/source/i18n/",
     ],
-    header_libs: [
-        "jni_headers",
-    ],
     cpp_std: "c++20",
 }
 
@@ -2935,9 +2917,6 @@
         "third_party/icu/source/common/",
         "third_party/icu/source/i18n/",
     ],
-    header_libs: [
-        "jni_headers",
-    ],
     cpp_std: "c++20",
 }
 
@@ -2990,9 +2969,6 @@
         "out/test/gen/",
         "third_party/libevent/android/",
     ],
-    header_libs: [
-        "jni_headers",
-    ],
     cpp_std: "c++20",
 }
 
@@ -3027,9 +3003,6 @@
         "buildtools/third_party/libc++/",
         "out/test/gen/",
     ],
-    header_libs: [
-        "jni_headers",
-    ],
     cpp_std: "c++20",
 }
 
diff --git a/tools/gn2bp/gen_android_bp b/tools/gn2bp/gen_android_bp
index d01c5bd..2087554 100755
--- a/tools/gn2bp/gen_android_bp
+++ b/tools/gn2bp/gen_android_bp
@@ -685,6 +685,9 @@
         break
 
   elif target.script == '//base/android/jni_generator/jni_generator.py':
+    # chromium builds against a prebuilt ndk that contains the jni_headers, so
+    # a dependency is never explicitly created.
+    module.genrule_header_libs.add('jni_headers')
     for i, val in enumerate(target.args):
       if val == '--output_dir':
         # replace --output_dir gen/... with --output_dir $(genDir)/...
@@ -823,12 +826,8 @@
 
   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')
       if '-std=' in flag:
         module.cpp_std = flag[len('-std='):]