gn2bp: get arch from toolchain
Default all non-android toolchains to the host toolchain. Some limited
host support may be required. Let's see.
Test: //components/cronet/android:cronet
Change-Id: I3bc7a0d5da0c9558bda83583a0a7f90b1a5a2597
diff --git a/tools/gn2bp/gn_utils.py b/tools/gn2bp/gn_utils.py
index e7ad37d..f56e41f 100644
--- a/tools/gn2bp/gn_utils.py
+++ b/tools/gn2bp/gn_utils.py
@@ -202,6 +202,21 @@
# TODO: There are some other possible variations we might need to support.
return target.type == 'group' and re.match('.*_java$', target.name)
+ def _get_arch(self, toolchain):
+ if toolchain is None:
+ # TODO: throw an exception instead of defaulting to x86_64.
+ return 'x86_64'
+ elif toolchain == '//build/toolchain/android:android_clang_x86':
+ return 'x86'
+ elif toolchain == '//build/toolchain/android:android_clang_x64':
+ return 'x86_64'
+ elif toolchain == '//build/toolchain/android:android_clang_arm':
+ return 'arm'
+ elif toolchain == '//build/toolchain/android:android_clang_arm64':
+ return 'arm64'
+ else:
+ return 'host'
+
def get_target(self, gn_target_name):
"""Returns a Target object from the fully qualified GN target name.
@@ -220,8 +235,7 @@
target_name = label_without_toolchain(gn_target_name)
target = self.all_targets.get(target_name)
desc = gn_desc[gn_target_name]
- # TODO: get arch from toolchain
- arch = 'x86_64'
+ arch = self._get_arch(desc.get('toolchain', None))
if target is None:
target = GnParser.Target(target_name, desc['type'])
self.all_targets[target_name] = target
@@ -232,6 +246,7 @@
return target # Target already processed.
target.testonly = desc.get('testonly', False)
+ # TODO: remove toolchain from Target object
target.toolchain = desc.get('toolchain', None)
proto_target_type, proto_desc = self.get_proto_target_type(gn_desc, gn_target_name)