Properly error out when cross file is missing a compiler.

crossenvvar
Jussi Pakkanen 3 years ago
parent d082204096
commit f11c643a82
  1. 9
      cross/noexes.txt
  2. 13
      cross/ubuntu-faketarget.txt
  3. 5
      mesonbuild/compilers/detect.py
  4. 2
      test cases/common/10 man install/meson.build
  5. 2
      unittests/allplatformstests.py
  6. 8
      unittests/linuxcrosstests.py
  7. 9
      unittests/machinefiletests.py

@ -0,0 +1,9 @@
# A cross file that is missing compilers must lead to
# an error.
[binaries]
[target_machine]
system = 'linux'
cpu_family = 'mips'
cpu = 'mips'
endian = 'little'

@ -1,13 +0,0 @@
# This is a setup for compiling a program that runs natively
# but produces output that runs on a different platform.
# That is either a cross compiler or something like binutils.
# We don't need to specify any properties or compilers,
# for we use the native ones and can run the resulting
# binaries directly.
[target_machine]
system = 'linux'
cpu_family = 'mips'
cpu = 'mips'
endian = 'little'

@ -240,8 +240,9 @@ def _get_compilers(env: 'Environment', lang: str, for_machine: MachineChoice) ->
# Return value has to be a list of compiler 'choices'
compilers = [comp]
else:
if not env.machines.matches_build_machine(for_machine):
raise EnvironmentException(f'{lang!r} compiler binary not defined in cross or native file')
# Cross compilers must NEVER EVER be taken from envvars.
if env.is_cross_build() and for_machine == MachineChoice.HOST:
raise EnvironmentException(f'{lang!r} compiler binary not defined in a cross file')
compilers = [[x] for x in defaults[lang]]
ccache = BinaryTable.detect_compiler_cache()

@ -1,4 +1,4 @@
project('man install', 'c')
project('man install')
m1 = install_man('foo.1')
m2 = install_man('bar.2')
m3 = install_man('foo.fr.1', locale: 'fr')

@ -3597,6 +3597,8 @@ class AllPlatformTests(BasePlatformTests):
machinefile = os.path.join(self.builddir, 'machine.txt')
with open(machinefile, 'w', encoding='utf-8') as f:
f.write(textwrap.dedent('''
[binaries]
c = 'cc'
[properties]
c_stdlib = 'mylibc'
'''))

@ -125,6 +125,14 @@ class LinuxCrossArmTests(BaseLinuxCrossTests):
self.run_tests()
self.assertPathExists(stamp_file)
def test_missing_compilers(self):
'''
Requesting a compiler that is not in the cross file must be an error.
'''
testdir = os.path.join(self.common_test_dir, '1 trivial')
self.meson_cross_files = [os.path.join(self.src_root, 'cross', 'noexes.txt')]
with self.assertRaises(subprocess.CalledProcessError, msg='compiler binary not defined in a cross file'):
self.init(testdir)
def should_run_cross_mingw_tests():
return shutil.which('x86_64-w64-mingw32-gcc') and not (is_windows() or is_cygwin())

@ -740,7 +740,7 @@ class CrossFileTests(BasePlatformTests):
self.init(testdir, extra_args=['--cross-file=' + name], inprocess=True)
self.wipe()
def helper_create_cross_file(self, values):
def helper_create_cross_file(self, values, *, add_fake_compilers=True):
"""Create a config file as a temporary file.
values should be a nested dictionary structure of {section: {key:
@ -748,6 +748,13 @@ class CrossFileTests(BasePlatformTests):
"""
filename = os.path.join(self.builddir, f'generated{self.current_config}.config')
self.current_config += 1
if add_fake_compilers:
if is_windows() and shutil.which('cl'):
base = {'binaries': {'c': 'cl', 'cpp': 'cl'}}
else:
base = {'binaries': {'c': 'cc', 'cpp': 'c++'}}
base.update(values)
values = base
with open(filename, 'wt', encoding='utf-8') as f:
for section, entries in values.items():
f.write(f'[{section}]\n')

Loading…
Cancel
Save