From a2e431331cbbad167efa1524e42a863a49e03a14 Mon Sep 17 00:00:00 2001 From: Rob Barnes Date: Wed, 26 Aug 2020 09:56:37 -0600 Subject: util/spd_tools: Support comments in json Allow comments in json file for better documentation. Comments must be on seperate line. BUG=none TEST=Injest global_ddr4_mem_parts.json.txt with comments Change-Id: I51295408d4f916708e4ed5bc42d5468ccdc68a6b Signed-off-by: Rob Barnes Reviewed-on: https://review.coreboot.org/c/coreboot/+/44834 Tested-by: build bot (Jenkins) Reviewed-by: Furquan Shaikh --- util/spd_tools/ddr4/gen_spd.go | 5 +++++ util/spd_tools/ddr4/global_ddr4_mem_parts.json.txt | 3 +++ 2 files changed, 8 insertions(+) diff --git a/util/spd_tools/ddr4/gen_spd.go b/util/spd_tools/ddr4/gen_spd.go index 5adadc962a..0462fd5056 100644 --- a/util/spd_tools/ddr4/gen_spd.go +++ b/util/spd_tools/ddr4/gen_spd.go @@ -12,6 +12,7 @@ import ( "reflect" "strconv" "strings" + "regexp" ) /* @@ -998,6 +999,10 @@ func readMemoryParts(memParts *memParts, memPartsFileName string) error { return err } + // Strip comments from json file + re := regexp.MustCompile(`(?m)^\s*//.*`) + databytes = re.ReplaceAll(databytes, []byte("")) + return json.Unmarshal(databytes, memParts) } diff --git a/util/spd_tools/ddr4/global_ddr4_mem_parts.json.txt b/util/spd_tools/ddr4/global_ddr4_mem_parts.json.txt index 4e9c7c8e95..51068d5154 100644 --- a/util/spd_tools/ddr4/global_ddr4_mem_parts.json.txt +++ b/util/spd_tools/ddr4/global_ddr4_mem_parts.json.txt @@ -1,3 +1,6 @@ +// Global list of ddr4 memory part attributes. +// These attributes match the part specifications and are independent +// of any SoC expectations. { "parts": [ { -- cgit v1.2.3