summaryrefslogtreecommitdiff
path: root/scripts/conv_linker_config.py
diff options
context:
space:
mode:
author Jooyung Han <jooyung@google.com> 2023-03-04 08:28:40 +0900
committer Jooyung Han <jooyung@google.com> 2023-03-04 08:28:40 +0900
commitb531beecd549d098c9672df72886d88165c4ffe3 (patch)
tree1c6969ff649a413eb51deb97abd27503fad35b74 /scripts/conv_linker_config.py
parentaa3408a50648c6076d9cc3542523b01e83c11b28 (diff)
conv_linker_config proto works with empty input
PRODUCT_VENDOR_LINKER_CONFIG_FRAGMENTS lists json files for vendor linker config. It's annoying to handle the case of empty list. `proto` subcommand now works for empty input. This is useful to generate the empty linker config. Bug: 244531518 Test: conv_linker_config proto --source --output output.pb Change-Id: Iec6de67a979814a818730c393d9a4a7ca5d2eebe
Diffstat (limited to 'scripts/conv_linker_config.py')
-rw-r--r--scripts/conv_linker_config.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/scripts/conv_linker_config.py b/scripts/conv_linker_config.py
index 3d7c0faa4..2ce0ee2be 100644
--- a/scripts/conv_linker_config.py
+++ b/scripts/conv_linker_config.py
@@ -28,14 +28,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(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)
- ParseDict(obj, pb)
+ if args.source:
+ for input in args.source.split(':'):
+ json_content = ''
+ 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)
+ ParseDict(obj, pb)
with open(args.output, 'wb') as f:
f.write(pb.SerializeToString())
@@ -104,7 +105,7 @@ def GetArgParser():
parser_proto.add_argument(
'-s',
'--source',
- required=True,
+ nargs='?',
type=str,
help='Colon-separated list of linker configuration files in JSON.')
parser_proto.add_argument(