aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesonbuild/coredata.py4
-rw-r--r--mesonbuild/environment.py10
-rwxr-xr-xrun_unittests.py14
3 files changed, 15 insertions, 13 deletions
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
diff --git a/run_unittests.py b/run_unittests.py
index 539ecd3..18e0f36 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -8373,7 +8373,7 @@ class NativeFileTests(BasePlatformTests):
else:
self.fail('Did not find werror in build options?')
- def test_builtin_options_env_overrides_conf(self):
+ def test_builtin_options_conf_overrides_env(self):
testcase = os.path.join(self.common_test_dir, '2 cpp')
config = self.helper_create_native_file({'built-in options': {'pkg_config_path': '/foo'}})
@@ -8381,7 +8381,7 @@ class NativeFileTests(BasePlatformTests):
configuration = self.introspect('--buildoptions')
for each in configuration:
if each['name'] == 'pkg_config_path':
- self.assertEqual(each['value'], ['/bar'])
+ self.assertEqual(each['value'], ['/foo'])
break
else:
self.fail('Did not find pkg_config_path in build options?')
@@ -8786,10 +8786,10 @@ class CrossFileTests(BasePlatformTests):
break
self.assertEqual(found, 4, 'Did not find all sections.')
- def test_builtin_options_env_overrides_conf(self):
+ def test_builtin_options_conf_overrides_env(self):
testcase = os.path.join(self.common_test_dir, '2 cpp')
- config = self.helper_create_cross_file({'built-in options': {'pkg_config_path': '/foo'}})
- cross = self.helper_create_cross_file({'built-in options': {'pkg_config_path': '/foo'}})
+ config = self.helper_create_cross_file({'built-in options': {'pkg_config_path': '/native'}})
+ cross = self.helper_create_cross_file({'built-in options': {'pkg_config_path': '/cross'}})
self.init(testcase, extra_args=['--native-file', config, '--cross-file', cross],
override_envvars={'PKG_CONFIG_PATH': '/bar', 'PKG_CONFIG_PATH_FOR_BUILD': '/dir'})
@@ -8797,10 +8797,10 @@ class CrossFileTests(BasePlatformTests):
found = 0
for each in configuration:
if each['name'] == 'pkg_config_path':
- self.assertEqual(each['value'], ['/bar'])
+ self.assertEqual(each['value'], ['/cross'])
found += 1
elif each['name'] == 'build.pkg_config_path':
- self.assertEqual(each['value'], ['/dir'])
+ self.assertEqual(each['value'], ['/native'])
found += 1
if found == 2:
break