dependencies: handle one more case of subproject installed files

Some projects treat meson.project_source_root() as the root of the
dependency files, because the project itself merely wraps a bunch of
datafiles. Our validation to make sure this doesn't point to another
subproject, made use of pathlib.Path's generator for all component
paths, which... did not include the path itself. So go ahead and
explicitly check that too. Add a test case to verify it while we are at
it.

Fixes https://github.com/mesonbuild/meson/pull/10103#issuecomment-1114901033
pull/10346/head
Eli Schwartz 3 years ago
parent 5a34dcedf7
commit 6c0370f62f
No known key found for this signature in database
GPG Key ID: CEB167EFB5722BD6
  1. 2
      mesonbuild/interpreter/interpreter.py
  2. 5
      test cases/common/251 subproject dependency variables/meson.build
  3. 1
      test cases/common/251 subproject dependency variables/subprojects/subfiles/foo.c
  4. 3
      test cases/common/251 subproject dependency variables/subprojects/subfiles/meson.build
  5. 1
      test cases/common/251 subproject dependency variables/test.json

@ -680,7 +680,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.resolve().parents:
if p.is_absolute() and p.is_dir() and srcdir / self.root_subdir in [p] + list(p.resolve().parents):
variables[k] = P_OBJ.DependencyVariableString(v)
for d in deps:
if not isinstance(d, dependencies.Dependency):

@ -11,3 +11,8 @@ executable(
'foo2',
subfiles_dep.get_variable('pkgdatadir2') / 'foo.c'
)
executable(
'foor32',
subfiles_dep.get_variable('pkgdatadir3') / 'foo.c'
)

@ -4,11 +4,13 @@ files_dep = declare_dependency(
variables: [
'pkgdatadir=@0@/subdir'.format(meson.current_source_dir()),
'pkgdatadir2=@0@/subdir2'.format(meson.current_source_dir()),
'pkgdatadir3=@0@'.format(meson.current_source_dir()),
]
)
install_data('subdir/foo.c', install_dir: get_option('datadir') / 'subdir')
install_subdir('subdir2', install_dir: get_option('datadir'))
install_data('foo.c', install_dir: get_option('datadir'))
import('pkgconfig').generate(
name: 'depvar_resource',
@ -21,6 +23,7 @@ import('pkgconfig').generate(
uninstalled_variables: [
'pkgdatadir=@0@/subdir'.format(meson.current_source_dir()),
'pkgdatadir2=@0@/subdir2'.format(meson.current_source_dir()),
'pkgdatadir3=@0@'.format(meson.current_source_dir()),
],
dataonly: true,
)

@ -1,6 +1,7 @@
{
"installed": [
{ "type": "file", "file": "usr/share/pkgconfig/depvar_resource.pc" },
{ "type": "file", "file": "usr/share/foo.c" },
{ "type": "file", "file": "usr/share/subdir/foo.c" },
{ "type": "file", "file": "usr/share/subdir2/foo.c" }
]

Loading…
Cancel
Save