diff options
Diffstat (limited to 'mesonbuild')
-rw-r--r-- | mesonbuild/coredata.py | 10 | ||||
-rw-r--r-- | mesonbuild/environment.py | 19 |
2 files changed, 28 insertions, 1 deletions
diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py index e2a6954..49104a7 100644 --- a/mesonbuild/coredata.py +++ b/mesonbuild/coredata.py @@ -377,6 +377,7 @@ class CoreData: host_cache = DependencyCache(self.builtins_per_machine, MachineChoice.BUILD) self.deps = PerMachine(build_cache, host_cache) # type: PerMachine[DependencyCache] self.compiler_check_cache = OrderedDict() + # Only to print a warning if it changes between Meson invocations. self.config_files = self.__load_config_files(options, scratch_dir, 'native') self.builtin_options_libdir_cross_fixup() @@ -734,7 +735,7 @@ class CoreData: if not self.is_cross_build(): self.copy_build_options_from_regular_ones() - def set_default_options(self, default_options, subproject, env): + def set_default_options(self, default_options: T.Mapping[str, str], subproject: str, env: 'Environment') -> None: # Warn if the user is using two different ways of setting build-type # options that override each other if 'buildtype' in env.cmd_line_options and \ @@ -755,6 +756,13 @@ class CoreData: k = subproject + ':' + k cmd_line_options[k] = v + # load the values for user options out of the appropriate machine file, + # then overload the command line + for k, v in env.user_options.get(subproject, {}).items(): + if subproject: + k = '{}:{}'.format(subproject, k) + cmd_line_options[k] = v + # Override project default_options using conf files (cross or native) for k, v in env.paths.host: if v is not None: diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index a82c8f8..c872aee 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -553,6 +553,9 @@ class Environment: # architecture, just the build and host architectures paths = PerMachineDefaultable() + # We only need one of these as project options are not per machine + user_options = {} + ## Setup build machine defaults # Will be fully initialized later using compilers later. @@ -565,12 +568,26 @@ class Environment: ## Read in native file(s) to override build machine configuration + def load_user_options(): + for section in config.keys(): + if section.endswith('project options'): + if ':' in section: + project = section.split(':')[0] + else: + project = '' + user_options[project] = config.get(section, {}) + if self.coredata.config_files is not None: config = coredata.parse_machine_files(self.coredata.config_files) binaries.build = BinaryTable(config.get('binaries', {})) paths.build = Directories(**config.get('paths', {})) properties.build = Properties(config.get('properties', {})) + # Don't run this if there are any cross files, we don't want to use + # the native values if we're doing a cross build + if not self.coredata.cross_files: + load_user_options() + ## Read in cross file(s) to override host machine configuration if self.coredata.cross_files: @@ -582,6 +599,7 @@ class Environment: if 'target_machine' in config: machines.target = MachineInfo.from_literal(config['target_machine']) paths.host = Directories(**config.get('paths', {})) + load_user_options() ## "freeze" now initialized configuration, and "save" to the class. @@ -589,6 +607,7 @@ class Environment: self.binaries = binaries.default_missing() self.properties = properties.default_missing() self.paths = paths.default_missing() + self.user_options = user_options exe_wrapper = self.lookup_binary_entry(MachineChoice.HOST, 'exe_wrapper') if exe_wrapper is not None: |