diff options
author | 2021-04-15 05:13:34 +0900 | |
---|---|---|
committer | 2021-04-15 10:58:21 +0900 | |
commit | e134d09831f4974be7ebe4ae6acc9687be3bd459 (patch) | |
tree | 8b59056c9fad867571da227e0fed905f1883c2a9 /scripts/conv_linker_config.py | |
parent | a0436a3928e604ec57f240014c33e3844a2d7d73 (diff) |
Add 'merge' command to conv_linker_config
'merge' command can merge multiple configurations.
It just delegates protobuf's msg.MergeFrom(other_msg).
usage: conv_linker_config merge -o out.pb -i a.pb -i b.pb ...
out.pb will have all keys from multiple inputs.
Bug: 181093750
Test: m
Test: MicrodroidTestCase
Change-Id: Ibf715aa0bcc1e5c82c85a9af8fe7dca8d6ab68ad
Diffstat (limited to 'scripts/conv_linker_config.py')
-rw-r--r-- | scripts/conv_linker_config.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/scripts/conv_linker_config.py b/scripts/conv_linker_config.py index 22fe9f671..92f79dae8 100644 --- a/scripts/conv_linker_config.py +++ b/scripts/conv_linker_config.py @@ -78,6 +78,14 @@ def Append(args): with open(args.output, 'wb') as f: f.write(pb.SerializeToString()) +def Merge(args): + pb = linker_config_pb2.LinkerConfig() + for other in args.input: + with open(other, 'rb') as f: + pb.MergeFromString(f.read()) + + with open(args.out, 'wb') as f: + f.write(pb.SerializeToString()) def GetArgParser(): parser = argparse.ArgumentParser() @@ -161,6 +169,22 @@ def GetArgParser(): help='Values of the libraries to append. If there are more than one it should be separated by empty space') append.set_defaults(func=Append) + append = subparsers.add_parser( + 'merge', help='Merge configurations') + append.add_argument( + '-o', + '--out', + required=True, + type=str, + help='Ouptut linker configuration file to write in protobuf.') + append.add_argument( + '-i', + '--input', + nargs='+', + type=str, + help='Linker configuration files to merge.') + append.set_defaults(func=Merge) + return parser |