interpreter: Correctly ignore def files in build directory

See https://gitlab.freedesktop.org/gstreamer/gst-build/-/issues/85.
0.54
Xavier Claessens 5 years ago committed by Nirbheek Chauhan
parent 79d13ce783
commit bd64692f63
  1. 14
      mesonbuild/interpreter.py
  2. 28
      run_unittests.py
  3. 0
      test cases/unit/74 dep files/foo.c
  4. 16
      test cases/unit/74 dep files/meson.build

@ -2422,14 +2422,14 @@ class Interpreter(InterpreterBase):
return return
f = os.path.normpath(f.relative_name()) f = os.path.normpath(f.relative_name())
elif os.path.isfile(f) and not f.startswith('/dev'): elif os.path.isfile(f) and not f.startswith('/dev'):
srcdir = self.environment.get_source_dir() srcdir = Path(self.environment.get_source_dir())
builddir = self.environment.get_build_dir() builddir = Path(self.environment.get_build_dir())
f = os.path.normpath(f) f = Path(f).resolve()
rel_path = mesonlib.relpath(f, start=srcdir) if builddir in f.parents:
if not rel_path.startswith('..'):
f = rel_path
elif not mesonlib.relpath(f, start=builddir).startswith('..'):
return return
if srcdir in f.parents:
f = f.relative_to(srcdir)
f = str(f)
else: else:
return return
if f not in self.build_def_files: if f not in self.build_def_files:

@ -4562,6 +4562,34 @@ recommended as it is not supported on some platforms''')
self._run([*self.meson_command, 'compile', '-C', self.builddir, '--clean']) self._run([*self.meson_command, 'compile', '-C', self.builddir, '--clean'])
self.assertPathDoesNotExist(os.path.join(self.builddir, prog)) self.assertPathDoesNotExist(os.path.join(self.builddir, prog))
def test_spurious_reconfigure_built_dep_file(self):
testdir = os.path.join(self.unit_test_dir, '74 dep files')
# Regression test: Spurious reconfigure was happening when build
# directory is inside source directory.
# See https://gitlab.freedesktop.org/gstreamer/gst-build/-/issues/85.
srcdir = os.path.join(self.builddir, 'srctree')
shutil.copytree(testdir, srcdir)
builddir = os.path.join(srcdir, '_build')
self.change_builddir(builddir)
self.init(srcdir)
self.build()
# During first configure the file did not exist so no dependency should
# have been set. A rebuild should not trigger a reconfigure.
self.clean()
out = self.build()
self.assertNotIn('Project configured', out)
self.init(srcdir, extra_args=['--reconfigure'])
# During the reconfigure the file did exist, but is inside build
# directory, so no dependency should have been set. A rebuild should not
# trigger a reconfigure.
self.clean()
out = self.build()
self.assertNotIn('Project configured', out)
class FailureTests(BasePlatformTests): class FailureTests(BasePlatformTests):
''' '''

@ -0,0 +1,16 @@
project('test', 'c')
python = import('python').find_installation()
lib = library('foo', 'foo.c')
# The library does not yet exist but we can already use its path during
# configuration. This should not trigger a reconfigure when the library is
# rebuilt.
configure_file(
output: 'out.txt',
capture: true,
command: [python, '-c', 'import sys; print(sys.argv[1])', lib.full_path()],
)
message('Project configured')
Loading…
Cancel
Save