aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/backend/backends.py
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2019-07-12 09:31:22 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2019-07-19 00:17:29 +0200
commitf95c965043221b2fc0e40c9410bd9efa88f31832 (patch)
tree87af98df662085c48dd9b57c75b8dbd64c6fec58 /mesonbuild/backend/backends.py
parenteb5aff8b767000477e926bd5fc1bc70e4198ccdb (diff)
downloadmeson-f95c965043221b2fc0e40c9410bd9efa88f31832.zip
meson-f95c965043221b2fc0e40c9410bd9efa88f31832.tar.gz
meson-f95c965043221b2fc0e40c9410bd9efa88f31832.tar.bz2
backends: choose whether to serialize in as_meson_exe_cmdline
This removes more duplicate code between custom targets and generators. In addition, generators can now have arguments with newlines in them.
Diffstat (limited to 'mesonbuild/backend/backends.py')
-rw-r--r--mesonbuild/backend/backends.py29
1 files changed, 18 insertions, 11 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py
index 71d5e20..b016fe5 100644
--- a/mesonbuild/backend/backends.py
+++ b/mesonbuild/backend/backends.py
@@ -323,26 +323,33 @@ class Backend:
raise MesonException('Unknown data type in object list.')
return obj_list
- def as_meson_exe_cmdline(self, tname, exe, cmd_args, workdir, env=None,
- extra_paths=None, capture=None):
+ def as_meson_exe_cmdline(self, tname, exe, cmd_args, workdir=None,
+ for_machine=MachineChoice.BUILD,
+ extra_bdeps=None, capture=None, force_serialize=False):
'''
Serialize an executable for running with a generator or a custom target
'''
import hashlib
- if env is None:
- env = {}
- if extra_paths is None:
- # The callee didn't check if we needed extra paths, so check it here
- if mesonlib.is_windows() or mesonlib.is_cygwin():
- extra_paths = self.determine_windows_extra_paths(exe, [])
- else:
- extra_paths = []
- # Can't just use exe.name here; it will likely be run more than once
+ machine = self.environment.machines[for_machine]
+ if machine.is_windows() or machine.is_cygwin():
+ extra_paths = self.determine_windows_extra_paths(exe, extra_bdeps or [])
+ else:
+ extra_paths = []
+
+ force_serialize = force_serialize or extra_paths or capture or workdir or \
+ any('\n' in c for c in cmd_args)
+ if not force_serialize:
+ return None
+
+ workdir = workdir or self.environment.get_build_dir()
+ env = {}
if isinstance(exe, (dependencies.ExternalProgram,
build.BuildTarget, build.CustomTarget)):
basename = exe.name
else:
basename = os.path.basename(exe)
+
+ # Can't just use exe.name here; it will likely be run more than once
# Take a digest of the cmd args, env, workdir, and capture. This avoids
# collisions and also makes the name deterministic over regenerations
# which avoids a rebuild by Ninja because the cmdline stays the same.