mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-26 07:17:10 +00:00
binman: build_from_git: Add optional make path inside git repo
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.anderweit@phytec.de> Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
5f2096d2bc
commit
b48bc41620
2 changed files with 8 additions and 2 deletions
|
@ -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
|
||||
|
|
|
@ -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'
|
||||
|
|
Loading…
Add table
Reference in a new issue