Bug 1484473 - Add a cbindgen version check. r=firefox-build-system-reviewers,froydnj
authorEmilio Cobos Álvarez <emilio@crisal.io>
Mon, 20 Aug 2018 15:20:42 +0000
changeset 432364 f9ba9a7a94d2b444ee3d00b327c170efa5036e4b
parent 432363 f5e54bee352fe8f870891d83fac0e9e252770667
child 432365 e20c185652fe0f0eb6f2dad6ae682f03b8a2f4a1
push id34475
push userncsoregi@mozilla.com
push dateMon, 20 Aug 2018 21:59:24 +0000
treeherdermozilla-central@a13766399397 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfirefox-build-system-reviewers, froydnj
bugs1484473
milestone63.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 1484473 - Add a cbindgen version check. r=firefox-build-system-reviewers,froydnj Differential Revision: https://phabricator.services.mozilla.com/D3718
build/moz.configure/rust.configure
taskcluster/scripts/misc/build-cbindgen.sh
--- a/build/moz.configure/rust.configure
+++ b/build/moz.configure/rust.configure
@@ -284,16 +284,38 @@ def rust_tests(enable_rust_tests, rustdo
 
 set_config('MOZ_RUST_TESTS', rust_tests)
 
 # cbindgen is needed by the style system build.
 cbindgen = check_prog('CBINDGEN', add_rustup_path('cbindgen'), paths=toolchain_search_path,
                       when=depends(build_project)
                       (lambda build_project: build_project != 'js'))
 
+
+@depends_if(cbindgen)
+@checking('cbindgen version')
+@imports(_from='textwrap', _import='dedent')
+def cbindgen_version(cbindgen):
+    cbindgen_min_version = Version('0.6.1')
+
+    # cbindgen x.y.z
+    version = Version(check_cmd_output(cbindgen, '--version').strip().split(" ")[1])
+
+    if version < cbindgen_min_version:
+        die(dedent('''\
+        cbindgen version {} is too old. At least version {} is required.
+
+        Please update using 'cargo install cbindgen --force' or running
+        './mach bootstrap', after removing the existing executable located at
+        {}.
+        '''.format(version, cbindgen_min_version, cbindgen)))
+
+    return version
+
+
 # Bindgen can use rustfmt to format Rust file, but it's not required.
 js_option(env='RUSTFMT', nargs=1, help='Path to the rustfmt program')
 
 rustfmt = check_prog('RUSTFMT', add_rustup_path('rustfmt'),
                      input='RUSTFMT', allow_missing=True)
 
 js_option(env='WIN64_LINK', nargs=1, help='Path to link.exe that targets win64')
 js_option(env='WIN64_LIB', nargs=1, help='Paths to libraries for the win64 linker')
--- a/taskcluster/scripts/misc/build-cbindgen.sh
+++ b/taskcluster/scripts/misc/build-cbindgen.sh
@@ -1,11 +1,13 @@
 #!/bin/bash
 set -x -e -v
 
+# If you update this, make sure to update the minimum version in rust.configure
+# as well.
 CBINDGEN_VERSION=v0.6.1
 TARGET="$1"
 
 case "$(uname -s)" in
 Linux)
     WORKSPACE=$HOME/workspace
     UPLOAD_DIR=$HOME/artifacts
     COMPRESS_EXT=xz