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> Reviewed-on: https://review.coreboot.org/c/coreboot/+/44834 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Furquan Shaikh <furquan@google.com>
This commit is contained in:
		
				
					committed by
					
						
						Furquan Shaikh
					
				
			
			
				
	
			
			
			
						parent
						
							196e9c0021
						
					
				
				
					commit
					a2e431331c
				
			@@ -12,6 +12,7 @@ import (
 | 
				
			|||||||
	"reflect"
 | 
						"reflect"
 | 
				
			||||||
	"strconv"
 | 
						"strconv"
 | 
				
			||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
 | 
						"regexp"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
@@ -998,6 +999,10 @@ func readMemoryParts(memParts *memParts, memPartsFileName string) error {
 | 
				
			|||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// Strip comments from json file
 | 
				
			||||||
 | 
						re := regexp.MustCompile(`(?m)^\s*//.*`)
 | 
				
			||||||
 | 
						databytes = re.ReplaceAll(databytes, []byte(""))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return json.Unmarshal(databytes, memParts)
 | 
						return json.Unmarshal(databytes, memParts)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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": [
 | 
					    "parts": [
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user