js_library.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. # Copyright 2017 The Chromium Authors. All rights reserved.
  2. # Use of this source code is governed by a BSD-style license that can be
  3. # found in the LICENSE file.
  4. """Generates a file describing the js_library to be used by js_binary action.
  5. This script takes in a list of sources and dependencies as described by a
  6. js_library action. It creates a file listing the sources and dependencies
  7. that can later be used by a js_binary action to compile the javascript.
  8. """
  9. from argparse import ArgumentParser
  10. def main():
  11. parser = ArgumentParser()
  12. parser.add_argument('-s', '--sources', nargs='*', default=[],
  13. help='List of js source files')
  14. parser.add_argument('-e', '--externs', nargs='*', default=[],
  15. help='List of js source files')
  16. parser.add_argument('-o', '--output', help='Write list to output')
  17. parser.add_argument('-d', '--deps', nargs='*', default=[],
  18. help='List of js_library dependencies')
  19. args = parser.parse_args()
  20. with open(args.output, 'w') as out:
  21. out.write('sources:\n')
  22. for s in args.sources:
  23. out.write('%s\n' % s)
  24. out.write('deps:\n')
  25. for d in args.deps:
  26. out.write('%s\n' % d)
  27. out.write('externs:\n')
  28. for e in args.externs:
  29. out.write('%s\n' % e)
  30. if __name__ == '__main__':
  31. main()