interpreter: fix a subproject check with symlinks

The check for whether or not a file is allowed to be accessed from a
subproject fails if the subproject is accessed via a symlink. Use the
absolute path of the subproject without resolving symlinks to fix the
check.

Extend unit test 106 to check for this in the future.
pull/10492/head
Hemmo Nieminen 2 years ago committed by Eli Schwartz
parent 9b21428006
commit b49b9f52b2
  1. 2
      mesonbuild/interpreter/interpreter.py
  2. 6
      test cases/unit/106 subproject symlink/cp.py
  3. 11
      test cases/unit/106 subproject symlink/meson.build
  4. 1
      test cases/unit/106 subproject symlink/symlinked_subproject/datadir/datafile
  5. 1
      test cases/unit/106 subproject symlink/symlinked_subproject/datadir/meson.build
  6. 9
      test cases/unit/106 subproject symlink/symlinked_subproject/meson.build

@ -684,7 +684,7 @@ class Interpreter(InterpreterBase, HoldableObject):
else:
if not self.is_subproject() and srcdir / self.subproject_dir in p.parents:
continue
if p.is_absolute() and p.is_dir() and srcdir / self.root_subdir in [p] + list(p.resolve().parents):
if p.is_absolute() and p.is_dir() and srcdir / self.root_subdir in [p] + list(Path(os.path.abspath(p)).parents):
variables[k] = P_OBJ.DependencyVariableString(v)
for d in deps:
if not isinstance(d, dependencies.Dependency):

@ -0,0 +1,6 @@
#!/usr/bin/env python3
from sys import argv
from shutil import copy
copy(argv[1], argv[2])

@ -1,8 +1,15 @@
project('foo', 'c')
symlinked_subproject = subproject('symlinked_subproject')
symlinked_subproject = subproject('symlinked_subproject').get_variable('dep')
executable('foo',
sources : 'main.c',
dependencies : symlinked_subproject.get_variable('dep')
dependencies : symlinked_subproject
)
custom_target(
input : symlinked_subproject.get_variable('datadir') / 'datafile',
output : 'datafile_copy',
command : [find_program('cp.py'), '@INPUT@', '@OUTPUT@'],
build_always : true
)

@ -1,3 +1,10 @@
project('symlinked_subproject', 'c', version : '1.0.0')
dep = declare_dependency(sources : 'src.c')
dep = declare_dependency(
sources : 'src.c',
variables : {
'datadir': meson.current_source_dir() / 'datadir'
}
)
subdir('datadir')

Loading…
Cancel
Save