Bug 1494287 - Check existing cbindgen version and update if necessary. r=ted
authorTooru Fujisawa <arai_a@mac.com>
Fri, 12 Oct 2018 07:59:22 +0900
changeset 496561 9de896fd363f935bba655ee6f8ef213bfbcd11cb
parent 496560 961ceb4f759b0652a7da3d59d1349a4a3d6d4b1c
child 496562 965a5b3b29a0b3a2c0c89b0863992d9befbad616
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted
bugs1494287
milestone64.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1494287 - Check existing cbindgen version and update if necessary. r=ted
python/mozboot/mozboot/base.py
python/mozboot/mozboot/osx.py
taskcluster/scripts/misc/build-cbindgen.sh
--- a/python/mozboot/mozboot/base.py
+++ b/python/mozboot/mozboot/base.py
@@ -263,28 +263,37 @@ class BaseBootstrapper(object):
 
     def ensure_node_packages(self, state_dir, checkout_root):
         '''
         Install any necessary packages needed to supply NodeJS'''
         raise NotImplementedError(
             '%s does not yet implement ensure_node_packages()'
             % __name__)
 
-    def ensure_rust_package(self, crate_name):
-        if self.which(crate_name):
-            return
-        cargo_home, cargo_bin = self.cargo_home()
-        cargo_bin_path = os.path.join(cargo_bin, crate_name)
-        if os.path.exists(cargo_bin_path) and os.access(cargo_bin_path, os.X_OK):
-            return
-        print('%s not found, installing via cargo install.' % crate_name)
+    def ensure_rust_package(self, crate_name, min_version):
         cargo = self.which('cargo')
         if not cargo:
             cargo = os.path.join(cargo_bin, 'cargo')
-        subprocess.check_call([cargo, 'install', crate_name])
+
+        list = subprocess.check_output([cargo, 'install', '--list'])
+        target = crate_name + ' v'
+        for line in list.splitlines():
+            if line.startswith(target):
+                version = line[len(target):-1]
+                if LooseVersion(version) >= LooseVersion(min_version):
+                    return
+                print('old version of {name} ({version}) found'.format(
+                    name=crate_name, version=version))
+                break
+        else:
+            print('{name} not found'.format(name=crate_name))
+
+        print('installing via cargo install.'.format(
+            name=crate_name))
+        subprocess.check_call([cargo, 'install', '--force', crate_name])
 
     def install_toolchain_artifact(self, state_dir, checkout_root, toolchain_job):
         mach_binary = os.path.join(checkout_root, 'mach')
         mach_binary = os.path.abspath(mach_binary)
         if not os.path.exists(mach_binary):
             raise ValueError("mach not found at %s" % mach_binary)
 
         # If Python can't figure out what its own executable is, there's little
--- a/python/mozboot/mozboot/osx.py
+++ b/python/mozboot/mozboot/osx.py
@@ -498,18 +498,19 @@ class OSXBootstrapper(BaseBootstrapper):
             for check in ('/bin', '/usr/bin'):
                 if path == check:
                     print(BAD_PATH_ORDER % (check, p_dir, p_dir, check, p_dir))
                     sys.exit(1)
 
         return active_name.lower()
 
     def ensure_stylo_packages(self, state_dir, checkout_root):
+        cbindgen_min_version = '0.6.4'
         # We installed clang via homebrew earlier.
-        self.ensure_rust_package('cbindgen')
+        self.ensure_rust_package('cbindgen', cbindgen_min_version)
 
     def ensure_node_packages(self, state_dir, checkout_root):
         # XXX from necessary?
         from mozboot import node
         self.install_toolchain_artifact(state_dir, checkout_root, node.OSX)
 
     def install_homebrew(self):
         print(PACKAGE_MANAGER_INSTALL % ('Homebrew', 'Homebrew', 'Homebrew', 'brew'))
--- a/taskcluster/scripts/misc/build-cbindgen.sh
+++ b/taskcluster/scripts/misc/build-cbindgen.sh
@@ -1,13 +1,13 @@
 #!/bin/bash
 set -x -e -v
 
-# If you update this, make sure to update the minimum version in rust.configure
-# as well.
+# If you update this, make sure to update the minimum version in
+# build/moz.configure/rust.configure and python/mozboot/mozboot/osx.py as well.
 CBINDGEN_VERSION=v0.6.4
 TARGET="$1"
 
 case "$(uname -s)" in
 Linux)
     WORKSPACE=$HOME/workspace
     UPLOAD_DIR=$HOME/artifacts
     COMPRESS_EXT=xz