Rob Barnes has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/44834 )
Change subject: util/spd_tools: Support comments in json ......................................................................
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 robbarnes@google.com --- M util/spd_tools/intel/ddr4/gen_spd.go M util/spd_tools/intel/ddr4/global_ddr4_mem_parts.json.txt 2 files changed, 8 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/34/44834/1
diff --git a/util/spd_tools/intel/ddr4/gen_spd.go b/util/spd_tools/intel/ddr4/gen_spd.go index 5adadc9..0462fd5 100644 --- a/util/spd_tools/intel/ddr4/gen_spd.go +++ b/util/spd_tools/intel/ddr4/gen_spd.go @@ -12,6 +12,7 @@ "reflect" "strconv" "strings" + "regexp" )
/* @@ -998,6 +999,10 @@ 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/intel/ddr4/global_ddr4_mem_parts.json.txt b/util/spd_tools/intel/ddr4/global_ddr4_mem_parts.json.txt index 4e9c7c8..51068d5 100644 --- a/util/spd_tools/intel/ddr4/global_ddr4_mem_parts.json.txt +++ b/util/spd_tools/intel/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": [ {