summaryrefslogtreecommitdiff
path: root/mesonbuild/backend/backends.py
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2024-12-10 14:34:08 -0800
committerJussi Pakkanen <jussi.pakkanen@mailbox.org>2025-11-04 21:56:04 +0200
commit60e3cc1c58c208c635bda23a7c62a92ae84cb6b6 (patch)
tree09e95bc8b62564211905abce8a3c30dcc1ff609c /mesonbuild/backend/backends.py
parent66e43fa19f93e9f9367cb2008d06ecc0d261ba73 (diff)
downloadmeson-60e3cc1c58c208c635bda23a7c62a92ae84cb6b6.tar.gz
Add build target keyword parameter 'build_subdir' [v8]
Place the build products in a directory of the specified name somewhere within the build directory. This allows use of the target that includes a specific directory name: #include <subdir/configure.h> This also allows creating targets with the same basename by using different subdirectory names. v2: Move build_subdir to Target class. Error if path separator in build_dir v3: Rename to 'build_subdir' to make it clear that the name is appended to a meson-specific build directory, and does not provide the user with a way to define the overall meson build hierarchy. Allow build_subdir to include path separators. Support 'build_subdir' for configure_file. build_subdir must not exist in the source directory and must not contain '..' Add documentation and tests v4: Rebase and prepare for version 1.9.1 Add failing test case when build_subdir is present in the project. Add release note snippet v5: Clarify wording on restrictions on the value of build_subdir. Use the same wording in each place this restriction is described. v6: Move path validation to shared function, validate_build_subdir, instead of duplicating the tests in two places. v7: Update version numbers to 1.10.0 Add TypedDict updates. Remove spurious build_subdir instance variable v8: Oops, missed one version number update. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'mesonbuild/backend/backends.py')
-rw-r--r--mesonbuild/backend/backends.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py
index db7b5785c..545b41756 100644
--- a/mesonbuild/backend/backends.py
+++ b/mesonbuild/backend/backends.py
@@ -336,9 +336,9 @@ class Backend:
def get_build_dir_include_args(self, target: build.BuildTarget, compiler: 'Compiler', *, absolute_path: bool = False) -> T.List[str]:
if absolute_path:
- curdir = os.path.join(self.build_dir, target.get_subdir())
+ curdir = os.path.join(self.build_dir, target.get_builddir())
else:
- curdir = target.get_subdir()
+ curdir = target.get_builddir()
if curdir == '':
curdir = '.'
return compiler.get_include_args(curdir, False)
@@ -373,9 +373,12 @@ class Backend:
# this produces no output, only a dummy top-level name
dirname = ''
elif self.environment.coredata.optstore.get_value_for(OptionKey('layout')) == 'mirror':
- dirname = target.get_subdir()
+ dirname = target.get_builddir()
else:
dirname = 'meson-out'
+ build_subdir = target.get_build_subdir()
+ if build_subdir:
+ dirname = os.path.join(dirname, build_subdir)
return dirname
def get_target_dir_relative_to(self,
@@ -488,7 +491,7 @@ class Backend:
for obj in objects:
if isinstance(obj, str):
o = os.path.join(proj_dir_to_build_root,
- self.build_to_src, target.get_subdir(), obj)
+ self.build_to_src, target.get_builddir(), obj)
obj_list.append(o)
elif isinstance(obj, mesonlib.File):
if obj.is_built:
@@ -1229,7 +1232,7 @@ class Backend:
ld_lib_path_libs.add(l)
env_build_dir = self.environment.get_build_dir()
- ld_lib_path: T.Set[str] = set(os.path.join(env_build_dir, l.get_subdir()) for l in ld_lib_path_libs)
+ ld_lib_path: T.Set[str] = set(os.path.join(env_build_dir, l.get_builddir()) for l in ld_lib_path_libs)
if ld_lib_path:
t_env.prepend('LD_LIBRARY_PATH', list(ld_lib_path), ':')