Add optional argument make_path to build_from git. The new argument allows specifying the path to a Makefile in case it is not in the root of the git repo. Also adjust the corresponding test.
Signed-off-by: Leonard Anderweit <l.anderw...@phytec.de> --- v2: fix tests --- tools/binman/bintool.py | 9 +++++++-- tools/binman/bintool_test.py | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/tools/binman/bintool.py b/tools/binman/bintool.py index 7280ee4f8cd9..81872db377f9 100644 --- a/tools/binman/bintool.py +++ b/tools/binman/bintool.py @@ -329,7 +329,7 @@ class Bintool: @classmethod def build_from_git(cls, git_repo, make_targets, bintool_path, - flags=None, git_branch=None): + flags=None, git_branch=None, make_path=None): """Build a bintool from a git repo This clones the repo in a temporary directory, builds it with 'make', @@ -343,6 +343,8 @@ class Bintool: build is complete flags (list of str): Flags or variables to pass to make, or None git_branch (str): Branch of git repo, or None to use the default + make_path (str): Relative path inside git repo containing the + Makefile, or None Returns: tuple: @@ -359,7 +361,10 @@ class Bintool: tools.run('git', 'clone', '--depth', '1', git_repo, tmpdir) for target in make_targets: print(f"- build target '{target}'") - cmd = ['make', '-C', tmpdir, '-j', f'{multiprocessing.cpu_count()}', + makedir = tmpdir + if make_path: + makedir = os.path.join(tmpdir, make_path) + cmd = ['make', '-C', makedir, '-j', f'{multiprocessing.cpu_count()}', target] if flags: cmd += flags diff --git a/tools/binman/bintool_test.py b/tools/binman/bintool_test.py index f9b16d4c73b5..949d6f4c8a90 100644 --- a/tools/binman/bintool_test.py +++ b/tools/binman/bintool_test.py @@ -303,6 +303,7 @@ class TestBintool(unittest.TestCase): # See Bintool.build_from_git() tmpdir = cmd[2] self.fname = os.path.join(tmpdir, 'pathname') + os.makedirs(os.path.dirname(tmpdir), exist_ok=True) tools.write_file(self.fname, b'hello') expected = b'this is a test' -- 2.34.1