aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/cmake
diff options
context:
space:
mode:
Diffstat (limited to 'mesonbuild/cmake')
-rwxr-xr-xmesonbuild/cmake/data/run_ctgt.py26
-rw-r--r--mesonbuild/cmake/traceparser.py15
2 files changed, 36 insertions, 5 deletions
diff --git a/mesonbuild/cmake/data/run_ctgt.py b/mesonbuild/cmake/data/run_ctgt.py
index 1897a1b..9d5d437 100755
--- a/mesonbuild/cmake/data/run_ctgt.py
+++ b/mesonbuild/cmake/data/run_ctgt.py
@@ -5,6 +5,7 @@ import subprocess
import shutil
import os
import sys
+from pathlib import Path
commands = [[]]
SEPARATOR = ';;;'
@@ -40,9 +41,32 @@ for i in commands:
if not i:
continue
+ cmd = []
+ stdout = None
+ stderr = None
+ capture_file = ''
+
+ for j in i:
+ if j in ['>', '>>']:
+ stdout = subprocess.PIPE
+ continue
+ elif j in ['&>', '&>>']:
+ stdout = subprocess.PIPE
+ stderr = subprocess.STDOUT
+ continue
+
+ if stdout is not None or stderr is not None:
+ capture_file += j
+ else:
+ cmd += [j]
+
try:
os.makedirs(args.directory, exist_ok=True)
- subprocess.run(i, cwd=args.directory, check=True)
+
+ res = subprocess.run(cmd, stdout=stdout, stderr=stderr, cwd=args.directory, check=True)
+ if capture_file:
+ out_file = Path(args.directory) / capture_file
+ out_file.write_bytes(res.stdout)
except subprocess.CalledProcessError:
exit(1)
diff --git a/mesonbuild/cmake/traceparser.py b/mesonbuild/cmake/traceparser.py
index 8eb8605..d6970f2 100644
--- a/mesonbuild/cmake/traceparser.py
+++ b/mesonbuild/cmake/traceparser.py
@@ -309,7 +309,7 @@ class CMakeTraceParser:
def _cmake_add_custom_command(self, tline: CMakeTraceLine, name=None):
# DOC: https://cmake.org/cmake/help/latest/command/add_custom_command.html
- args = list(tline.args) # Make a working copy
+ args = self._flatten_args(list(tline.args)) # Commands can be passed as ';' seperated lists
if not args:
return self._gen_exception('add_custom_command', 'requires at least 1 argument', tline)
@@ -325,15 +325,15 @@ class CMakeTraceParser:
target = CMakeGeneratorTarget(name)
def handle_output(key: str, target: CMakeGeneratorTarget) -> None:
- target.outputs += key.split(';')
+ target.outputs += [key]
def handle_command(key: str, target: CMakeGeneratorTarget) -> None:
if key == 'ARGS':
return
- target.command[-1] += key.split(';')
+ target.command[-1] += [key]
def handle_depends(key: str, target: CMakeGeneratorTarget) -> None:
- target.depends += key.split(';')
+ target.depends += [key]
def handle_working_dir(key: str, target: CMakeGeneratorTarget) -> None:
if target.working_dir is None:
@@ -608,6 +608,13 @@ class CMakeTraceParser:
args = [parse_generator_expressions(x) for x in args]
yield CMakeTraceLine(data['file'], data['line'], data['cmd'], args)
+ def _flatten_args(self, args: T.List[str]) -> T.List[str]:
+ # Split lists in arguments
+ res = [] # type: T.List[str]
+ for i in args:
+ res += i.split(';')
+ return res
+
def _guess_files(self, broken_list: T.List[str]) -> T.List[str]:
# Nothing has to be done for newer formats
if self.trace_format != 'human':