aboutsummaryrefslogtreecommitdiff
path: root/run_unittests.py
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2020-06-11 16:04:50 -0400
committerJussi Pakkanen <jpakkane@gmail.com>2020-06-29 20:16:21 +0300
commit1c8731a10018e8ba1e6b30411a290ca50fa45d81 (patch)
tree9c5332199c2acd2f26bb131429e1251b76cd7dfa /run_unittests.py
parent5696a5abbaaff75279d9c50d431de47f35dc6228 (diff)
downloadmeson-1c8731a10018e8ba1e6b30411a290ca50fa45d81.zip
meson-1c8731a10018e8ba1e6b30411a290ca50fa45d81.tar.gz
meson-1c8731a10018e8ba1e6b30411a290ca50fa45d81.tar.bz2
envconfig: Add [constants] section in machine files
Machine files already supports `+` operator as an implementation detail, since it's using eval(). Now make it an officially supported feature and add a way to define constants that are used while evaluating an entry value.
Diffstat (limited to 'run_unittests.py')
-rwxr-xr-xrun_unittests.py34
1 files changed, 32 insertions, 2 deletions
diff --git a/run_unittests.py b/run_unittests.py
index 8a12180..6cc6302 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -3915,7 +3915,7 @@ recommended as it is not supported on some platforms''')
with tempfile.NamedTemporaryFile(mode='w', delete=False) as crossfile:
crossfile.write(textwrap.dedent(
'''[binaries]
- pkgconfig = r'{0}'
+ pkgconfig = '{0}'
[properties]
@@ -3945,7 +3945,7 @@ recommended as it is not supported on some platforms''')
pkgconfig = 'pkg-config'
[properties]
- pkg_config_libdir = [r'{0}']
+ pkg_config_libdir = ['{0}']
[host_machine]
system = 'linux'
@@ -4969,6 +4969,36 @@ recommended as it is not supported on some platforms''')
self.run_tests()
self.run_target('coverage-xml')
+ def test_cross_file_constants(self):
+ with temp_filename() as crossfile1, temp_filename() as crossfile2:
+ with open(crossfile1, 'w') as f:
+ f.write(textwrap.dedent(
+ '''
+ [constants]
+ compiler = 'gcc'
+ '''))
+ with open(crossfile2, 'w') as f:
+ f.write(textwrap.dedent(
+ '''
+ [constants]
+ toolchain = '/toolchain/'
+ common_flags = ['--sysroot=' + toolchain / 'sysroot']
+
+ [properties]
+ c_args = common_flags + ['-DSOMETHING']
+ cpp_args = c_args + ['-DSOMETHING_ELSE']
+
+ [binaries]
+ c = toolchain / compiler
+ '''))
+
+ values = mesonbuild.coredata.parse_machine_files([crossfile1, crossfile2])
+ self.assertEqual(values['binaries']['c'], '/toolchain/gcc')
+ self.assertEqual(values['properties']['c_args'],
+ ['--sysroot=/toolchain/sysroot', '-DSOMETHING'])
+ self.assertEqual(values['properties']['cpp_args'],
+ ['--sysroot=/toolchain/sysroot', '-DSOMETHING', '-DSOMETHING_ELSE'])
+
class FailureTests(BasePlatformTests):
'''
Tests that test failure conditions. Build files here should be dynamically