Skip to content

Commit

Permalink
Use the jq Python package
Browse files Browse the repository at this point in the history
  • Loading branch information
puddly committed Oct 29, 2024
1 parent ce99bc9 commit a562149
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ FROM debian:bookworm

ARG DEBIAN_FRONTEND=noninteractive

ENV PIP_ROOT_USER_ACTION=ignore

RUN \
apt-get update \
&& apt-get install -y --no-install-recommends \
Expand All @@ -16,9 +18,10 @@ RUN \
default-jre-headless \
patch \
python3 \
python3-ruamel.yaml \
python3-pip \
unzip \
xz-utils
xz-utils \
&& pip install jq ruamel.yaml

# Install Simplicity Commander (unfortunately no stable URL available, this
# is known to be working with Commander_linux_x86_64_1v15p0b1306.tar.bz).
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ tool will automatically determine which SDK and toolchain to use.
> automatically found so these flags can be omitted.
```bash
pip install ruamel.yaml # Only dependency
pip install jq ruamel.yaml

python tools/build_project.py \
# The following SDK and toolchain flags can be omitted on macOS
Expand Down
15 changes: 3 additions & 12 deletions tools/build_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import multiprocessing
from datetime import datetime, timezone

import jq
from ruamel.yaml import YAML


Expand Down Expand Up @@ -374,18 +375,8 @@ def main():
for json_config in manifest.get("json_config", []):
json_path = build_template_path / json_config["file"]

result = subprocess.run(
[
"jq",
json_config["jq"],
json_path,
],
capture_output=True,
check=True,
)

with open(json_path, "wb") as f:
f.write(result.stdout)
result = jq.compile(json_config["jq"]).input_text(json_path.read_text()).first()
json_path.write_text(json.dumps(result, indent=2))

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

0 comments on commit a562149

Please sign in to comment.