Bug 1322025 - Provide variants of host and target that depend on --help. r=chmanchester draft
authorMike Hommey <mh+mozilla@glandium.org>
Wed, 25 Jan 2017 17:54:16 +0900
changeset 467005 84047cec9dbe36ee92d5394dde6d849b2146e4e4
parent 467004 8a5f8d07a994e4af834f96bcb8d1da9cbc15ed4c
child 543600 b2b5f31fa04a5948d2ea236cca26bb07b4d86c50
push id43083
push userbmo:mh+mozilla@glandium.org
push dateFri, 27 Jan 2017 00:32:10 +0000
reviewerschmanchester
bugs1322025, 1313306
milestone54.0a1
Bug 1322025 - Provide variants of host and target that depend on --help. r=chmanchester We want to avoid giving --help dependencies to host and target, so that they we don't spawn config.guess and config.sub when running configure --help, and don't need to reach out to the which module to find a suitable shell to execute them. So, when --help is given, we return a fake host/target namespace, and avoid the config.guess/config.sub-invoking code being executed. Then, by giving the --help option to the linter, it can properly find that the config.guess/config.sub-invoking code doesn't need the dependency on --help. This effectively unbreaks configure --help after bug 1313306.
build/moz.configure/init.configure
python/mozbuild/mozbuild/configure/__init__.py
python/mozbuild/mozbuild/test/configure/lint.py
--- a/build/moz.configure/init.configure
+++ b/build/moz.configure/init.configure
@@ -412,16 +412,33 @@ def split_triplet(triplet):
         raw_cpu=cpu,
         raw_os=os,
         # Toolchains, most notably for cross compilation may use cpu-os
         # prefixes.
         toolchain='%s-%s' % (cpu, os),
     )
 
 
+# This defines a fake target/host namespace for when running with --help
+@depends('--help')
+def help_host_target(help):
+    if help:
+        return namespace(
+            alias='unknown-unknown-unknown',
+            cpu='unknown',
+            bitness='unknown',
+            kernel='unknown',
+            os='unknown',
+            endianness='unknown',
+            raw_cpu='unknown',
+            raw_os='unknown',
+            toolchain='unknown-unknown',
+        )
+
+
 @imports('subprocess')
 def config_sub(shell, triplet):
     config_sub = os.path.join(os.path.dirname(__file__), '..',
                               'autoconf', 'config.sub')
     return subprocess.check_output([shell, config_sub, triplet]).strip()
 
 
 @depends('--host', shell)
@@ -432,24 +449,28 @@ def host(value, shell):
         config_guess = os.path.join(os.path.dirname(__file__), '..',
                                     'autoconf', 'config.guess')
         host = subprocess.check_output([shell, config_guess]).strip()
     else:
         host = value[0]
 
     return split_triplet(config_sub(shell, host))
 
+host = help_host_target | host
+
 
 @depends('--target', host, shell)
 @checking('for target system type', lambda t: t.alias)
 def target(value, host, shell):
     if not value:
         return host
     return split_triplet(config_sub(shell, value[0]))
 
+target = help_host_target | target
+
 
 @depends(host, target)
 @checking('whether cross compiling')
 def cross_compiling(host, target):
     return host != target
 
 set_config('CROSS_COMPILE', cross_compiling)
 set_define('CROSS_COMPILE', cross_compiling)
--- a/python/mozbuild/mozbuild/configure/__init__.py
+++ b/python/mozbuild/mozbuild/configure/__init__.py
@@ -143,18 +143,18 @@ class CombinedDependsFunction(DependsFun
             elif d not in flatten_deps:
                 flatten_deps.append(d)
 
         super(CombinedDependsFunction, self).__init__(
             sandbox, func, flatten_deps)
 
     @memoize
     def result(self, need_help_dependency=False):
-        resolved_args = [self.sandbox._value_for(d, need_help_dependency)
-                         for d in self.dependencies]
+        resolved_args = (self.sandbox._value_for(d, need_help_dependency)
+                         for d in self.dependencies)
         return self._func(resolved_args)
 
     def __eq__(self, other):
         return (isinstance(other, self.__class__) and
                 self._func is other._func and
                 set(self.dependencies) == set(other.dependencies))
 
     def __ne__(self, other):
--- a/python/mozbuild/mozbuild/test/configure/lint.py
+++ b/python/mozbuild/mozbuild/test/configure/lint.py
@@ -52,14 +52,14 @@ class Lint(unittest.TestCase):
     def tearDown(self):
         os.chdir(self._curdir)
 
     def lint(self, project):
         sandbox = LintSandbox({
             'OLD_CONFIGURE': os.path.join(topsrcdir, 'old-configure'),
             'MOZCONFIG': os.path.join(os.path.dirname(test_path), 'data',
                                       'empty_mozconfig'),
-        }, ['--enable-project=%s' % project])
+        }, ['--enable-project=%s' % project, '--help'])
         sandbox.run(os.path.join(topsrcdir, 'moz.configure'))
 
 
 if __name__ == '__main__':
     main()