Merge "Do not allow a module exists both in provideLibs and requireLibs" into main
This commit is contained in:
@@ -62,8 +62,8 @@ def Proto(args):
|
|||||||
if args.source:
|
if args.source:
|
||||||
for input in args.source.split(':'):
|
for input in args.source.split(':'):
|
||||||
pb.MergeFrom(LoadJsonMessage(input))
|
pb.MergeFrom(LoadJsonMessage(input))
|
||||||
with open(args.output, 'wb') as f:
|
|
||||||
f.write(pb.SerializeToString())
|
ValidateAndWriteAsPbFile(pb, args.output)
|
||||||
|
|
||||||
|
|
||||||
def Print(args):
|
def Print(args):
|
||||||
@@ -90,8 +90,8 @@ def SystemProvide(args):
|
|||||||
for item in installed_libraries:
|
for item in installed_libraries:
|
||||||
if item not in getattr(pb, 'provideLibs'):
|
if item not in getattr(pb, 'provideLibs'):
|
||||||
getattr(pb, 'provideLibs').append(item)
|
getattr(pb, 'provideLibs').append(item)
|
||||||
with open(args.output, 'wb') as f:
|
|
||||||
f.write(pb.SerializeToString())
|
ValidateAndWriteAsPbFile(pb, args.output)
|
||||||
|
|
||||||
|
|
||||||
def Append(args):
|
def Append(args):
|
||||||
@@ -106,8 +106,8 @@ def Append(args):
|
|||||||
else:
|
else:
|
||||||
setattr(pb, args.key, args.value)
|
setattr(pb, args.key, args.value)
|
||||||
|
|
||||||
with open(args.output, 'wb') as f:
|
ValidateAndWriteAsPbFile(pb, args.output)
|
||||||
f.write(pb.SerializeToString())
|
|
||||||
|
|
||||||
|
|
||||||
def Merge(args):
|
def Merge(args):
|
||||||
@@ -116,8 +116,7 @@ def Merge(args):
|
|||||||
with open(other, 'rb') as f:
|
with open(other, 'rb') as f:
|
||||||
pb.MergeFromString(f.read())
|
pb.MergeFromString(f.read())
|
||||||
|
|
||||||
with open(args.out, 'wb') as f:
|
ValidateAndWriteAsPbFile(pb, args.output)
|
||||||
f.write(pb.SerializeToString())
|
|
||||||
|
|
||||||
|
|
||||||
def Validate(args):
|
def Validate(args):
|
||||||
@@ -151,6 +150,29 @@ def Validate(args):
|
|||||||
sys.exit(f'Unknown type: {args.type}')
|
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():
|
def GetArgParser():
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
subparsers = parser.add_subparsers()
|
subparsers = parser.add_subparsers()
|
||||||
|
Reference in New Issue
Block a user