groupgen.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/usr/bin/env python3
  2. # Copyright (C) 2018 RDA Technologies Limited and/or its affiliates("RDA").
  3. # All rights reserved.
  4. #
  5. # This software is supplied "AS IS" without any warranties.
  6. # RDA assumes no responsibility or liability for the use of the software,
  7. # conveys no license or title under any patent, copyright, or mask work
  8. # right to the product. RDA reserves the right to make changes in the
  9. # software without notification. RDA also make no representation or
  10. # warranty that such application will be suitable for the specified use
  11. # without further testing or modification.
  12. import argparse
  13. import sys
  14. import os
  15. def main(argv):
  16. parser = argparse.ArgumentParser(
  17. description='generate group linker script')
  18. parser.add_argument('--base', dest='base', default=None,
  19. help='base directory of libraries')
  20. parser.add_argument('output', help='output file name')
  21. parser.add_argument('libs', nargs='+',
  22. help='library file names')
  23. args = parser.parse_args(argv)
  24. libs = args.libs
  25. if args.base:
  26. libs = [os.path.relpath(x, args.base) for x in libs]
  27. with open(args.output, 'w') as fh:
  28. fh.write('GROUP(\n' + '\n'.join(libs) + ')\n')
  29. return 0
  30. if __name__ == "__main__":
  31. sys.exit(main(sys.argv[1:]))