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/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: