Files
openlayers/bin/generate-requireall
Tom Payne 9494321c91 Use a Python script to generate requireall.js
This is needed to work around platform variations in the sort command.
2012-09-29 12:31:31 +02:00

33 lines
883 B
Python
Executable File

#!/usr/bin/env python
from optparse import OptionParser
import os
import os.path
import re
import sys
def main(argv):
option_parser = OptionParser()
option_parser.add_option('--require', action='append')
options, args = option_parser.parse_args(argv[1:])
requires = set(options.require or ())
for arg in args:
for dirpath, dirnames, filenames in os.walk(arg):
for filename in filenames:
if not filename.endswith('.js'):
continue
for line in open(os.path.join(dirpath, filename)):
m = re.match(r'goog\.provide\(\'(.*)\'\);', line)
if m:
requires.add(m.group(1))
for require in sorted(requires):
sys.stdout.write('goog.require(\'%s\');\n' % (require,))
if __name__ == '__main__':
sys.exit(main(sys.argv))