Bug 1471425 - Require rustc 1.28 in configure when building with Tup. draft
authorChris Manchester <cmanchester@mozilla.com>
Tue, 26 Jun 2018 20:32:16 -0700
changeset 811163 b7accec9d206a6150ff7400f9c229e000856d043
parent 811162 53398269672a901ce66ea920c91dd2bd46c4e495
push id114215
push userbmo:cmanchester@mozilla.com
push dateWed, 27 Jun 2018 03:32:43 +0000
bugs1471425
milestone63.0a1
Bug 1471425 - Require rustc 1.28 in configure when building with Tup. MozReview-Commit-ID: 9FCs5FPcchC
build/moz.configure/tup.configure
moz.configure
new file mode 100644
--- /dev/null
+++ b/build/moz.configure/tup.configure
@@ -0,0 +1,65 @@
+# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+# tup detection
+# ==============================================================
+
+tup = check_prog('TUP', ['tup'])
+
+@depends(tup)
+@checking('for tup version')
+@imports('re')
+def tup_version(tup):
+    tup_min_version = '0.7.6'
+    out = check_cmd_output(tup, '--version',
+                           onerror=lambda: die('Failed to get tup version'))
+    m = re.search(r'tup v?([0-9]+\.[0-9]+\.[0-9]+)', out)
+
+    if not m:
+        raise FatalCheckError('Unknown version of tup: %s' % out)
+    ver = Version(m.group(1))
+
+    if ver < tup_min_version:
+        raise FatalCheckError('To use the tup backend you must have tup version '
+                              '%s or greater in your path' % tup_min_version)
+    return ver
+
+@depends(tup)
+@checking('for tup ldpreload dependency checker')
+def tup_is_ldpreload(tup):
+    out = check_cmd_output(tup, 'server',
+                           onerror=lambda: die('Failed to get tup dependency checker'))
+    if out.rstrip() != 'ldpreload':
+        raise FatalCheckError('To use the tup backend, please use a version '
+                              'of tup compiled with the ldpreload dependency '
+                              'checker. Either compile tup locally with '
+                              'CONFIG_TUP_SERVER=ldpreload in your tup.config '
+                              'file, or use the version from the toolchain '
+                              'task via |./mach artifact toolchain '
+                              '--from-build linux64-tup|')
+    return True
+
+@depends(tup, using_sccache)
+def tup_and_sccache(tup, using_sccache):
+    if tup and using_sccache:
+        die('Cannot use sccache with tup yet. Please disable sccache or use '
+            'the make backend until it is supported.')
+
+@depends(tup, rustc_info)
+def check_tup_min_rustc_version(tup, rustc_info):
+    min_rustc_version = Version('1.28.0')
+    if tup and rustc_info.version < min_rustc_version:
+        die('Cannot build with tup and rustc %s. please update to at least '
+            'rustc %s to continue.', rustc_info.version, min_rustc_version)
+
+option('--upload-tup-db', help= 'Upload the tup database from an automated build.')
+
+@depends('--upload-tup-db')
+def upload_tdb(value):
+    if value:
+        return True
+
+set_config('UPLOAD_TUP_DB', upload_tdb)
--- a/moz.configure
+++ b/moz.configure
@@ -387,74 +387,30 @@ def possible_makes(make, host):
     if host.kernel == 'WINNT':
         candidates.extend(('make', 'gmake'))
     else:
         candidates.extend(('gmake', 'make'))
     return candidates
 
 check_prog('GMAKE', possible_makes)
 
-# tup detection
-# ==============================================================
-@depends(build_backends)
-def tup_progs(build_backends):
+@depends(build_backends, build_project)
+def tup_include(build_backends, build_project):
+    # We need to check the rustc version when building with tup, but
+    # rustc_info isn't available when configuring js (and build_backends isn't
+    # available from project-specific configure), so as a workaround we only
+    # include the file when we know we'll need it. This can be removed when
+    # we globally require a rustc recent enough to build with tup.
+    if build_project not in ('browser', 'mobile/android'):
+        return None
     for backend in build_backends:
         if 'Tup' in backend:
-            return ['tup']
-    return None
-
-tup = check_prog('TUP', tup_progs)
-
-@depends_if(tup)
-@checking('for tup version')
-@imports('re')
-def tup_version(tup):
-    tup_min_version = '0.7.6'
-    out = check_cmd_output(tup, '--version',
-                           onerror=lambda: die('Failed to get tup version'))
-    m = re.search(r'tup v?([0-9]+\.[0-9]+\.[0-9]+)', out)
-
-    if not m:
-        raise FatalCheckError('Unknown version of tup: %s' % out)
-    ver = Version(m.group(1))
-
-    if ver < tup_min_version:
-        raise FatalCheckError('To use the tup backend you must have tup version '
-                              '%s or greater in your path' % tup_min_version)
-    return ver
+            return 'build/moz.configure/tup.configure'
 
-@depends_if(tup)
-@checking('for tup ldpreload dependency checker')
-def tup_is_ldpreload(tup):
-    out = check_cmd_output(tup, 'server',
-                           onerror=lambda: die('Failed to get tup dependency checker'))
-    if out.rstrip() != 'ldpreload':
-        raise FatalCheckError('To use the tup backend, please use a version '
-                              'of tup compiled with the ldpreload dependency '
-                              'checker. Either compile tup locally with '
-                              'CONFIG_TUP_SERVER=ldpreload in your tup.config '
-                              'file, or use the version from the toolchain '
-                              'task via |./mach artifact toolchain '
-                              '--from-build linux64-tup|')
-    return True
-
-@depends_if(tup, using_sccache)
-def tup_and_sccache(tup, using_sccache):
-    if tup and using_sccache:
-        die('Cannot use sccache with tup yet. Please disable sccache or use '
-            'the make backend until it is supported.')
-
-option('--upload-tup-db', help= 'Upload the tup database from an automated build.')
-
-@depends('--upload-tup-db')
-def upload_tdb(value):
-    if value:
-        return True
-
-set_config('UPLOAD_TUP_DB', upload_tdb)
+include(tup_include)
 
 # watchman detection
 # ==============================================================
 
 option(env='WATCHMAN', nargs=1, help='Path to the watchman program')
 
 @depends('WATCHMAN')
 @checking('for watchman', callback=lambda w: w.path if w else 'not found')