Skip to content

Commit 15471bf

Browse files
committed
Add MGOS_FW_EXTRA_ATTRS, a way to add extra manifest attributes
```yaml build_var: MGOS_FW_EXTRA_ATTRS: x=y a=1 b=true ``` will add extra attributes to manifest: ```json { x: "y", a: 1, b: true } ```
1 parent 4d31e09 commit 15471bf

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

tools/mgos_fw_meta.py

+16
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,21 @@ def cmd_create_manifest(args):
330330
if k in bi:
331331
manifest[k] = bi[k]
332332

333+
for e in args.extra_attr:
334+
if not e:
335+
continue
336+
k, v = e.split('=', 1)
337+
if v in ('true', 'false'):
338+
v = (v == 'true')
339+
elif v == 'null':
340+
v = None
341+
else:
342+
try:
343+
v = int(v, 0)
344+
except ValueError:
345+
pass
346+
manifest[k] = v
347+
333348
for p in args.parts:
334349
name, attrs = p.split(':', 2)
335350
part = {}
@@ -508,6 +523,7 @@ def cmd_xxd(args):
508523
cm_cmd.add_argument('--src_dir', default='.')
509524
cm_cmd.add_argument('--staging_dir')
510525
cm_cmd.add_argument('--output', '-o')
526+
cm_cmd.add_argument('--extra-attr', metavar='extra_attrs', default=[], action='append')
511527
cm_cmd.add_argument('parts', nargs='+')
512528
handlers['create_manifest'] = cmd_create_manifest
513529

tools/mk/mgos_fw_meta.mk

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
FW_MANIFEST ?= $(FW_STAGING_DIR)/manifest.json
1010
FW_ZIP ?= $(FW_DIR)/$(APP)-$(APP_PLATFORM)-last.zip
1111
FW_META_CMD ?= $(MGOS_PATH)/tools/mgos_fw_meta.py
12+
MGOS_FW_EXTRA_ATTRS ?=
1213

1314
$(FW_ZIP): $(FW_MANIFEST) $(FW_META_CMD)
1415
$(vecho) "ZIP $@"
@@ -24,6 +25,7 @@ $(FW_MANIFEST): $(FW_META_CMD)
2425
$(Q) $(FW_META_CMD) create_manifest \
2526
--name=$(APP) --platform=$(APP_PLATFORM) \
2627
--build_info=$(BUILD_INFO_JSON) \
28+
$(addprefix --extra-attr=,$(MGOS_FW_EXTRA_ATTRS)) \
2729
--staging_dir=$(FW_STAGING_DIR) \
2830
--output=$(FW_MANIFEST) \
2931
$(FW_PARTS)

0 commit comments

Comments
 (0)