Use a Python script to generate requireall.js
This is needed to work around platform variations in the sort command.
This commit is contained in:
4
Makefile
4
Makefile
@@ -36,9 +36,9 @@ build/src/external/externs/types.js: bin/generate-src src/ol/literals.txt
|
||||
mkdir -p $(dir $@)
|
||||
bin/generate-src --externs src/ol/literals.txt >$@
|
||||
|
||||
build/src/internal/src/requireall.js: $(SRC)
|
||||
build/src/internal/src/requireall.js: bin/generate-requireall $(SRC)
|
||||
mkdir -p $(dir $@)
|
||||
( echo "goog.require('goog.dom');" ; find src/ol -name \*.js | xargs grep -rh ^goog.provide | sort | uniq | sed -e 's/provide/require/g' ) >$@
|
||||
bin/generate-requireall --require=goog.dom src/ol >$@
|
||||
|
||||
build/src/internal/src/types.js: bin/generate-src src/ol/literals.txt
|
||||
mkdir -p $(dir $@)
|
||||
|
||||
32
bin/generate-requireall
Executable file
32
bin/generate-requireall
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/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))
|
||||
Reference in New Issue
Block a user