build: Allow extra bitbake arguments to be passed
This allows the `kas build` command to be used when you need to pass extra arguments to bitbake. A `--` separator is needed when passing arguments which begin with a dash so that argparse doesn't try to parse them as kas further arguments. For example, to pass `--skip-setscene` to bitbake: kas build config.yml -- --skip-setscene Signed-off-by: Paul Barker <pbarker@konsulko.com> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
This commit is contained in:
parent
8fb8b1b1e1
commit
677c469fb5
10
kas/build.py
10
kas/build.py
@ -59,6 +59,9 @@ class Build:
|
|||||||
|
|
||||||
bld_psr.add_argument('config',
|
bld_psr.add_argument('config',
|
||||||
help='Config file')
|
help='Config file')
|
||||||
|
bld_psr.add_argument('extra_bitbake_args',
|
||||||
|
nargs='*',
|
||||||
|
help='Extra arguments to pass to bitbake')
|
||||||
bld_psr.add_argument('--target',
|
bld_psr.add_argument('--target',
|
||||||
action='append',
|
action='append',
|
||||||
help='Select target to build')
|
help='Select target to build')
|
||||||
@ -102,7 +105,7 @@ class Build:
|
|||||||
macro.add(WriteBBConfig())
|
macro.add(WriteBBConfig())
|
||||||
|
|
||||||
# Build
|
# Build
|
||||||
macro.add(BuildCommand())
|
macro.add(BuildCommand(args.extra_bitbake_args))
|
||||||
|
|
||||||
if 'SSH_PRIVATE_KEY' in os.environ:
|
if 'SSH_PRIVATE_KEY' in os.environ:
|
||||||
macro.add(CleanupSSHAgent())
|
macro.add(CleanupSSHAgent())
|
||||||
@ -117,8 +120,9 @@ class BuildCommand(Command):
|
|||||||
Implements the bitbake build step.
|
Implements the bitbake build step.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self, extra_bitbake_args):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
self.extra_bitbake_args = extra_bitbake_args
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return 'build'
|
return 'build'
|
||||||
@ -130,7 +134,7 @@ class BuildCommand(Command):
|
|||||||
# Start bitbake build of image
|
# Start bitbake build of image
|
||||||
bitbake = find_program(ctx.environ['PATH'], 'bitbake')
|
bitbake = find_program(ctx.environ['PATH'], 'bitbake')
|
||||||
cmd = ([bitbake, '-k', '-c', ctx.config.get_bitbake_task()]
|
cmd = ([bitbake, '-k', '-c', ctx.config.get_bitbake_task()]
|
||||||
+ ctx.config.get_bitbake_targets())
|
+ self.extra_bitbake_args + ctx.config.get_bitbake_targets())
|
||||||
if sys.stdout.isatty():
|
if sys.stdout.isatty():
|
||||||
logging.info('%s$ %s', ctx.build_dir, ' '.join(cmd))
|
logging.info('%s$ %s', ctx.build_dir, ' '.join(cmd))
|
||||||
ret = subprocess.call(cmd, env=ctx.environ, cwd=ctx.build_dir)
|
ret = subprocess.call(cmd, env=ctx.environ, cwd=ctx.build_dir)
|
||||||
|
Loading…
Reference in New Issue
Block a user