Archived
3
0
This repository has been archived on 2025-09-02. You can view files and clone it, but cannot push or open issues or pull requests.
Files
zmp24-docs/lib/config.mk
Ondřej Mekina 5513042b1b
Some checks failed
Check indentation / build (push) Has been cancelled
Continuous testing / build (push) Has been cancelled
extract config to external files
2025-03-12 23:08:40 +01:00

12 lines
913 B
Makefile

JQ_INTO_TOML := '.prod|to_entries.[]|if (.value | type == "object") then "\n[" + .key + "]\n" + (.value|to_entries.[] | if (.value | type == "string") then .key + " = \"" + (.value|tostring) + "\"" else .key + " = " + (.value|tostring) end) + "\n" else if (.value | type == "string") then .key + " = \"" + (.value|tostring) + "\"" else .key + " = " + (.value|tostring) end end'
define to_toml
jq -r '.$(1)|to_entries.[]|if (.value | type == "object") then "\n[" + .key + "]\n" + (.value|to_entries.[] | if (.value | type == "string") then .key + " = \"" + (.value|tostring) + "\"" else .key + " = " + (.value|tostring) end) + "\n" else if (.value | type == "string") then .key + " = \"" + (.value|tostring) + "\"" else .key + " = " + (.value|tostring) end end' $(2) > $(3)
endef
dst/dev_config.toml: config.json dst
$(call to_toml,dev,$<,$@)
dst/prod_config.toml: config.json dst
$(call to_toml,prod,$<,$@)