Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add build target keyword parameter 'build_dir' #4037

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/markdown/Reference-manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,8 @@ be passed to [shared and static libraries](#library).
in the D programming language
- `d_unittest`, when set to true, the D modules are compiled in debug mode
- `d_module_versions` list of module versions set when compiling D sources
- `build_dir` provides a subdirectory to place the built
target. Useful when building multiple targets with the same base filename.

The list of `sources`, `objects`, and `dependencies` is always
flattened, which means you can freely nest and add lists while
Expand Down
4 changes: 3 additions & 1 deletion mesonbuild/backend/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,9 @@ def get_target_dir(self, target):
dirname = target.get_subdir()
else:
dirname = 'meson-out'
return dirname
if target.build_dir == '':
return dirname
return os.path.join(dirname, target.build_dir)

def get_target_dir_relative_to(self, t, o):
'''Get a target dir relative to another target's directory'''
Expand Down
9 changes: 9 additions & 0 deletions mesonbuild/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
buildtarget_kwargs = set([
'build_by_default',
'build_rpath',
'build_dir',
'dependencies',
'extra_files',
'gui_app',
Expand Down Expand Up @@ -306,6 +307,7 @@ def __init__(self, name, subdir, subproject, build_by_default):
This is not supported, it can cause unexpected failures and will become
a hard error in the future.''' % name)
self.name = name
self.build_dir = ''
self.subdir = subdir
self.subproject = subproject
self.build_by_default = build_by_default
Expand All @@ -328,6 +330,8 @@ def get_id(self):
name_part = self.name.replace('/', '@').replace('\\', '@')
assert not has_path_sep(self.type_suffix())
myid = name_part + self.type_suffix()
if self.build_dir:
myid = self.build_dir + '@@' + myid
if self.subdir:
subdir_part = self.subdir.replace('/', '@').replace('\\', '@')
myid = subdir_part + '@@' + myid
Expand All @@ -339,6 +343,11 @@ def process_kwargs(self, kwargs):
if not isinstance(self.build_by_default, bool):
raise InvalidArguments('build_by_default must be a boolean value.')
self.option_overrides = self.parse_overrides(kwargs)
self.build_dir = kwargs.get('build_dir', '')
if not isinstance(self.build_dir, str):
raise InvalidArguments('Build_dir must be a string.')
if has_path_sep(self.build_dir):
raise InvalidArguments('Build_dir "%s" has a path separator in its name.' % self.build_dir)

def parse_overrides(self, kwargs):
result = {}
Expand Down