@@ -14,7 +14,8 @@ import time
1414#=======================================================================================================================
1515PROJECT_PATH = os .path .abspath (os .path .dirname (__file__ ))
1616CONTRIB_PATH = os .path .join (PROJECT_PATH , 'contrib' )
17- COMPILER_PATH = os .path .join (CONTRIB_PATH , 'compiler' , 'compiler.jar' )
17+ COMPILER_VERSION = '20160911'
18+ COMPILER_PATH = os .path .join (CONTRIB_PATH , 'compiler' , 'closure-compiler-v%s.jar' % COMPILER_VERSION )
1819SRC_PATH = os .path .join (PROJECT_PATH , 'src' )
1920OUT_PATH = os .path .join (PROJECT_PATH , 'out' )
2021CLOSURE_LIBRARY_PATH = os .path .join (CONTRIB_PATH , 'closure-library' )
@@ -28,6 +29,7 @@ PYTHON = 'python'
2829if not (platform .system () == 'Windows' ):
2930 PYTHON = 'python2.7'
3031
32+
3133#=======================================================================================================================
3234# Synchronize contributions.
3335#=======================================================================================================================
@@ -44,16 +46,16 @@ def __has_closure_linter_wrapper():
4446
4547
4648def __has_closure_linter ():
47- hasLint = True
49+ has_lint = True
4850 try :
4951 subprocess .Popen (['gjslint' ], shell = True , stdout = subprocess .PIPE , stderr = subprocess .STDOUT )
5052 except StandardError :
51- hasLint = False
53+ has_lint = False
5254
53- return hasLint
55+ return has_lint
5456
5557
56- def __ensureDirExists (path ):
58+ def __ensure_dir_exists (path ):
5759 if not os .path .exists (path ):
5860 os .mkdir (path )
5961
@@ -67,35 +69,35 @@ def __need_sync_contrib():
6769
6870def __sync_contrib ():
6971 t = time .time ()
70- __ensureDirExists (CONTRIB_PATH )
72+ __ensure_dir_exists (CONTRIB_PATH )
7173
7274 subprocess .call (['git' , 'submodule' , 'init' ])
7375 subprocess .call (['git' , 'submodule' , 'update' ])
7476
7577 #Download closure compiler
7678 if not os .path .exists (COMPILER_PATH ):
77- print 'Downloading Google Closure Compiler v.20151216'
79+ print 'Downloading Google Closure Compiler v.' + COMPILER_VERSION
7880 try :
7981 __download_and_unzip_from_http (
80- 'http://dl.google.com/closure-compiler/compiler-20151216 .zip' ,
82+ 'http://dl.google.com/closure-compiler/compiler-%s .zip' % COMPILER_VERSION ,
8183 'compiler'
8284 )
8385 except StandardError as e :
8486 print e
8587 print 'Failed'
86- return False ;
88+ return False
8789
8890 #Install closure linter
8991 if not __has_closure_linter ():
9092 if not __install_closure_linter ():
91- return False ;
93+ return False
9294
9395 print 'Environment ready. Time spent: {:.3f}s\n ' .format (time .time () - t )
9496 return True
9597
9698
97- def __download_and_unzip_from_http (from_url , dri_name ):
98- z_obj_path = os .path .join (CONTRIB_PATH , dri_name + '.zip' )
99+ def __download_and_unzip_from_http (from_url , dir_name ):
100+ z_obj_path = os .path .join (CONTRIB_PATH , dir_name + '.zip' )
99101
100102 # download zip archive from url
101103 if not os .path .exists (z_obj_path ):
@@ -105,8 +107,8 @@ def __download_and_unzip_from_http(from_url, dri_name):
105107 )
106108
107109 # extract zip archive
108- target_path = os .path .join (CONTRIB_PATH , dri_name )
109- __ensureDirExists (target_path )
110+ target_path = os .path .join (CONTRIB_PATH , dir_name )
111+ __ensure_dir_exists (target_path )
110112 z_obj = zipfile .ZipFile (z_obj_path )
111113 z_obj .extractall (path = target_path )
112114 z_obj .close ()
@@ -151,30 +153,26 @@ def __getNotOptimizedCompilerArgs():
151153
152154def __getOptimizedCompilerArgs ():
153155 compilerArgs = [
154- '--compilation_level ADVANCED_OPTIMIZATIONS' ,
156+ '--compilation_level ADVANCED' ,
157+ '--env BROWSER' ,
155158 '--warning_level VERBOSE' ,
156159 '--jscomp_warning accessControls' ,
157160 '--jscomp_warning ambiguousFunctionDecl' ,
158- '--jscomp_warning checkDebuggerStatement' ,
159161 '--jscomp_warning checkEventfulObjectDisposal' ,
160162 '--jscomp_warning checkRegExp' ,
161163 '--jscomp_warning checkTypes' ,
162164 '--jscomp_warning checkVars' ,
163- '--jscomp_warning closureDepMethodUsageChecks' ,
164165 '--jscomp_warning conformanceViolations' ,
165166 '--jscomp_warning const' ,
166167 '--jscomp_warning constantProperty' ,
167168 '--jscomp_warning deprecated' ,
168169 '--jscomp_warning deprecatedAnnotations' ,
169- '--jscomp_warning duplicate' ,
170170 '--jscomp_warning duplicateMessage' ,
171171 '--jscomp_warning es3' ,
172172 '--jscomp_warning es5Strict' ,
173173 '--jscomp_warning externsValidation' ,
174- '--jscomp_warning extraRequire' ,
175174 '--jscomp_warning fileoverviewTags' ,
176175 '--jscomp_warning globalThis' ,
177- '--jscomp_warning inferredConstCheck' ,
178176 '--jscomp_warning internetExplorerChecks' ,
179177 '--jscomp_warning invalidCasts' ,
180178 '--jscomp_warning misplacedTypeAnnotation' ,
@@ -183,22 +181,24 @@ def __getOptimizedCompilerArgs():
183181 '--jscomp_warning missingProvide' ,
184182 '--jscomp_warning missingRequire' ,
185183 '--jscomp_warning missingReturn' ,
184+ '--jscomp_warning msgDescriptions' ,
186185 '--jscomp_warning newCheckTypes' ,
187- #'--jscomp_warning msgDescriptionsNewCheckTypes',
188186 '--jscomp_warning nonStandardJsDocs' ,
189- #'--jscomp_warning reportUnknownTypes',
190187 '--jscomp_warning suspiciousCode' ,
191188 '--jscomp_warning strictModuleDepCheck' ,
192- '--jscomp_warning tweakValidation' ,
193189 '--jscomp_warning typeInvalidation' ,
194190 '--jscomp_warning undefinedNames' ,
195191 '--jscomp_warning undefinedVars' ,
196192 '--jscomp_warning unknownDefines' ,
197- #+'--jscomp_warning unnecessaryCasts',
193+ # '--jscomp_warning unusedLocalVariables',
194+ # '--jscomp_warning unusedPrivateMembers',
198195 '--jscomp_warning uselessCode' ,
199- #+ '--jscomp_warning useOfGoogBase',
200- '--jscomp_warning violatedModuleDep ' ,
196+ # '--jscomp_warning useOfGoogBase',
197+ '--jscomp_warning underscore ' ,
201198 '--jscomp_warning visibility' ,
199+ # '--use_types_for_optimization',
200+ '--rewrite_polyfills' ,
201+ '--process_closure_primitives' ,
202202 ]
203203 return compilerArgs
204204
@@ -208,19 +208,21 @@ def __getDefaultCompilerArgs(outputFile):
208208 'java -jar' ,
209209 COMPILER_PATH ,
210210 '--charset UTF-8' ,
211- '--only_closure_dependencies ' ,
211+ '--dependency_mode STRICT ' ,
212212 '--externs ' + EXTERNS_PATH ,
213213 '--js="%s"' % os .path .join (SRC_PATH , '**.js' ),
214214 '--js="%s"' % os .path .join (CLOSURE_LIBRARY_PATH , '**.js' ),
215- '--closure_entry_point acgraph' ,
216- '--js_output_file ' + outputFile
215+ '--entry_point acgraph' ,
216+ '--js_output_file ' + outputFile ,
217+ '--assume_function_wrapper' ,
218+ '--output_wrapper "(function(){%output%}).apply(this);"'
217219 ]
218220 return result
219221
220222
221223@sync_required
222224def __compileBinary ():
223- __ensureDirExists (OUT_PATH )
225+ __ensure_dir_exists (OUT_PATH )
224226
225227 t = time .time ()
226228 outputFileName = os .path .join (OUT_PATH , 'graphics.min.js' )
@@ -236,7 +238,7 @@ def __compileBinary():
236238
237239@sync_required
238240def __compilePlain ():
239- __ensureDirExists (OUT_PATH )
241+ __ensure_dir_exists (OUT_PATH )
240242
241243 t = time .time ()
242244 outputFileName = os .path .join (OUT_PATH , 'graphics.js' )
0 commit comments