diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2019-07-17 22:54:58 +0300 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2019-08-06 21:34:15 +0300 |
commit | 5fd4963766fe53d4a6db24a2cb7cb54e21600fe9 (patch) | |
tree | 08c48cdf5927bfdf12d3a00a07135a2a9ad44b07 | |
parent | 534c95cc3eae86bb8e08bee5f5162ca65bc53461 (diff) | |
download | meson-5fd4963766fe53d4a6db24a2cb7cb54e21600fe9.zip meson-5fd4963766fe53d4a6db24a2cb7cb54e21600fe9.tar.gz meson-5fd4963766fe53d4a6db24a2cb7cb54e21600fe9.tar.bz2 |
Made build. options alias basic ones when native building.
-rw-r--r-- | mesonbuild/coredata.py | 23 | ||||
-rw-r--r-- | mesonbuild/interpreter.py | 2 | ||||
-rwxr-xr-x | run_unittests.py | 28 | ||||
-rw-r--r-- | test cases/unit/51 noncross options/meson.build | 14 | ||||
-rw-r--r-- | test cases/unit/51 noncross options/prog.c (renamed from test cases/unit/51 std remains/prog.c) | 0 | ||||
-rw-r--r-- | test cases/unit/51 noncross options/ylib.pc | 13 | ||||
-rw-r--r-- | test cases/unit/51 std remains/meson.build | 2 |
7 files changed, 68 insertions, 14 deletions
diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py index 2d3d5ab..48aeda8 100644 --- a/mesonbuild/coredata.py +++ b/mesonbuild/coredata.py @@ -635,7 +635,28 @@ class CoreData: if type(oldval) != type(value): self.user_options[name] = value + def is_cross_build(self): + return len(self.cross_files) > 0 + + def strip_build_option_names(self, options): + res = {} + for k, v in options.items(): + if k.startswith('build.'): + k = k.split('.', 1)[1] + res[k] = v + return res + + def copy_build_options_from_regular_ones(self): + assert(not self.is_cross_build()) + for k, o in self.builtins_per_machine.host.items(): + self.builtins_per_machine.build[k].set_value(o.value) + for k, o in self.compiler_options.host.items(): + if k in self.compiler_options.build: + self.compiler_options.build[k].set_value(o.value) + def set_options(self, options, *, subproject='', warn_unknown=True): + if not self.is_cross_build(): + options = self.strip_build_option_names(options) # Set prefix first because it's needed to sanitize other options prefix = self.builtins['prefix'].value if 'prefix' in options: @@ -663,6 +684,8 @@ class CoreData: unknown_options = ', '.join(sorted(unknown_options)) sub = 'In subproject {}: '.format(subproject) if subproject else '' mlog.warning('{}Unknown options: "{}"'.format(sub, unknown_options)) + if not self.is_cross_build(): + self.copy_build_options_from_regular_ones() def set_default_options(self, default_options, subproject, env): # Set defaults first from conf files (cross or native), then diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 03bbcc1..c6ad815 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -2795,6 +2795,8 @@ external dependencies (including libraries) must go to "dependencies".''') def add_languages(self, args: Sequence[str], required: bool) -> bool: success = self.add_languages_for(args, required, MachineChoice.BUILD) success &= self.add_languages_for(args, required, MachineChoice.HOST) + if not self.coredata.is_cross_build(): + self.coredata.copy_build_options_from_regular_ones() return success def add_languages_for(self, args, required, for_machine: MachineChoice): diff --git a/run_unittests.py b/run_unittests.py index 8212c46..735f3e2 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -3717,6 +3717,8 @@ recommended as it is not supported on some platforms''') for idx, i in enumerate(res1): if i['name'] == 'cpp_std': res1[idx]['value'] = 'c++14' + if i['name'] == 'build.cpp_std': + res1[idx]['value'] = 'c++14' if i['name'] == 'buildtype': res1[idx]['value'] = 'release' if i['name'] == 'optimization': @@ -5380,20 +5382,14 @@ endian = 'little' # Assert that self.assertEqual(len(line.split(lib)), 2, msg=(lib, line)) - @skipIfNoPkgconfig - def test_pkg_config_option(self): - testdir = os.path.join(self.unit_test_dir, '58 pkg_config_path option') - self.init(testdir, extra_args=[ - '-Dbuild.pkg_config_path=' + os.path.join(testdir, 'build_extra_path'), - '-Dpkg_config_path=' + os.path.join(testdir, 'host_extra_path'), - ]) - - def test_std_remains(self): + def test_noncross_options(self): # C_std defined in project options must be in effect also when native compiling. - testdir = os.path.join(self.unit_test_dir, '51 std remains') - self.init(testdir) + testdir = os.path.join(self.unit_test_dir, '51 noncross options') + self.init(testdir, extra_args=['-Dpkg_config_path=' + testdir]) compdb = self.get_compdb() + self.assertEqual(len(compdb), 2) self.assertRegex(compdb[0]['command'], '-std=c99') + self.assertRegex(compdb[1]['command'], '-std=c99') self.build() def test_identity_cross(self): @@ -5461,12 +5457,20 @@ class LinuxCrossArmTests(BasePlatformTests): def test_std_remains(self): # C_std defined in project options must be in effect also when cross compiling. - testdir = os.path.join(self.unit_test_dir, '51 std remains') + testdir = os.path.join(self.unit_test_dir, '51 noncross options') self.init(testdir) compdb = self.get_compdb() self.assertRegex(compdb[0]['command'], '-std=c99') self.build() + @skipIfNoPkgconfig + def test_pkg_config_option(self): + testdir = os.path.join(self.unit_test_dir, '58 pkg_config_path option') + self.init(testdir, extra_args=[ + '-Dbuild.pkg_config_path=' + os.path.join(testdir, 'build_extra_path'), + '-Dpkg_config_path=' + os.path.join(testdir, 'host_extra_path'), + ]) + def should_run_cross_mingw_tests(): return shutil.which('x86_64-w64-mingw32-gcc') and not (is_windows() or is_cygwin()) diff --git a/test cases/unit/51 noncross options/meson.build b/test cases/unit/51 noncross options/meson.build new file mode 100644 index 0000000..42e2cbb --- /dev/null +++ b/test cases/unit/51 noncross options/meson.build @@ -0,0 +1,14 @@ +project('std_remains', 'c', default_options: ['c_std=c99']) + +executable('prog', 'prog.c') + +# Check that native: true does not affect the use of c_std in +# non-cross builds + +if not meson.is_cross_build() + executable('prog2', 'prog.c', native: true) + + # Check that even deps marked as native are found + # by default when not cross compiling. + dependency('ylib', method: 'pkg-config') +endif diff --git a/test cases/unit/51 std remains/prog.c b/test cases/unit/51 noncross options/prog.c index 0314ff1..0314ff1 100644 --- a/test cases/unit/51 std remains/prog.c +++ b/test cases/unit/51 noncross options/prog.c diff --git a/test cases/unit/51 noncross options/ylib.pc b/test cases/unit/51 noncross options/ylib.pc new file mode 100644 index 0000000..afec2d3 --- /dev/null +++ b/test cases/unit/51 noncross options/ylib.pc @@ -0,0 +1,13 @@ +prefix=/usr +exec_prefix=${prefix} +libdir=${prefix}/lib/x86_64-linux-gnu +sharedlibdir=${libdir} +includedir=${prefix}/include + +Name: ylib +Description: ylib compression library +Version: 1.2.3 + +Requires: +Libs: -L${libdir} -L${sharedlibdir} -ly +Cflags: -I${includedir} diff --git a/test cases/unit/51 std remains/meson.build b/test cases/unit/51 std remains/meson.build deleted file mode 100644 index ac6f9e2..0000000 --- a/test cases/unit/51 std remains/meson.build +++ /dev/null @@ -1,2 +0,0 @@ -project('std_remains', 'c', default_options: ['c_std=c99']) -executable('prog', 'prog.c') |