Skip to content
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

Add verbose flag to build_examples.py #37894

Merged
merged 1 commit into from
Mar 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions scripts/build/build/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ class Context:
to generate make/ninja instructions and to compile.
"""

def __init__(self, runner, repository_path: str, output_prefix: str, ninja_jobs: int):
def __init__(self, runner, repository_path: str, output_prefix: str, verbose: bool, ninja_jobs: int):
self.builders = []
self.runner = runner
self.repository_path = repository_path
self.output_prefix = output_prefix
self.verbose = verbose
self.ninja_jobs = ninja_jobs
self.completed_steps = set()

Expand All @@ -38,7 +39,8 @@ def SetupBuilders(self, targets: Sequence[str], options: BuilderOptions):
found = False
for choice in BUILD_TARGETS:
builder = choice.Create(target, self.runner, self.repository_path,
self.output_prefix, self.ninja_jobs, options)
self.output_prefix, self.verbose, self.ninja_jobs,
options)
if builder:
self.builders.append(builder)
found = True
Expand Down
3 changes: 2 additions & 1 deletion scripts/build/build/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ def StringIntoTargetParts(self, value: str):
return _StringIntoParts(value, suffix, self.fixed_targets, self.modifiers)

def Create(self, name: str, runner, repository_path: str, output_prefix: str,
ninja_jobs: int, builder_options: BuilderOptions):
verbose: bool, ninja_jobs: int, builder_options: BuilderOptions):

parts = self.StringIntoTargetParts(name)

Expand All @@ -406,6 +406,7 @@ def Create(self, name: str, runner, repository_path: str, output_prefix: str,
builder.target = self
builder.identifier = name
builder.output_dir = os.path.join(output_prefix, name)
builder.verbose = verbose
builder.ninja_jobs = ninja_jobs
builder.chip_dir = os.path.abspath(repository_path)
builder.options = builder_options
Expand Down
11 changes: 9 additions & 2 deletions scripts/build/build_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ def ValidateTargetNames(context, parameter, values):
default='INFO',
type=click.Choice(__LOG_LEVELS__.keys(), case_sensitive=False),
help='Determines the verbosity of script output.')
@click.option(
'--verbose',
default=False,
is_flag=True,
help='Pass verbose flag to ninja.')
@click.option(
'--target',
default=[],
Expand Down Expand Up @@ -142,7 +147,7 @@ def ValidateTargetNames(context, parameter, values):
'Set pigweed command launcher. E.g.: "--pw-command-launcher=ccache" '
'for using ccache when building examples.'))
@click.pass_context
def main(context, log_level, target, enable_link_map_file, repo,
def main(context, log_level, verbose, target, enable_link_map_file, repo,
out_prefix, ninja_jobs, pregen_dir, clean, dry_run, dry_run_output,
enable_flashbundle, no_log_timestamps, pw_command_launcher):
# Ensures somewhat pretty logging of what is going on
Expand All @@ -168,7 +173,9 @@ def main(context, log_level, target, enable_link_map_file, repo,
logging.info('Building targets: %s', CommaSeparate(requested_targets))

context.obj = build.Context(
repository_path=repo, output_prefix=out_prefix, ninja_jobs=ninja_jobs, runner=runner)
repository_path=repo, output_prefix=out_prefix, verbose=verbose,
ninja_jobs=ninja_jobs, runner=runner
)
context.obj.SetupBuilders(targets=requested_targets, options=BuilderOptions(
enable_link_map_file=enable_link_map_file,
enable_flashbundle=enable_flashbundle,
Expand Down
2 changes: 2 additions & 0 deletions scripts/build/builders/gn.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ def _build(self):
self.PreBuildCommand()

cmd = ['ninja', '-C', self.output_dir]
if self.verbose:
cmd.append('-v')
if self.ninja_jobs is not None:
cmd.append('-j' + str(self.ninja_jobs))
if self.build_command:
Expand Down
Loading