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

Improve subprocess run logging #88

Merged
merged 4 commits into from
Oct 30, 2024
Merged
Changes from 1 commit
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
21 changes: 18 additions & 3 deletions tools/build_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
yaml = YAML(typ="safe")


def log_subprocess_output(pipe, prefix: str = "subprocess"):
for line in iter(pipe.readline, b""):
LOGGER.info("[%s] %r", prefix, line)


def evaulate_f_string(f_string: str, variables: dict[str, typing.Any]) -> str:
"""
Evaluates an `f`-string with the given locals.
Expand Down Expand Up @@ -371,10 +376,10 @@ def main():
yaml.dump(manifest["gbl"], f)

# Next, generate a chip-specific project from the modified base project
print(f"Generating project for {manifest['device']}")
LOGGER.info(f"Generating project for {manifest['device']}")

# fmt: off
subprocess.run(
slc_result = subprocess.Popen(
puddly marked this conversation as resolved.
Show resolved Hide resolved
SLC
+ [
"generate",
Expand All @@ -387,10 +392,20 @@ def main():
"--sdk", sdk,
"--output-type", args.build_system,
],
check=True,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT
)
# fmt: on

with slc_result.stdout:
log_subprocess_output(slc_result.stdout, "SLC generate")

slc_result_returncode = slc_result.wait()

if slc_result_returncode != 0:
LOGGER.error("[SLC generate] Error: %s", slc_result_returncode)
sys.exit(1)

# Make sure all extensions are valid
for sdk_extension in base_project.get("sdk_extension", []):
expected_dir = sdk / f"extension/{sdk_extension['id']}_extension"
Expand Down