From 1231af292c611c8cf24ca25665c1822c68f63fe1 Mon Sep 17 00:00:00 2001 From: Matthew Maurer Date: Thu, 16 Jun 2022 13:31:35 -0700 Subject: [PATCH 1/2] c2a: Fix rust_version calculation string-typed result groups would cause the comparison to fail with a type error. Explicitly casting results to integer for comparison, then back to string for concatenation causes things to work again. Bug: 234744235 Test: Run tool with no --cargo_bin option (and the following patch) (thus using local cargo version detection) and observe success. Change-Id: I91d8de925c1b6eca7c9905ea85e1ad90e01fb1f9 --- scripts/cargo2android.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/cargo2android.py b/scripts/cargo2android.py index a9d57ebeb..0eafda45f 100755 --- a/scripts/cargo2android.py +++ b/scripts/cargo2android.py @@ -1205,10 +1205,10 @@ class Runner(object): result = version_pat.match(dir_name) if not result: continue - version = (result.group(1), result.group(2), result.group(3)) + version = (int(result.group(1)), int(result.group(2)), int(result.group(3))) if version > rust_version: rust_version = version - return '.'.join(rust_version) + return '.'.join(map(str, rust_version)) def find_out_files(self): # list1 has build.rs output for normal crates From ce53b80d816440d9bd63e80eb9cffdf3ddf0f5d6 Mon Sep 17 00:00:00 2001 From: Matthew Maurer Date: Thu, 16 Jun 2022 13:18:20 -0700 Subject: [PATCH 2/2] c2a: Our cargo works again, re-enable defaulting. Bug: 234744235 Test: Run cargo2android.py without --cargo_bin Test: Run in the sandbox without providing --cargo_bin Change-Id: I4c3744e0e391ab7e4fb6a857483fde5c0015f0ff --- scripts/cargo2android.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/scripts/cargo2android.py b/scripts/cargo2android.py index 0eafda45f..ae9bd2e62 100755 --- a/scripts/cargo2android.py +++ b/scripts/cargo2android.py @@ -1160,12 +1160,6 @@ class Runner(object): sys.exit('ERROR: cannot find cargo in ' + self.args.cargo_bin) print('INFO: using cargo in ' + self.args.cargo_bin) return - elif os.environ.get('ANDROID_BUILD_ENVIRONMENT_CONFIG', '') == 'googler': - sys.exit('ERROR: Not executed within the sandbox. Please see ' - 'go/cargo2android-sandbox for more information.') - else: - sys.exit('ERROR: the prebuilt cargo is not usable; please ' - 'use the --cargo_bin flag.') # We have only tested this on Linux. if platform.system() != 'Linux': sys.exit('ERROR: this script has only been tested on Linux with cargo.')