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