diff options
-rw-r--r-- | cross/noexes.txt | 9 | ||||
-rw-r--r-- | cross/ubuntu-faketarget.txt | 13 | ||||
-rw-r--r-- | mesonbuild/compilers/detect.py | 5 | ||||
-rw-r--r-- | test cases/common/10 man install/meson.build | 2 | ||||
-rw-r--r-- | unittests/allplatformstests.py | 2 | ||||
-rw-r--r-- | unittests/linuxcrosstests.py | 8 | ||||
-rw-r--r-- | unittests/machinefiletests.py | 9 |
7 files changed, 31 insertions, 17 deletions
diff --git a/cross/noexes.txt b/cross/noexes.txt new file mode 100644 index 0000000..d211f17 --- /dev/null +++ b/cross/noexes.txt @@ -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' diff --git a/cross/ubuntu-faketarget.txt b/cross/ubuntu-faketarget.txt deleted file mode 100644 index cc43998..0000000 --- a/cross/ubuntu-faketarget.txt +++ /dev/null @@ -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' diff --git a/mesonbuild/compilers/detect.py b/mesonbuild/compilers/detect.py index 9216ecf..7e6d655 100644 --- a/mesonbuild/compilers/detect.py +++ b/mesonbuild/compilers/detect.py @@ -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() diff --git a/test cases/common/10 man install/meson.build b/test cases/common/10 man install/meson.build index 05c5278..d0f3be8 100644 --- a/test cases/common/10 man install/meson.build +++ b/test cases/common/10 man install/meson.build @@ -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') diff --git a/unittests/allplatformstests.py b/unittests/allplatformstests.py index 60ff123..6f722c7 100644 --- a/unittests/allplatformstests.py +++ b/unittests/allplatformstests.py @@ -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' ''')) diff --git a/unittests/linuxcrosstests.py b/unittests/linuxcrosstests.py index 16f7c24..0c0355a 100644 --- a/unittests/linuxcrosstests.py +++ b/unittests/linuxcrosstests.py @@ -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()) diff --git a/unittests/machinefiletests.py b/unittests/machinefiletests.py index 0a756b5..a124b64 100644 --- a/unittests/machinefiletests.py +++ b/unittests/machinefiletests.py @@ -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') |