[PATCH v4 01/12] binman: bintool: Build a tool from a list of commands
Simon Glass
sjg at chromium.org
Sun Jul 16 01:40:48 CEST 2023
Hi Sughosh,
On Sat, 15 Jul 2023 at 07:46, Sughosh Ganu <sughosh.ganu at linaro.org> wrote:
>
> 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 at linaro.org>
> ---
> Changes since V3:
> * New patch to support passing multiple commands to the build_from_git
> function to build the tool.
>
> tools/binman/bintool.py | 19 +++++++++++--------
> tools/binman/btool/_testing.py | 3 ++-
> tools/binman/btool/fiptool.py | 4 +++-
> tools/binman/btool/futility.py | 4 +++-
> 4 files changed, 19 insertions(+), 11 deletions(-)
>
> diff --git a/tools/binman/bintool.py b/tools/binman/bintool.py
> index 81629683df..279bf2fec4 100644
> --- a/tools/binman/bintool.py
> +++ b/tools/binman/bintool.py
> @@ -328,7 +328,7 @@ class Bintool:
> return result.stdout
>
> @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
>
> This clones the repo in a temporary directory, builds it with 'make',
> @@ -336,7 +336,8 @@ class Bintool:
>
> Args:
> 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
> build is complete
> flags (list of str): Flags or variables to pass to make, or None
> @@ -350,12 +351,14 @@ class Bintool:
> tmpdir = tempfile.mkdtemp(prefix='binmanf.')
> print(f"- clone git repo '{git_repo}' to '{tmpdir}'")
> tools.run('git', 'clone', '--depth', '1', git_repo, tmpdir)
> - print(f"- build target '{make_target}'")
> - cmd = ['make', '-C', tmpdir, '-j', f'{multiprocessing.cpu_count()}',
> - make_target]
> - if flags:
> - cmd += flags
> - tools.run(*cmd)
> + for target in make_targets:
> + print(f"- build target '{target}'")
> + cmd = ['make', '-C', tmpdir, '-j', f'{multiprocessing.cpu_count()}',
> + target]
> + if flags:
> + cmd += flags
> + tools.run(*cmd)
> +
> fname = os.path.join(tmpdir, bintool_path)
> if not os.path.exists(fname):
> print(f"- File '{fname}' was not produced")
> diff --git a/tools/binman/btool/_testing.py b/tools/binman/btool/_testing.py
> index 4005e8a8a5..c0109c76bf 100644
> --- a/tools/binman/btool/_testing.py
> +++ b/tools/binman/btool/_testing.py
> @@ -32,5 +32,6 @@ class Bintool_testing(bintool.Bintool):
> return self.apt_install('package')
> return self.fetch_from_drive('junk')
> if method == bintool.FETCH_BUILD:
> - return self.build_from_git('url', 'target', 'pathname')
> + cmd = ['target']
> + return self.build_from_git('url', cmd, 'pathname')
Instead of the 'cmd' variable here, can you just put ['target'] as the
function arg? Same below. It doesn't really add anything.
> return None
> diff --git a/tools/binman/btool/fiptool.py b/tools/binman/btool/fiptool.py
> index c80f8275c4..b275fee43b 100644
> --- a/tools/binman/btool/fiptool.py
> +++ b/tools/binman/btool/fiptool.py
> @@ -107,8 +107,10 @@ class Bintoolfiptool(bintool.Bintool):
> """
> if method != bintool.FETCH_BUILD:
> return None
> +
> + cmd = ['fiptool']
> result = self.build_from_git(
> 'https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git',
> - 'fiptool',
> + cmd,
> 'tools/fiptool/fiptool')
> return result
> diff --git a/tools/binman/btool/futility.py b/tools/binman/btool/futility.py
> index 04c9aefe9b..4b22547368 100644
> --- a/tools/binman/btool/futility.py
> +++ b/tools/binman/btool/futility.py
> @@ -168,9 +168,11 @@ class Bintoolfutility(bintool.Bintool):
> #
> # Unfortunately this requires logging in and obtaining a line for the
> # .gitcookies file. So use a mirror instead.
> +
> + cmd = ['all']
> result = self.build_from_git(
> 'https://github.com/sjg20/vboot_reference.git',
> - 'all',
> + cmd,
> 'build/futility/futility',
> flags=['USE_FLASHROM=0'])
> return result
> --
> 2.34.1
>
Regards,
Simon
More information about the U-Boot
mailing list