Use closure-util's Closure lib for the check-requires target

This commit is contained in:
Éric Lemoine
2014-07-02 08:15:50 +02:00
parent 8c4a55cc65
commit 167d13b4f6
+7 -7
View File
@@ -408,19 +408,19 @@ def _strip_comments(lines):
@target('build/check-requires-timestamp', SRC, EXAMPLES_SRC, SHADER_SRC, SPEC) @target('build/check-requires-timestamp', SRC, EXAMPLES_SRC, SHADER_SRC, SPEC)
def build_check_requires_timestamp(t): def build_check_requires_timestamp(t):
from zipfile import ZipFile
unused_count = 0 unused_count = 0
all_provides = set() all_provides = set()
zf = ZipFile(PLOVR_JAR) closure_lib_path = output('node', '-e',
for zi in zf.infolist(): 'process.stdout.write(require("closure-util").getLibraryPath())')
if zi.filename.endswith('.js'): for filename in ifind(closure_lib_path):
if not zi.filename.startswith('closure/goog/'): if filename.endswith('.js'):
if not re.match(r'.*/closure/goog/', filename):
continue continue
# Skip goog.i18n because it contains so many modules that it causes # Skip goog.i18n because it contains so many modules that it causes
# the generated regular expression to exceed Python's limits # the generated regular expression to exceed Python's limits
if zi.filename.startswith('closure/goog/i18n/'): if re.match(r'.*/closure/goog/i18n/', filename):
continue continue
for line in zf.open(zi, 'rU'): for line in open(filename, 'rU'):
m = re.match(r'goog.provide\(\'(.*)\'\);', line) m = re.match(r'goog.provide\(\'(.*)\'\);', line)
if m: if m:
all_provides.add(m.group(1)) all_provides.add(m.group(1))