make sure files arguments to compiler.compiles and friends, performs rebuild

If the compiler check is updated as a string in meson.build, we force
rebuild, which is a good thing since the outcome of that check changes
the configuration context and can enable or disable parts of the build.

If the compiler check came from a files() object then we didn't add a
regen rule on those files.

Fixes #1656
pull/9604/head
Eli Schwartz 3 years ago
parent 69fa37e9ca
commit bea735dd76
No known key found for this signature in database
GPG Key ID: CEB167EFB5722BD6
  1. 3
      mesonbuild/interpreter/compiler.py
  2. 7
      unittests/allplatformstests.py

@ -275,6 +275,7 @@ class CompilerHolder(ObjectHolder['Compiler']):
def run_method(self, args: T.Tuple['mesonlib.FileOrString'], kwargs: 'CompileKW') -> 'RunResult':
code = args[0]
if isinstance(code, mesonlib.File):
self.interpreter.add_build_def_file(code)
code = mesonlib.File.from_absolute_file(
code.rel_to_builddir(self.environment.source_dir))
testname = kwargs['name']
@ -434,6 +435,7 @@ class CompilerHolder(ObjectHolder['Compiler']):
def compiles_method(self, args: T.Tuple['mesonlib.FileOrString'], kwargs: 'CompileKW') -> bool:
code = args[0]
if isinstance(code, mesonlib.File):
self.interpreter.add_build_def_file(code)
code = mesonlib.File.from_absolute_file(
code.rel_to_builddir(self.environment.source_dir))
testname = kwargs['name']
@ -457,6 +459,7 @@ class CompilerHolder(ObjectHolder['Compiler']):
code = args[0]
compiler = None
if isinstance(code, mesonlib.File):
self.interpreter.add_build_def_file(code)
code = mesonlib.File.from_absolute_file(
code.rel_to_builddir(self.environment.source_dir))
suffix = code.suffix

@ -1965,6 +1965,13 @@ class AllPlatformTests(BasePlatformTests):
# cxx.links with C source
self.assertEqual(cmds[3][0], cc)
self.assertEqual(cmds[4][0], cxx)
if self.backend is Backend.ninja:
# updating the file to check causes a reconfigure
#
# only the ninja backend is competent enough to detect reconfigured
# no-op builds without build targets
self.utime(os.path.join(testdir, 'test.c'))
self.assertReconfiguredBuildIsNoop()
def test_ndebug_if_release_disabled(self):
testdir = os.path.join(self.unit_test_dir, '28 ndebug if-release')

Loading…
Cancel
Save