conv_linker_config proto supports multiple input json files
conv_linker_config proto -s input1.json:input2.json generates a merged proto output file. Bug: 264330513 Test: conv_linker_config proto -s input1.json:input2.json Change-Id: I4806fc606d115c42a1c745fba67960ce6db8c8d7
This commit is contained in:
@@ -27,13 +27,15 @@ from google.protobuf.text_format import MessageToString
|
||||
|
||||
|
||||
def Proto(args):
|
||||
pb = linker_config_pb2.LinkerConfig()
|
||||
for input in args.source.split(':'):
|
||||
json_content = ''
|
||||
with open(args.source) as f:
|
||||
with open(input) as f:
|
||||
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())
|
||||
ParseDict(obj, pb)
|
||||
with open(args.output, 'wb') as f:
|
||||
f.write(pb.SerializeToString())
|
||||
|
||||
@@ -104,7 +106,7 @@ def GetArgParser():
|
||||
'--source',
|
||||
required=True,
|
||||
type=str,
|
||||
help='Source linker configuration file in JSON.')
|
||||
help='Colon-separated list of linker configuration files in JSON.')
|
||||
parser_proto.add_argument(
|
||||
'-o',
|
||||
'--output',
|
||||
|
Reference in New Issue
Block a user