[OpenWrt-Devel] [PATCH v2] build: refactor JSON info files to `profiles.json`
Petr Štetiar
ynezz at true.cz
Sun Mar 1 07:34:33 EST 2020
Paul Spooren <mail at aparcar.org> [2020-02-29 16:48:50]:
FYI:
$ grep JSON .config
CONFIG_JSON_OVERVIEW_IMAGE_INFO=y
$ cat bin/targets/imx6/generic/profiles.json
{}
> diff --git a/config/Config-build.in b/config/Config-build.in
> index 6a6fb2882c..57428399ab 100644
> --- a/config/Config-build.in
> +++ b/config/Config-build.in
> @@ -7,12 +7,14 @@
>
> menu "Global build settings"
>
> - config JSON_ADD_IMAGE_INFO
> - bool "Create JSON info files per build image"
> + config JSON_OVERVIEW_IMAGE_INFO
> + bool "Create JSON info file overview per target"
> default BUILDBOT
> + select JSON_CREATE_IMAGE_INFO
This is probably some leftover.
> diff --git a/include/image.mk b/include/image.mk
> index fd04d4020b..933d844e8e 100644
> --- a/include/image.mk
> +++ b/include/image.mk
> @@ -568,9 +568,9 @@ define Device/Build/image
>
> $(BIN_DIR)/$(call IMAGE_NAME,$(1),$(2)): $(KDIR)/tmp/$(call IMAGE_NAME,$(1),$(2))
> cp $$^ $$@
> - $(if $(CONFIG_JSON_ADD_IMAGE_INFO), \
> + $(if $(CONFIG_JSON_OVERVIEW_IMAGE_INFO), \
> DEVICE_ID="$(DEVICE_NAME)" \
> - BIN_DIR="$(BIN_DIR)" \
> + BIN_DIR="$(KDIR)/tmp" \
> IMAGE_NAME="$(IMAGE_NAME)" \
> IMAGE_TYPE=$(word 1,$(subst ., ,$(2))) \
> IMAGE_PREFIX="$(IMAGE_PREFIX)" \
Unhandled remark from v1, this part still needs some work, when that Python
script fails, the build should fail. Reproducer:
echo borken > scripts/json_add_image_info.py; make
> +output_json = {}
> +
> +assert target_dir, "Target directory required"
> +
> +for json_file in input_dir.glob("*.json"):
> + profile_info = json.loads(json_file.read_text())
> + if not output_json:
> + output_json = {
> + "metadata_version": 1,
> + "target": profile_info["target"],
> + "version_commit": profile_info["version_commit"],
> + "version_number": profile_info["version_number"],
> + "profiles": {},
> + }
I'm not a Pythonista, but perhaps you want to init the output_json dict just a
few lines above and get rid of that unnecesary if.
-- ynezz
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list