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:
Kiyoung Kim
2020-10-23 11:00:25 +09:00
parent e83dea5aac
commit e52c665d7f

View File

@@ -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())