From d5d033979fdeba50f3d4668244fdd582e3062224 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thi=C3=A9baud=20Weksteen?= Date: Wed, 9 Feb 2022 10:48:15 +1100 Subject: [PATCH] Require cargo_bin option The prebuilt cargo (or more precisely, its libstd) cannot be used when running cargo2android.py. Ensure that the upstream cargo binary is used. This is automatically set when using the sandbox for Googlers. For external contributors, raise an error if the option is not provided. Test: As a googler, execute cargo2android.py directly; an error is raised. Test: As a googler, use the sandbox; cargo2android.py is executed correctly. Test: As an external contributor, execute cargo2android.py; an error is raised if cargo_bin is not provided. Bug: 217810523 Change-Id: Id42ba777b3960b13f6ef91d36eaad94df939f48e --- scripts/cargo2android.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/cargo2android.py b/scripts/cargo2android.py index 9aa7d12c3..c571dabe2 100755 --- a/scripts/cargo2android.py +++ b/scripts/cargo2android.py @@ -1152,8 +1152,14 @@ class Runner(object): self.cargo_path = os.path.join(self.args.cargo_bin, 'cargo') if not os.path.isfile(self.cargo_path): sys.exit('ERROR: cannot find cargo in ' + self.args.cargo_bin) - print('WARNING: using 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.')