diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2014-07-27 23:48:59 +0300 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2014-07-27 23:48:59 +0300 |
commit | 860329c5661e4692a3ad115b675aec86acebc758 (patch) | |
tree | f297623691fa0ec29116f857e06e70af4f5736b2 /interpreter.py | |
parent | af0ca6751a9b8d1c9ad643602b7d699ed8bc7a76 (diff) | |
download | meson-860329c5661e4692a3ad115b675aec86acebc758.zip meson-860329c5661e4692a3ad115b675aec86acebc758.tar.gz meson-860329c5661e4692a3ad115b675aec86acebc758.tar.bz2 |
Can do run_command in the build tree.
Diffstat (limited to 'interpreter.py')
-rw-r--r-- | interpreter.py | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/interpreter.py b/interpreter.py index ffad881..b58c3eb 100644 --- a/interpreter.py +++ b/interpreter.py @@ -63,9 +63,9 @@ class TryRunResultHolder(InterpreterObject): class RunProcess(InterpreterObject): - def __init__(self, command_array, source_dir, build_dir, subdir): + def __init__(self, command_array, source_dir, build_dir, subdir, in_builddir=False): super().__init__() - pc = self.run_command(command_array, source_dir, build_dir, subdir) + pc = self.run_command(command_array, source_dir, build_dir, subdir, in_builddir) (stdout, stderr) = pc.communicate() self.returncode = pc.returncode self.stdout = stdout.decode().replace('\r\n', '\n') @@ -75,12 +75,15 @@ class RunProcess(InterpreterObject): 'stderr' : self.stderr_method, }) - def run_command(self, command_array, source_dir, build_dir, subdir): + def run_command(self, command_array, source_dir, build_dir, subdir, in_builddir): cmd_name = command_array[0] env = {'MESON_SOURCE_ROOT' : source_dir, 'MESON_BUILD_ROOT' : build_dir, 'MESON_SUBDIR' : subdir} - cwd = os.path.join(source_dir, subdir) + if in_builddir: + cwd = os.path.join(build_dir, subdir) + else: + cwd = os.path.join(source_dir, subdir) child_env = os.environ.copy() child_env.update(env) try: @@ -806,7 +809,11 @@ class Interpreter(): if not isinstance(i, str): raise InterpreterException('Run_command arguments must be strings.') args = [cmd] + cargs - return RunProcess(args, self.environment.source_dir, self.environment.build_dir, self.subdir) + in_builddir = kwargs.get('in_builddir', False) + if not isinstance(in_builddir, bool): + raise InterpreterException('in_builddir must be boolean.') + return RunProcess(args, self.environment.source_dir, self.environment.build_dir, + self.subdir, in_builddir) def func_gettext(self, nodes, args, kwargs): if len(args) != 1: |