aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesonbuild/interpreter.py14
-rwxr-xr-xrun_unittests.py28
-rw-r--r--test cases/unit/74 dep files/foo.c0
-rw-r--r--test cases/unit/74 dep files/meson.build16
4 files changed, 51 insertions, 7 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index c1636d7..214b1eb 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -2422,14 +2422,14 @@ class Interpreter(InterpreterBase):
return
f = os.path.normpath(f.relative_name())
elif os.path.isfile(f) and not f.startswith('/dev'):
- srcdir = self.environment.get_source_dir()
- builddir = self.environment.get_build_dir()
- f = os.path.normpath(f)
- rel_path = mesonlib.relpath(f, start=srcdir)
- if not rel_path.startswith('..'):
- f = rel_path
- elif not mesonlib.relpath(f, start=builddir).startswith('..'):
+ srcdir = Path(self.environment.get_source_dir())
+ builddir = Path(self.environment.get_build_dir())
+ f = Path(f).resolve()
+ if builddir in f.parents:
return
+ if srcdir in f.parents:
+ f = f.relative_to(srcdir)
+ f = str(f)
else:
return
if f not in self.build_def_files:
diff --git a/run_unittests.py b/run_unittests.py
index 4cd6e17..d3d220c 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -4562,6 +4562,34 @@ recommended as it is not supported on some platforms''')
self._run([*self.meson_command, 'compile', '-C', self.builddir, '--clean'])
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):
'''
diff --git a/test cases/unit/74 dep files/foo.c b/test cases/unit/74 dep files/foo.c
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test cases/unit/74 dep files/foo.c
diff --git a/test cases/unit/74 dep files/meson.build b/test cases/unit/74 dep files/meson.build
new file mode 100644
index 0000000..4829f56
--- /dev/null
+++ b/test cases/unit/74 dep files/meson.build
@@ -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')