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.
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: