mirror of
https://github.com/AsahiLinux/u-boot
synced 2025-02-26 12:27:12 +00:00
binman: bintool: Build a tool from a list of commands
Add support to build a tool from source with a list of commands. This is useful when a tool can be built with multiple commands instead of a single command. Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org> Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
11cf91f755
commit
d71e711699
1 changed files with 11 additions and 8 deletions
|
@ -328,7 +328,7 @@ class Bintool:
|
||||||
return result.stdout
|
return result.stdout
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def build_from_git(cls, git_repo, make_target, bintool_path, flags=None):
|
def build_from_git(cls, git_repo, make_targets, bintool_path, flags=None):
|
||||||
"""Build a bintool from a git repo
|
"""Build a bintool from a git repo
|
||||||
|
|
||||||
This clones the repo in a temporary directory, builds it with 'make',
|
This clones the repo in a temporary directory, builds it with 'make',
|
||||||
|
@ -336,7 +336,8 @@ class Bintool:
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
git_repo (str): URL of git repo
|
git_repo (str): URL of git repo
|
||||||
make_target (str): Target to pass to 'make' to build the tool
|
make_targets (list of str): List of targets to pass to 'make' to build
|
||||||
|
the tool
|
||||||
bintool_path (str): Relative path of the tool in the repo, after
|
bintool_path (str): Relative path of the tool in the repo, after
|
||||||
build is complete
|
build is complete
|
||||||
flags (list of str): Flags or variables to pass to make, or None
|
flags (list of str): Flags or variables to pass to make, or None
|
||||||
|
@ -350,12 +351,14 @@ class Bintool:
|
||||||
tmpdir = tempfile.mkdtemp(prefix='binmanf.')
|
tmpdir = tempfile.mkdtemp(prefix='binmanf.')
|
||||||
print(f"- clone git repo '{git_repo}' to '{tmpdir}'")
|
print(f"- clone git repo '{git_repo}' to '{tmpdir}'")
|
||||||
tools.run('git', 'clone', '--depth', '1', git_repo, tmpdir)
|
tools.run('git', 'clone', '--depth', '1', git_repo, tmpdir)
|
||||||
print(f"- build target '{make_target}'")
|
for target in make_targets:
|
||||||
cmd = ['make', '-C', tmpdir, '-j', f'{multiprocessing.cpu_count()}',
|
print(f"- build target '{target}'")
|
||||||
make_target]
|
cmd = ['make', '-C', tmpdir, '-j', f'{multiprocessing.cpu_count()}',
|
||||||
if flags:
|
target]
|
||||||
cmd += flags
|
if flags:
|
||||||
tools.run(*cmd)
|
cmd += flags
|
||||||
|
tools.run(*cmd)
|
||||||
|
|
||||||
fname = os.path.join(tmpdir, bintool_path)
|
fname = os.path.join(tmpdir, bintool_path)
|
||||||
if not os.path.exists(fname):
|
if not os.path.exists(fname):
|
||||||
print(f"- File '{fname}' was not produced")
|
print(f"- File '{fname}' was not produced")
|
||||||
|
|
Loading…
Add table
Reference in a new issue