Merge "Do not allow a module exists both in provideLibs and requireLibs" into main am: f2fd12d97c am: 25ee09b5b6 am: 9b31abbd26

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2762828

Change-Id: Ie74e276644dd93a36b9bb898f5a21bd27b3f30e8
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Kiyoung Kim 2023-10-05 05:29:21 +00:00 committed by Automerger Merge Worker
commit 75e9b19848

View file

@ -62,8 +62,8 @@ def Proto(args):
if args.source:
for input in args.source.split(':'):
pb.MergeFrom(LoadJsonMessage(input))
with open(args.output, 'wb') as f:
f.write(pb.SerializeToString())
ValidateAndWriteAsPbFile(pb, args.output)
def Print(args):
@ -90,8 +90,8 @@ def SystemProvide(args):
for item in installed_libraries:
if item not in getattr(pb, 'provideLibs'):
getattr(pb, 'provideLibs').append(item)
with open(args.output, 'wb') as f:
f.write(pb.SerializeToString())
ValidateAndWriteAsPbFile(pb, args.output)
def Append(args):
@ -106,8 +106,8 @@ def Append(args):
else:
setattr(pb, args.key, args.value)
with open(args.output, 'wb') as f:
f.write(pb.SerializeToString())
ValidateAndWriteAsPbFile(pb, args.output)
def Merge(args):
@ -116,8 +116,7 @@ def Merge(args):
with open(other, 'rb') as f:
pb.MergeFromString(f.read())
with open(args.out, 'wb') as f:
f.write(pb.SerializeToString())
ValidateAndWriteAsPbFile(pb, args.output)
def Validate(args):
@ -151,6 +150,29 @@ def Validate(args):
sys.exit(f'Unknown type: {args.type}')
def ValidateAndWriteAsPbFile(pb, output_path):
ValidateConfiguration(pb)
with open(output_path, 'wb') as f:
f.write(pb.SerializeToString())
def ValidateConfiguration(pb):
"""
Validate if the configuration is valid to be used as linker configuration
"""
# Validate if provideLibs and requireLibs have common module
provideLibs = set(getattr(pb, 'provideLibs'))
requireLibs = set(getattr(pb, 'requireLibs'))
intersectLibs = provideLibs.intersection(requireLibs)
if intersectLibs:
for lib in intersectLibs:
print(f'{lib} exists both in requireLibs and provideLibs', file=sys.stderr)
sys.exit(1)
def GetArgParser():
parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers()