Allow comments from linker.config.json
Filter out lines starts with "//" from json file to allow simple comments on the contents. Original json format does not support comments, but this reduces readability compared to txt file or other formats. This change allows simple comments on the linker.config.json to give more information on the contents. Test: parse succeeded with commented contents Change-Id: I1c734bf9a054f81f57aa2aea1038d0041297acf1
This commit is contained in:
@@ -25,8 +25,12 @@ from google.protobuf.text_format import MessageToString
|
||||
|
||||
|
||||
def Proto(args):
|
||||
json_content = ''
|
||||
with open(args.source) as f:
|
||||
obj = json.load(f, object_pairs_hook=collections.OrderedDict)
|
||||
for line in f:
|
||||
if not line.lstrip().startswith('//'):
|
||||
json_content += line
|
||||
obj = json.loads(json_content, object_pairs_hook=collections.OrderedDict)
|
||||
pb = ParseDict(obj, linker_config_pb2.LinkerConfig())
|
||||
with open(args.output, 'wb') as f:
|
||||
f.write(pb.SerializeToString())
|
||||
|
Reference in New Issue
Block a user