Bug 1257448 - Don't emit an error on unknown implied options when their resolved value is None draft
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 15 Apr 2016 06:43:35 +0900
changeset 351706 45391b60ffa539c14f82400a3a54af1e98220b7c
parent 351705 c7b6bb8ea5987b142cd7734e3391bf07e626338c
child 518485 2d59a8765fad18bb8bad153d03fc180c1ac8d3b5
push id15511
push userbmo:mh+mozilla@glandium.org
push dateThu, 14 Apr 2016 21:56:32 +0000
bugs1257448
milestone48.0a1
Bug 1257448 - Don't emit an error on unknown implied options when their resolved value is None imply_option has no effect when the resolved value is None, so the same logic can be applied when checking for unknown implied options. This allows to imply options that may not always exist (because they are in a configure file that is optionally included). Ideally, it would be better not to do this, but until we have something better than optionally included configure files for --disable-compile-environment, this is a necessary evil.
build/moz.configure/no-toolchain.configure
moz.configure
python/mozbuild/mozbuild/configure/__init__.py
deleted file mode 100644
--- a/build/moz.configure/no-toolchain.configure
+++ /dev/null
@@ -1,20 +0,0 @@
-# -*- Mode: python; c-basic-offset: 4; 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/.
-
-@depends('--help')
-def no_toolchain_compiler(_):
-    return namespace(
-        wrapper=(),
-        compiler='',
-        flags=(),
-        type='',
-        version='',
-    )
-
-c_compiler = no_toolchain_compiler
-cxx_compiler = no_toolchain_compiler
-host_c_compiler = no_toolchain_compiler
-host_cxx_compiler = no_toolchain_compiler
--- a/moz.configure
+++ b/moz.configure
@@ -52,22 +52,25 @@ def compile_environment(value):
 
 set_config('COMPILE_ENVIRONMENT', compile_environment)
 add_old_configure_assignment('COMPILE_ENVIRONMENT', compile_environment)
 
 @depends('--disable-compile-environment', '--help')
 def toolchain_include(value, help):
     if value:
         return 'build/moz.configure/toolchain.configure'
-    else:
-        return 'build/moz.configure/no-toolchain.configure'
 
 include(toolchain_include)
 
-include('build/moz.configure/memory.configure')
+@depends('--disable-compile-environment', '--help')
+def memory_include(value, help):
+    if value:
+        return 'build/moz.configure/memory.configure'
+
+include(memory_include)
 
 
 @depends('--help')
 @imports(_from='mozbuild.backend', _import='backends')
 def build_backends_choices(help):
     return tuple(backends)
 
 
--- a/python/mozbuild/mozbuild/configure/__init__.py
+++ b/python/mozbuild/mozbuild/configure/__init__.py
@@ -216,20 +216,23 @@ class ConfigureSandbox(dict):
                     'Option `%s` is not handled ; reference it with a @depends'
                     % option.option
                 )
 
             self._value_for(option)
 
         # All implied options should exist.
         for implied_option in self._implied_options:
-            raise ConfigureError(
-                '`%s`, emitted from `%s` line %d, is unknown.'
-                % (implied_option.option, implied_option.caller[1],
-                   implied_option.caller[2]))
+            value = self._resolve(implied_option.value,
+                                  need_help_dependency=False)
+            if value is not None:
+                raise ConfigureError(
+                    '`%s`, emitted from `%s` line %d, is unknown.'
+                    % (implied_option.option, implied_option.caller[1],
+                       implied_option.caller[2]))
 
         # All options should have been removed (handled) by now.
         for arg in self._helper:
             without_value = arg.split('=', 1)[0]
             raise InvalidOptionError('Unknown option: %s' % without_value)
 
         # Run the execution queue
         for func, args in self._execution_queue: