Merge "conv_linker_config proto works with empty input"

This commit is contained in:
Treehugger Robot
2023-03-06 18:36:10 +00:00
committed by Gerrit Code Review

View File

@@ -28,14 +28,15 @@ from google.protobuf.text_format import MessageToString
def Proto(args): def Proto(args):
pb = linker_config_pb2.LinkerConfig() pb = linker_config_pb2.LinkerConfig()
for input in args.source.split(':'): if args.source:
json_content = '' for input in args.source.split(':'):
with open(input) as f: json_content = ''
for line in f: with open(input) as f:
if not line.lstrip().startswith('//'): for line in f:
json_content += line if not line.lstrip().startswith('//'):
obj = json.loads(json_content, object_pairs_hook=collections.OrderedDict) json_content += line
ParseDict(obj, pb) obj = json.loads(json_content, object_pairs_hook=collections.OrderedDict)
ParseDict(obj, pb)
with open(args.output, 'wb') as f: with open(args.output, 'wb') as f:
f.write(pb.SerializeToString()) f.write(pb.SerializeToString())
@@ -104,7 +105,7 @@ def GetArgParser():
parser_proto.add_argument( parser_proto.add_argument(
'-s', '-s',
'--source', '--source',
required=True, nargs='?',
type=str, type=str,
help='Colon-separated list of linker configuration files in JSON.') help='Colon-separated list of linker configuration files in JSON.')
parser_proto.add_argument( parser_proto.add_argument(