Made build. options alias basic ones when native building.

pull/5777/head
Jussi Pakkanen 5 years ago
parent 534c95cc3e
commit 5fd4963766
  1. 23
      mesonbuild/coredata.py
  2. 2
      mesonbuild/interpreter.py
  3. 28
      run_unittests.py
  4. 14
      test cases/unit/51 noncross options/meson.build
  5. 0
      test cases/unit/51 noncross options/prog.c
  6. 13
      test cases/unit/51 noncross options/ylib.pc
  7. 2
      test cases/unit/51 std remains/meson.build

@ -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

@ -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):

@ -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())

@ -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

@ -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}

@ -1,2 +0,0 @@
project('std_remains', 'c', default_options: ['c_std=c99'])
executable('prog', 'prog.c')
Loading…
Cancel
Save