-
Notifications
You must be signed in to change notification settings - Fork 8k
scripts: flash: Add west config for flash skip rebuild #96115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -143,7 +143,9 @@ def add_parser_common(command, parser_adder=None, parser=None): | |||||||||
group.add_argument('-r', '--runner', | ||||||||||
help='override default runner from --build-dir') | ||||||||||
group.add_argument('--skip-rebuild', action='store_true', | ||||||||||
help='do not refresh cmake dependencies first') | ||||||||||
help='(deprecated) do not refresh cmake dependencies first') | ||||||||||
group.add_argument('--rebuild', action=argparse.BooleanOptionalAction, | ||||||||||
help='manually specify to refresh cmake dependencies or not') | ||||||||||
group.add_argument('--domain', action='append', | ||||||||||
help='execute runner only for given domain') | ||||||||||
|
||||||||||
|
@@ -244,8 +246,7 @@ def do_run_common(command, user_args, user_runner_args, domain_file=None): | |||||||||
) | ||||||||||
|
||||||||||
build_dir = get_build_dir(user_args) | ||||||||||
if not user_args.skip_rebuild: | ||||||||||
rebuild(command, build_dir, user_args) | ||||||||||
rebuild(command, build_dir, user_args) | ||||||||||
|
||||||||||
domains = get_domains_to_process(build_dir, user_args, domain_file) | ||||||||||
|
||||||||||
|
@@ -568,6 +569,18 @@ def load_cmake_cache(build_dir, args): | |||||||||
log.die(f'no CMake cache found (expected one at {cache_file})') | ||||||||||
|
||||||||||
def rebuild(command, build_dir, args): | ||||||||||
if args.rebuild is False: | ||||||||||
return | ||||||||||
|
||||||||||
if args.skip_rebuild: | ||||||||||
log.wrn("--skip-rebuild is deprecated. Please use --no-rebuild instead") | ||||||||||
return | ||||||||||
|
||||||||||
rebuild_config = config.getboolean(command.name, 'rebuild', fallback=True) | ||||||||||
|
||||||||||
if not rebuild_config and not args.rebuild: | ||||||||||
return | ||||||||||
Comment on lines
+581
to
+582
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is a bit easier to read and understand (the config should only be taken into account if the command line argument isn't specified):
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For situations like this I find it even clearer to add some new Something like this: def rebuild_wanted():
if args.rebuild is not None:
return args.rebuild
if rebuild_config is not None:
return rebuild_config
return True
def rebuild(command, build_dir, args):
if not rebuild_wanted()
return
... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "not" will be true if it is None or False. I'm not clear why you want to change from that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They have the same result, but the way I suggested it, is how I would explain it in words: It might be just me, but I had to read your statement a few times more to understand. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Generally speaking you cannot treat There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. args.rebuild can be None (if not specified on command line) or False (if --no-rebuild was specified). Therefore I think using 'not args.rebuild' is correct here. I would just change the order (but it is only personal favor): Or even better what @marc-hb proposed: add a new method rebuild_wanted() |
||||||||||
|
||||||||||
_banner(f'west {command.name}: rebuilding') | ||||||||||
try: | ||||||||||
zcmake.run_build(build_dir) | ||||||||||
|
@@ -723,7 +736,7 @@ def dump_context(command, args, unknown_args): | |||||||||
get_all_domain = True | ||||||||||
|
||||||||||
# Re-build unless asked not to, to make sure the output is up to date. | ||||||||||
if build_dir and not args.skip_rebuild: | ||||||||||
if build_dir: | ||||||||||
rebuild(command, build_dir, args) | ||||||||||
|
||||||||||
domains = get_domains_to_process(build_dir, args, None, get_all_domain) | ||||||||||
|
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe some parameterized test for this function would make sense to test all combinations of
args.rebuild
(True
,False
,None
),args.skip_rebuild
(True
/False
) andconfig_rebuild
(True
/False
/None
) versus the truth table.