From 7271b1e9423a83c56bf6e011b4f06dc6831a6d71 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Sun, 9 Aug 2020 08:45:34 -0400 Subject: Machine file pkg_config_path overrides environment This is consistent with c_args in machine file overriding CFLAGS from env. This also spotted an issue where in a native build this resulted in pkg_config_path being /bar instead of /foo: `-Dpkg_config_path=/foo -Dbuild.pkg_config_path=/bar` Fixes: #7573 --- mesonbuild/coredata.py | 4 +++- mesonbuild/environment.py | 10 +++++----- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'mesonbuild') diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py index 9ed939b..d5d90f9 100644 --- a/mesonbuild/coredata.py +++ b/mesonbuild/coredata.py @@ -735,7 +735,9 @@ class CoreData: for k, v in options.items(): if k.startswith('build.'): k = k.split('.', 1)[1] - res[k] = v + res.setdefault(k, v) + else: + res[k] = v return res def copy_build_options_from_regular_ones(self): diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index e63e9bf..e3ea956 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -629,12 +629,12 @@ class Environment: self.properties = properties.default_missing() self.cmakevars = cmakevars.default_missing() - # Environment options override those from cross/native files - self.set_options_from_env() - # Command line options override those from cross/native files self.raw_options.update(options.cmd_line_options) + # Take default value from env if not set in cross/native files or command line. + self.set_default_options_from_env() + # Warn if the user is using two different ways of setting build-type # options that override each other if 'buildtype' in self.raw_options and \ @@ -727,7 +727,7 @@ class Environment: per_machine_options[build_optname] = value self.raw_options = per_machine_options - def set_options_from_env(self): + def set_default_options_from_env(self): for for_machine in MachineChoice: p_env_pair = get_env_var_pair(for_machine, self.is_cross_build(), 'PKG_CONFIG_PATH') if p_env_pair is not None: @@ -746,7 +746,7 @@ class Environment: # FIXME: We should remember if we took the value from env to warn # if it changes on future invocations. if self.first_invocation: - self.raw_options[key] = p_list + self.raw_options.setdefault(key, p_list) def create_new_coredata(self, options: 'argparse.Namespace') -> None: # WARNING: Don't use any values from coredata in __init__. It gets -- cgit v1.1