From 4ee686ddca07cb9cc2df05a73877e011cafa123e Mon Sep 17 00:00:00 2001 From: Kiyoung Kim Date: Thu, 3 Dec 2020 15:20:07 +0900 Subject: [PATCH] Add 'append' command for conv_linker_config Add 'append' command for conv_linker_config so any item can be appended to linker.config.pb file. Bug: 174646355 Test: buildbot_build.sh succeeded Change-Id: Ic3f12ee5e5c0e7ca7c27d4a8cff347e93061eb5f --- scripts/conv_linker_config.py | 41 +++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/scripts/conv_linker_config.py b/scripts/conv_linker_config.py index fca71ad56..22fe9f671 100644 --- a/scripts/conv_linker_config.py +++ b/scripts/conv_linker_config.py @@ -64,6 +64,21 @@ def SystemProvide(args): f.write(pb.SerializeToString()) +def Append(args): + pb = linker_config_pb2.LinkerConfig() + with open(args.source, 'rb') as f: + pb.ParseFromString(f.read()) + + if getattr(type(pb), args.key).DESCRIPTOR.label == FieldDescriptor.LABEL_REPEATED: + for value in args.value.split(): + getattr(pb, args.key).append(value) + else: + setattr(pb, args.key, args.value) + + with open(args.output, 'wb') as f: + f.write(pb.SerializeToString()) + + def GetArgParser(): parser = argparse.ArgumentParser() subparsers = parser.add_subparsers() @@ -120,6 +135,32 @@ def GetArgParser(): help='Path of the system image.') system_provide_libs.set_defaults(func=SystemProvide) + append = subparsers.add_parser( + 'append', help='Append value(s) to given key.') + append.add_argument( + '-s', + '--source', + required=True, + type=str, + help='Source linker configuration file in protobuf.') + append.add_argument( + '-o', + '--output', + required=True, + type=str, + help='Target linker configuration file to write in protobuf.') + append.add_argument( + '--key', + required=True, + type=str, + help='.') + append.add_argument( + '--value', + required=True, + type=str, + 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) + return parser