[OpenWrt-Devel] [PATCH v2] build: refactor JSON info files to `profiles.json`

Paul Spooren mail at aparcar.org
Sun Mar 1 19:10:16 EST 2020


On 01.03.20 02:34, Petr Štetiar wrote:
> 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
>   {}

This problem occurs also fox x86, the problem is that the image function 
is not properly called. Maybe because IMX6 only offer a default target 
but no profiles, resulting in an empty profiles.json file - I think. I 
started (based on Lynxis draft) reworking the x86 so it creates also 
JSON files[0].

I'd be in favor reworking (unifying) the target specific code instead of 
extending the script logic to handle corner cases. At least if reworking 
is something what should be done anyway.

>> 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.
Yes! Removed in v3 thanks!
>> 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
I tried adding things like `|| exit 1` but make stubbornly keeps going. 
Can you help me out here please?
>> +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.
The `profile_info` variable is only available after reading the first 
JSON profile and therefore in the loop.

[0]: https://github.com/openwrt/openwrt/pull/2772


_______________________________________________
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