Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e52c665d authored by Kiyoung Kim's avatar Kiyoung Kim
Browse files

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
parent e83dea5a
Loading
Loading
Loading
Loading
+5 −1
Original line number Original line Diff line number Diff line
@@ -25,8 +25,12 @@ from google.protobuf.text_format import MessageToString




def Proto(args):
def Proto(args):
  json_content = ''
  with open(args.source) as f:
  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())
  pb = ParseDict(obj, linker_config_pb2.LinkerConfig())
  with open(args.output, 'wb') as f:
  with open(args.output, 'wb') as f:
    f.write(pb.SerializeToString())
    f.write(pb.SerializeToString())