Skip to content

Commit

Permalink
make sure files arguments to compiler.compiles and friends, performs …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
eli-schwartz committed Nov 28, 2021
1 parent 69fa37e commit bea735d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions mesonbuild/interpreter/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ def alignment_method(self, args: T.Tuple[str], kwargs: 'AlignmentKw') -> int:
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']
Expand Down Expand Up @@ -434,6 +435,7 @@ def get_define_method(self, args: T.Tuple[str], kwargs: 'CommonKW') -> str:
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']
Expand All @@ -457,6 +459,7 @@ def links_method(self, args: T.Tuple['mesonlib.FileOrString'], kwargs: 'CompileK
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
Expand Down
7 changes: 7 additions & 0 deletions unittests/allplatformstests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1965,6 +1965,13 @@ def test_mixed_language_linker_check(self):
# 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')
Expand Down

0 comments on commit bea735d

Please sign in to comment.