From ed129a53118b417d95d1554a0ccf4286606ef69b Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Sun, 18 Sep 2022 21:10:21 -0400 Subject: [PATCH] wrap: If the directory exists in a sub-subproject, uses it inplace A subproject could have a sub-subproject as a git submodule, or part of the subproject's release tarball, and still have a wrap file for it (e.g. needed for [provide] section). In that case we need to use the source tree for the sub-subproject inplace instead of downloading a new copy into the main project. This is the case with GLib 2.74, it has a subproject "gvdb" as git submodule, and part of release tarball, it ships gvdb.wrap file as well. --- mesonbuild/wrap/wrap.py | 11 +++++++---- .../common/254 subsubproject inplace/meson.build | 3 +++ .../subprojects/sub/meson.build | 3 +++ .../sub/subprojects/subsub-1.0/meson.build | 1 + .../subprojects/sub/subprojects/subsub.wrap | 2 ++ 5 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 test cases/common/254 subsubproject inplace/meson.build create mode 100644 test cases/common/254 subsubproject inplace/subprojects/sub/meson.build create mode 100644 test cases/common/254 subsubproject inplace/subprojects/sub/subprojects/subsub-1.0/meson.build create mode 100644 test cases/common/254 subsubproject inplace/subprojects/sub/subprojects/subsub.wrap diff --git a/mesonbuild/wrap/wrap.py b/mesonbuild/wrap/wrap.py index 86dd74ec4..10aa1b80e 100644 --- a/mesonbuild/wrap/wrap.py +++ b/mesonbuild/wrap/wrap.py @@ -346,10 +346,13 @@ class Resolver: self.directory = self.wrap.directory if self.wrap.has_wrap: - # We have a .wrap file, source code will be placed into main - # project's subproject_dir even if the wrap file comes from another - # subproject. - self.dirname = os.path.join(self.subdir_root, self.directory) + # We have a .wrap file, use directory relative to the location of + # the wrap file if it exists, otherwise source code will be placed + # into main project's subproject_dir even if the wrap file comes + # from another subproject. + self.dirname = os.path.join(os.path.dirname(self.wrap.filename), self.wrap.directory) + if not os.path.exists(self.dirname): + self.dirname = os.path.join(self.subdir_root, self.directory) # Check if the wrap comes from the main project. main_fname = os.path.join(self.subdir_root, self.wrap.basename) if self.wrap.filename != main_fname: diff --git a/test cases/common/254 subsubproject inplace/meson.build b/test cases/common/254 subsubproject inplace/meson.build new file mode 100644 index 000000000..26a421b32 --- /dev/null +++ b/test cases/common/254 subsubproject inplace/meson.build @@ -0,0 +1,3 @@ +project('main') + +subproject('sub') diff --git a/test cases/common/254 subsubproject inplace/subprojects/sub/meson.build b/test cases/common/254 subsubproject inplace/subprojects/sub/meson.build new file mode 100644 index 000000000..5e33d2193 --- /dev/null +++ b/test cases/common/254 subsubproject inplace/subprojects/sub/meson.build @@ -0,0 +1,3 @@ +project('sub') + +subproject('subsub') diff --git a/test cases/common/254 subsubproject inplace/subprojects/sub/subprojects/subsub-1.0/meson.build b/test cases/common/254 subsubproject inplace/subprojects/sub/subprojects/subsub-1.0/meson.build new file mode 100644 index 000000000..7807a1bae --- /dev/null +++ b/test cases/common/254 subsubproject inplace/subprojects/sub/subprojects/subsub-1.0/meson.build @@ -0,0 +1 @@ +project('subsub') diff --git a/test cases/common/254 subsubproject inplace/subprojects/sub/subprojects/subsub.wrap b/test cases/common/254 subsubproject inplace/subprojects/sub/subprojects/subsub.wrap new file mode 100644 index 000000000..bf398525a --- /dev/null +++ b/test cases/common/254 subsubproject inplace/subprojects/sub/subprojects/subsub.wrap @@ -0,0 +1,2 @@ +[wrap-file] +directory = subsub-1.0