diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2021-04-05 10:17:51 -0700 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2021-04-06 16:09:13 -0700 |
commit | fdde948ca1521f03d9495f3fec862063862af2b4 (patch) | |
tree | 7fd7b32bd8dca5eaa5235cda0437a8286958c2f2 | |
parent | 111070bf4971d7e404fa642d03be27429e76dce9 (diff) | |
download | meson-fdde948ca1521f03d9495f3fec862063862af2b4.zip meson-fdde948ca1521f03d9495f3fec862063862af2b4.tar.gz meson-fdde948ca1521f03d9495f3fec862063862af2b4.tar.bz2 |
environment: don't load project options from a native file in a cross build
-rw-r--r-- | mesonbuild/environment.py | 4 | ||||
-rwxr-xr-x | run_unittests.py | 18 |
2 files changed, 20 insertions, 2 deletions
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index a38ac5d..7c9e1ff 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -786,7 +786,9 @@ class Environment: if key.subproject: raise MesonException('Do not set subproject options in [built-in options] section, use [subproject:built-in options] instead.') self.options[key.evolve(subproject=subproject, machine=machine)] = v - elif section == 'project options': + elif section == 'project options' and machine is MachineChoice.HOST: + # Project options are only for the host machine, we don't want + # to read these from the native file for k, v in values.items(): # Project options are always for the host machine key = OptionKey.from_string(k) diff --git a/run_unittests.py b/run_unittests.py index dbb37df..e9711db 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -9202,7 +9202,7 @@ class CrossFileTests(BasePlatformTests): for section, entries in values.items(): f.write(f'[{section}]\n') for k, v in entries.items(): - f.write(f"{k}='{v}'\n") + f.write(f"{k}={v!r}\n") return filename def test_cross_file_dirs(self): @@ -9368,6 +9368,22 @@ class CrossFileTests(BasePlatformTests): break self.assertEqual(found, 2, 'Did not find all sections.') + def test_project_options_native_only(self) -> None: + # Do not load project options from a native file when doing a cross + # build + testcase = os.path.join(self.unit_test_dir, '19 array option') + config = self.helper_create_cross_file({'project options': {'list': ['bar', 'foo']}}) + cross = self.helper_create_cross_file({'binaries': {}}) + + self.init(testcase, extra_args=['--native-file', config, '--cross-file', cross]) + configuration = self.introspect('--buildoptions') + for each in configuration: + if each['name'] == 'list': + self.assertEqual(each['value'], ['foo', 'bar']) + break + else: + self.fail('Did not find expected option.') + class TAPParserTests(unittest.TestCase): def assert_test(self, events, **kwargs): |