u_boot_pylib: Add a function to run a single command
Add a helper to avoid needing to use a list within a list for this
simple case.
Update existing users of runpipe() to use this where possible.
Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/tools/buildman/boards.py b/tools/buildman/boards.py
index e7aa0d8..2fe43c3 100644
--- a/tools/buildman/boards.py
+++ b/tools/buildman/boards.py
@@ -251,9 +251,9 @@
'-undef',
'-x', 'assembler-with-cpp',
defconfig]
- result = command.run_pipe([cmd], capture=True, capture_stderr=True)
+ stdout = command.output(*cmd, capture_stderr=True)
temp = tempfile.NamedTemporaryFile(prefix='buildman-')
- tools.write_file(temp.name, result.stdout, False)
+ tools.write_file(temp.name, stdout, False)
fname = temp.name
tout.info(f'Processing #include to produce {defconfig}')
else:
diff --git a/tools/buildman/builder.py b/tools/buildman/builder.py
index cbf1345..3eac17a 100644
--- a/tools/buildman/builder.py
+++ b/tools/buildman/builder.py
@@ -510,7 +510,7 @@
stage: Stage that we are at (mrproper, config, oldconfig, build)
cwd: Directory where make should be run
args: Arguments to pass to make
- kwargs: Arguments to pass to command.run_pipe()
+ kwargs: Arguments to pass to command.run_one()
"""
def check_output(stream, data):
@@ -531,11 +531,12 @@
return False
self._restarting_config = False
- self._terminated = False
+ self._terminated = False
cmd = [self.gnu_make] + list(args)
- result = command.run_pipe([cmd], capture=True, capture_stderr=True,
- cwd=cwd, raise_on_error=False, infile='/dev/null',
- output_func=check_output, **kwargs)
+ result = command.run_one(*cmd, capture=True, capture_stderr=True,
+ cwd=cwd, raise_on_error=False,
+ infile='/dev/null', output_func=check_output,
+ **kwargs)
if self._terminated:
# Try to be helpful
diff --git a/tools/buildman/builderthread.py b/tools/buildman/builderthread.py
index 29e6cf3..7646f2e 100644
--- a/tools/buildman/builderthread.py
+++ b/tools/buildman/builderthread.py
@@ -179,13 +179,12 @@
cwd (str): Working directory to set, or None to leave it alone
*args (list of str): Arguments to pass to 'make'
**kwargs (dict): A list of keyword arguments to pass to
- command.run_pipe()
+ command.run_one()
Returns:
CommandResult object
"""
- return self.builder.do_make(commit, brd, stage, cwd, *args,
- **kwargs)
+ return self.builder.do_make(commit, brd, stage, cwd, *args, **kwargs)
def _build_args(self, brd, out_dir, out_rel_dir, work_dir, commit_upto):
"""Set up arguments to the args list based on the settings
@@ -588,9 +587,10 @@
lines = []
for fname in BASE_ELF_FILENAMES:
cmd = [f'{self.toolchain.cross}nm', '--size-sort', fname]
- nm_result = command.run_pipe([cmd], capture=True,
- capture_stderr=True, cwd=result.out_dir,
- raise_on_error=False, env=env)
+ nm_result = command.run_one(*cmd, capture=True,
+ capture_stderr=True,
+ cwd=result.out_dir,
+ raise_on_error=False, env=env)
if nm_result.stdout:
nm_fname = self.builder.get_func_sizes_file(
result.commit_upto, result.brd.target, fname)
@@ -598,9 +598,10 @@
print(nm_result.stdout, end=' ', file=outf)
cmd = [f'{self.toolchain.cross}objdump', '-h', fname]
- dump_result = command.run_pipe([cmd], capture=True,
- capture_stderr=True, cwd=result.out_dir,
- raise_on_error=False, env=env)
+ dump_result = command.run_one(*cmd, capture=True,
+ capture_stderr=True,
+ cwd=result.out_dir,
+ raise_on_error=False, env=env)
rodata_size = ''
if dump_result.stdout:
objdump = self.builder.get_objdump_file(result.commit_upto,
@@ -613,9 +614,10 @@
rodata_size = fields[2]
cmd = [f'{self.toolchain.cross}size', fname]
- size_result = command.run_pipe([cmd], capture=True,
- capture_stderr=True, cwd=result.out_dir,
- raise_on_error=False, env=env)
+ size_result = command.run_one(*cmd, capture=True,
+ capture_stderr=True,
+ cwd=result.out_dir,
+ raise_on_error=False, env=env)
if size_result.stdout:
lines.append(size_result.stdout.splitlines()[1] + ' ' +
rodata_size)
@@ -624,9 +626,8 @@
cmd = [f'{self.toolchain.cross}objcopy', '-O', 'binary',
'-j', '.rodata.default_environment',
'env/built-in.o', 'uboot.env']
- command.run_pipe([cmd], capture=True,
- capture_stderr=True, cwd=result.out_dir,
- raise_on_error=False, env=env)
+ command.run_one(*cmd, capture=True, capture_stderr=True,
+ cwd=result.out_dir, raise_on_error=False, env=env)
if not work_in_output:
copy_files(result.out_dir, build_dir, '', ['uboot.env'])
diff --git a/tools/buildman/func_test.py b/tools/buildman/func_test.py
index 51a2366..1afc2fb 100644
--- a/tools/buildman/func_test.py
+++ b/tools/buildman/func_test.py
@@ -232,8 +232,8 @@
self._toolchains.Add('gcc', test=False)
def _RunBuildman(self, *args):
- return command.run_pipe([[self._buildman_pathname] + list(args)],
- capture=True, capture_stderr=True)
+ all_args = [self._buildman_pathname] + list(args)
+ return command.run_one(*all_args, capture=True, capture_stderr=True)
def _RunControl(self, *args, brds=False, clean_dir=False,
test_thread_exceptions=False, get_builder=True):
@@ -445,7 +445,7 @@
stage: Stage that we are at (mrproper, config, build)
cwd: Directory where make should be run
args: Arguments to pass to make
- kwargs: Arguments to pass to command.run_pipe()
+ kwargs: Arguments to pass to command.run_one()
"""
self._make_calls += 1
out_dir = ''
diff --git a/tools/buildman/toolchain.py b/tools/buildman/toolchain.py
index 958f36f..5d051e0 100644
--- a/tools/buildman/toolchain.py
+++ b/tools/buildman/toolchain.py
@@ -100,7 +100,7 @@
else:
self.priority = priority
if test:
- result = command.run_pipe([cmd], capture=True, env=env,
+ result = command.run_one(*cmd, capture=True, env=env,
raise_on_error=False)
self.ok = result.return_code == 0
if verbose: