gn2bp: use name without toolchain for Targets

This change does affect the Android.bp.swp for targets that currently
exist in multiple toolchain variations. Only the first one is parsed.

Test: //components/cronet/android:cronet
Change-Id: I77501b1b195a91a61e29566d540ecc7dfadeea75
diff --git a/tools/gn2bp/Android.bp.swp b/tools/gn2bp/Android.bp.swp
index b769545..5d9e1a8 100644
--- a/tools/gn2bp/Android.bp.swp
+++ b/tools/gn2bp/Android.bp.swp
@@ -1698,137 +1698,6 @@
     cpp_std: "c++20",
 }
 
-// GN: //base/third_party/symbolize:symbolize
-cc_library_static {
-    name: "cronet_aml_base_third_party_symbolize_symbolize",
-    srcs: [
-        "base/third_party/symbolize/demangle.cc",
-        "base/third_party/symbolize/symbolize.cc",
-    ],
-    defaults: [
-        "cronet_aml_defaults",
-    ],
-    cflags: [
-        "-DCR_CLANG_REVISION=\"llvmorg-16-init-8697-g60809cd2-1\"",
-        "-DCR_LIBCXX_REVISION=47b31179d10646029c260702650a25d24f555acc",
-        "-DCR_SYSROOT_KEY=20220331T153654Z-0",
-        "-DDCHECK_ALWAYS_ON=1",
-        "-DDYNAMIC_ANNOTATIONS_ENABLED=1",
-        "-DGLOG_EXPORT=",
-        "-DUSE_AURA=1",
-        "-DUSE_OZONE=1",
-        "-DUSE_UDEV",
-        "-D_DEBUG",
-        "-D_FILE_OFFSET_BITS=64",
-        "-D_GNU_SOURCE",
-        "-D_LARGEFILE64_SOURCE",
-        "-D_LARGEFILE_SOURCE",
-        "-D_LIBCPP_AVAILABILITY_CUSTOM_VERBOSE_ABORT_PROVIDED=1",
-        "-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
-        "-D_LIBCPP_ENABLE_ASSERTIONS_DEFAULT=1",
-        "-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
-        "-UANDROID",
-    ],
-    local_include_dirs: [
-        "./",
-        "buildtools/third_party/libc++/",
-        "buildtools/third_party/libc++/trunk/include",
-        "buildtools/third_party/libc++abi/trunk/include",
-        "build/linux/debian_bullseye_amd64-sysroot/usr/include/x86_64-linux-gnu",
-        "build/linux/debian_bullseye_amd64-sysroot/usr/include",
-    ],
-    cpp_std: "c++20",
-}
-
-// GN: //base/third_party/xdg_mime:xdg_mime
-cc_library_static {
-    name: "cronet_aml_base_third_party_xdg_mime_xdg_mime",
-    srcs: [
-        "base/third_party/xdg_mime/xdgmime.c",
-        "base/third_party/xdg_mime/xdgmimealias.c",
-        "base/third_party/xdg_mime/xdgmimecache.c",
-        "base/third_party/xdg_mime/xdgmimeglob.c",
-        "base/third_party/xdg_mime/xdgmimeicon.c",
-        "base/third_party/xdg_mime/xdgmimeint.c",
-        "base/third_party/xdg_mime/xdgmimemagic.c",
-        "base/third_party/xdg_mime/xdgmimeparent.c",
-    ],
-    defaults: [
-        "cronet_aml_defaults",
-    ],
-    cflags: [
-        "-DCR_CLANG_REVISION=\"llvmorg-16-init-8697-g60809cd2-1\"",
-        "-DCR_LIBCXX_REVISION=47b31179d10646029c260702650a25d24f555acc",
-        "-DCR_SYSROOT_KEY=20220331T153654Z-0",
-        "-DDCHECK_ALWAYS_ON=1",
-        "-DDYNAMIC_ANNOTATIONS_ENABLED=1",
-        "-DUSE_AURA=1",
-        "-DUSE_OZONE=1",
-        "-DUSE_UDEV",
-        "-D_DEBUG",
-        "-D_FILE_OFFSET_BITS=64",
-        "-D_GNU_SOURCE",
-        "-D_LARGEFILE64_SOURCE",
-        "-D_LARGEFILE_SOURCE",
-        "-D_LIBCPP_AVAILABILITY_CUSTOM_VERBOSE_ABORT_PROVIDED=1",
-        "-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
-        "-D_LIBCPP_ENABLE_ASSERTIONS_DEFAULT=1",
-        "-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
-        "-UANDROID",
-    ],
-    local_include_dirs: [
-        "./",
-        "buildtools/third_party/libc++/",
-        "buildtools/third_party/libc++/trunk/include",
-        "buildtools/third_party/libc++abi/trunk/include",
-        "build/linux/debian_bullseye_amd64-sysroot/usr/include/x86_64-linux-gnu",
-        "build/linux/debian_bullseye_amd64-sysroot/usr/include",
-    ],
-    cpp_std: "c++20",
-}
-
-// GN: //base/third_party/xdg_user_dirs:xdg_user_dirs
-cc_library_static {
-    name: "cronet_aml_base_third_party_xdg_user_dirs_xdg_user_dirs",
-    srcs: [
-        "base/third_party/xdg_user_dirs/xdg_user_dir_lookup.cc",
-    ],
-    defaults: [
-        "cronet_aml_defaults",
-    ],
-    cflags: [
-        "-DCR_CLANG_REVISION=\"llvmorg-16-init-8697-g60809cd2-1\"",
-        "-DCR_LIBCXX_REVISION=47b31179d10646029c260702650a25d24f555acc",
-        "-DCR_SYSROOT_KEY=20220331T153654Z-0",
-        "-DDCHECK_ALWAYS_ON=1",
-        "-DDYNAMIC_ANNOTATIONS_ENABLED=1",
-        "-DUSE_AURA=1",
-        "-DUSE_OZONE=1",
-        "-DUSE_UDEV",
-        "-D_DEBUG",
-        "-D_FILE_OFFSET_BITS=64",
-        "-D_GNU_SOURCE",
-        "-D_LARGEFILE64_SOURCE",
-        "-D_LARGEFILE_SOURCE",
-        "-D_LIBCPP_AVAILABILITY_CUSTOM_VERBOSE_ABORT_PROVIDED=1",
-        "-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
-        "-D_LIBCPP_ENABLE_ASSERTIONS_DEFAULT=1",
-        "-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
-        "-D__STDC_CONSTANT_MACROS",
-        "-D__STDC_FORMAT_MACROS",
-        "-UANDROID",
-    ],
-    local_include_dirs: [
-        "./",
-        "buildtools/third_party/libc++/",
-        "buildtools/third_party/libc++/trunk/include",
-        "buildtools/third_party/libc++abi/trunk/include",
-        "build/linux/debian_bullseye_amd64-sysroot/usr/include/x86_64-linux-gnu",
-        "build/linux/debian_bullseye_amd64-sysroot/usr/include",
-    ],
-    cpp_std: "c++20",
-}
-
 // GN: //base:tracing_buildflags
 genrule {
     name: "cronet_aml_base_tracing_buildflags",
@@ -2071,9 +1940,6 @@
         "cronet_aml_base_base_static",
         "cronet_aml_base_third_party_double_conversion_double_conversion",
         "cronet_aml_base_third_party_dynamic_annotations_dynamic_annotations",
-        "cronet_aml_base_third_party_symbolize_symbolize",
-        "cronet_aml_base_third_party_xdg_mime_xdg_mime",
-        "cronet_aml_base_third_party_xdg_user_dirs_xdg_user_dirs",
         "cronet_aml_components_prefs_prefs",
         "cronet_aml_crypto_crypto",
         "cronet_aml_net_net",
@@ -3436,9 +3302,6 @@
         "cronet_aml_base_base_static",
         "cronet_aml_base_third_party_double_conversion_double_conversion",
         "cronet_aml_base_third_party_dynamic_annotations_dynamic_annotations",
-        "cronet_aml_base_third_party_symbolize_symbolize",
-        "cronet_aml_base_third_party_xdg_mime_xdg_mime",
-        "cronet_aml_base_third_party_xdg_user_dirs_xdg_user_dirs",
         "cronet_aml_crypto_crypto",
         "cronet_aml_net_preload_decoder",
         "cronet_aml_net_third_party_quiche_quiche",
@@ -5730,19 +5593,26 @@
 filegroup {
     name: "cronet_aml_third_party_boringssl_boringssl_asm_x86",
     srcs: [
-        "third_party/boringssl/linux-x86/crypto/chacha/chacha-x86.S",
-        "third_party/boringssl/linux-x86/crypto/fipsmodule/aesni-x86.S",
-        "third_party/boringssl/linux-x86/crypto/fipsmodule/bn-586.S",
-        "third_party/boringssl/linux-x86/crypto/fipsmodule/co-586.S",
-        "third_party/boringssl/linux-x86/crypto/fipsmodule/ghash-ssse3-x86.S",
-        "third_party/boringssl/linux-x86/crypto/fipsmodule/ghash-x86.S",
-        "third_party/boringssl/linux-x86/crypto/fipsmodule/md5-586.S",
-        "third_party/boringssl/linux-x86/crypto/fipsmodule/sha1-586.S",
-        "third_party/boringssl/linux-x86/crypto/fipsmodule/sha256-586.S",
-        "third_party/boringssl/linux-x86/crypto/fipsmodule/sha512-586.S",
-        "third_party/boringssl/linux-x86/crypto/fipsmodule/vpaes-x86.S",
-        "third_party/boringssl/linux-x86/crypto/fipsmodule/x86-mont.S",
-        "third_party/boringssl/linux-x86/crypto/test/trampoline-x86.S",
+        "third_party/boringssl/linux-x86_64/crypto/chacha/chacha-x86_64.S",
+        "third_party/boringssl/linux-x86_64/crypto/cipher_extra/aes128gcmsiv-x86_64.S",
+        "third_party/boringssl/linux-x86_64/crypto/cipher_extra/chacha20_poly1305_x86_64.S",
+        "third_party/boringssl/linux-x86_64/crypto/fipsmodule/aesni-gcm-x86_64.S",
+        "third_party/boringssl/linux-x86_64/crypto/fipsmodule/aesni-x86_64.S",
+        "third_party/boringssl/linux-x86_64/crypto/fipsmodule/ghash-ssse3-x86_64.S",
+        "third_party/boringssl/linux-x86_64/crypto/fipsmodule/ghash-x86_64.S",
+        "third_party/boringssl/linux-x86_64/crypto/fipsmodule/md5-x86_64.S",
+        "third_party/boringssl/linux-x86_64/crypto/fipsmodule/p256-x86_64-asm.S",
+        "third_party/boringssl/linux-x86_64/crypto/fipsmodule/p256_beeu-x86_64-asm.S",
+        "third_party/boringssl/linux-x86_64/crypto/fipsmodule/rdrand-x86_64.S",
+        "third_party/boringssl/linux-x86_64/crypto/fipsmodule/rsaz-avx2.S",
+        "third_party/boringssl/linux-x86_64/crypto/fipsmodule/sha1-x86_64.S",
+        "third_party/boringssl/linux-x86_64/crypto/fipsmodule/sha256-x86_64.S",
+        "third_party/boringssl/linux-x86_64/crypto/fipsmodule/sha512-x86_64.S",
+        "third_party/boringssl/linux-x86_64/crypto/fipsmodule/vpaes-x86_64.S",
+        "third_party/boringssl/linux-x86_64/crypto/fipsmodule/x86_64-mont.S",
+        "third_party/boringssl/linux-x86_64/crypto/fipsmodule/x86_64-mont5.S",
+        "third_party/boringssl/linux-x86_64/crypto/test/trampoline-x86_64.S",
+        "third_party/boringssl/src/crypto/hrss/asm/poly_rq_mul.S",
     ],
 }
 
diff --git a/tools/gn2bp/gn_utils.py b/tools/gn2bp/gn_utils.py
index fd8bc75..276f723 100644
--- a/tools/gn2bp/gn_utils.py
+++ b/tools/gn2bp/gn_utils.py
@@ -199,7 +199,7 @@
 
       get_target() requires that parse_gn_desc() has already been called.
       """
-    return self.all_targets[gn_target_name]
+    return self.all_targets[label_without_toolchain(gn_target_name)]
 
   def parse_gn_desc(self, gn_desc, gn_target_name):
     """Parses a gn desc tree and resolves all target dependencies.
@@ -207,15 +207,18 @@
         It bubbles up variables from source_set dependencies as described in the
         class-level comments.
         """
-    target = self.all_targets.get(gn_target_name)
+    # Use name without toolchain for targets to support targets built for
+    # multiple archs.
+    target_name = label_without_toolchain(gn_target_name)
+    target = self.all_targets.get(target_name)
     if target is not None:
       return target  # Target already processed.
 
     desc = gn_desc[gn_target_name]
-    target = GnParser.Target(gn_target_name, desc['type'])
+    target = GnParser.Target(target_name, desc['type'])
     target.testonly = desc.get('testonly', False)
     target.toolchain = desc.get('toolchain', None)
-    self.all_targets[gn_target_name] = target
+    self.all_targets[target_name] = target
 
     proto_target_type, proto_desc = self.get_proto_target_type(gn_desc, gn_target_name)
     if proto_target_type is not None: