Bug 1290957 - ensure MOZ_AUTOMATION builds require a cargo with --frozen support; r=chmanchester
authorNathan Froyd <froydnj@gmail.com>
Tue, 09 Aug 2016 18:10:19 -0400
changeset 398696 c8be3efb34863ed1b532536c3cc77ad46340d497
parent 398695 03fbe28e5a1084a2496fdae846b10c607434bdc7
child 398697 a5fdb733058ba8eac47c94965c7d20082837ece1
push id25600
push userbmo:tchiovoloni@mozilla.com
push dateTue, 09 Aug 2016 16:33:05 +0000
reviewerschmanchester
bugs1290957
milestone51.0a1
Bug 1290957 - ensure MOZ_AUTOMATION builds require a cargo with --frozen support; r=chmanchester We want to ensure that our automation builds don't pull in libraries from crates.io, and we need --frozen support in cargo to do that. If we don't have that support, we shouldn't build.
build/moz.configure/rust.configure
--- a/build/moz.configure/rust.configure
+++ b/build/moz.configure/rust.configure
@@ -27,22 +27,26 @@ def rustc_info(rustc):
         return namespace(
             version=Version(info.get('release', '0')),
             commit=info.get('commit-hash', 'unknown'),
         )
 
 @depends_if(cargo)
 @checking('cargo support for --frozen')
 @imports('subprocess')
+@imports('os')
 def cargo_supports_frozen(cargo):
     try:
         lines = subprocess.check_output(
             [cargo, 'help', 'build']
         ).splitlines()
-        return any('    --frozen' in l for l in lines)
+        supported = any('    --frozen' in l for l in lines)
+        if 'MOZ_AUTOMATION' in os.environ and not supported:
+            die('cargo in automation must support --frozen')
+        return supported
     except subprocess.CalledProcessError as e:
         die('Failed to call cargo: %s', e.message)
 
 set_config('MOZ_CARGO_SUPPORTS_FROZEN', cargo_supports_frozen)
 
 @depends('--enable-rust', rustc, rustc_info)
 @imports(_from='textwrap', _import='dedent')
 def rust_compiler(value, rustc, rustc_info):