Permalink
Browse files

Remove unused compilation scripts.

  • Loading branch information...
1 parent 4b60a8a commit a32d6871ac62b08206e8f90a0805128d0654cc6c @sjl sjl committed Jul 27, 2012
Showing with 0 additions and 188 deletions.
  1. +0 −120 closure/compile.py
  2. +0 −68 closure/compilelite.py
View
@@ -1,120 +0,0 @@
-#!/usr/bin/env python
-
-import sys
-import os
-import subprocess
-import logging
-
-BASE = os.path.dirname(__file__)
-sys.path.insert(0, os.path.join(BASE, ".."))
-import settings
-
-logging.basicConfig(level=logging.INFO,
- format='%(asctime)s %(levelname)s %(message)s')
-
-JS_LIB = os.path.join(BASE, "../media/js")
-CLOSURE_LIB = os.path.join(JS_LIB, "closure-library")
-FLOWPLAYER_JS = os.path.join(BASE, "../media/flowplayer/flowplayer-3.2.6.min.js")
-
-def call_command(command):
- process = subprocess.Popen(command.split(' '),
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
- return process.communicate()
-
-def compile(output_file_name, js_file_list,
- closure_dep_file='closure-dependencies.js',
- include_flash_deps=True, debug=False):
- logging.info("Starting {0}".format(output_file_name))
-
- deps = [" --js %s " % os.path.join(JS_LIB, file) for file in js_file_list]
- calcdeps_js = os.path.join(JS_LIB, 'unisubs-calcdeps.js')
- compiled_js = os.path.join(JS_LIB, output_file_name)
- compiler_jar = os.path.join(BASE, 'compiler.jar')
-
- logging.info("Calculating closure dependencies")
-
- js_debug_dep_file = ''
- if debug:
- js_debug_dep_file = '-i {0}/{1}'.format(JS_LIB, 'closure-debug-dependencies.js')
-
- output,_ = call_command(("%s/closure/bin/calcdeps.py -i %s/%s %s " +
- "-p %s/ -o script") %
- (CLOSURE_LIB, JS_LIB, closure_dep_file,
- js_debug_dep_file, CLOSURE_LIB))
-
- # This is to reduce the number of warnings in the code.
- # The unisubs-calcdeps.js file is a concatenation of a bunch of Google Closure
- # JavaScript files, each of which has a @fileoverview tag to describe it.
- # When put all in one file, the compiler complains, so remove them all.
- output_lines = filter(lambda s: s.find("@fileoverview") == -1,
- output.split("\n"))
-
- calcdeps_file = open(calcdeps_js, "w")
- calcdeps_file.write("\n".join(output_lines))
- calcdeps_file.close()
-
- logging.info("Compiling {0}".format(output_file_name))
-
- debug_arg = ''
- if not debug:
- debug_arg = '--define goog.DEBUG=false'
-
- output,err = call_command(("java -jar %s --js %s %s "
- "--js_output_file %s "
- "%s "
- "--define goog.NATIVE_ARRAY_PROTOTYPES=false "
- "--output_wrapper (function(){%%output%%})(); "
- "--compilation_level ADVANCED_OPTIMIZATIONS") %
- (compiler_jar, calcdeps_js, deps, compiled_js,
- debug_arg))
-
- with open(compiled_js, 'r') as compiled_js_file:
- compiled_js_text = compiled_js_file.read()
-
- with open(compiled_js, 'w') as compiled_js_file:
- if include_flash_deps:
- with open(os.path.join(JS_LIB, 'swfobject.js'), 'r') as swfobject_file:
- compiled_js_file.write(swfobject_file.read())
- with open(FLOWPLAYER_JS, 'r') as flowplayerjs_file:
- compiled_js_file.write(flowplayerjs_file.read())
- compiled_js_file.write(compiled_js_text)
-
- if len(output) > 0:
- logging.info("compiler.jar output: %s" % output)
-
- if len(err) > 0:
- logging.info("stderr: %s" % err)
-
- logging.info("Successfully compiled {0}".format(output_file_name))
-
-compile('unisubs-offsite-compiled.js', settings.JS_OFFSITE)
-compile('unisubs-onsite-compiled.js', settings.JS_ONSITE)
-
-# assumes that some other process has generated config.js
-widgetizer_js_files = ['config.js']
-widgetizer_js_files.extend(settings.JS_WIDGETIZER)
-compile('unisubs-widgetizer.js', widgetizer_js_files)
-compile('unisubs-widgetizer-debug.js', widgetizer_js_files,
- debug=True)
-
-# assumes that some other process has generated config.js
-extension_js_files = ['config.js']
-extension_js_files.extend(settings.JS_EXTENSION)
-compile('unisubs-extension.js', extension_js_files)
-
-statwidget_js_files = [
- 'unisubs.js',
- 'rpc.js',
- 'loadingdom.js',
- 'statwidget/statwidgetconfig.js',
- 'statwidget/statwidget.js']
-# assumes that some other process has generated statwidget/statwidgetconfig.js
-compile('unisubs-statwidget.js', statwidget_js_files,
- closure_dep_file='closure-stat-dependencies.js',
- include_flash_deps=False)
-
-# assumes that some other process has generated config.js
-api_js_files = ['config.js']
-api_js_files.extend(settings.JS_API)
-compile('unisubs-api.js', api_js_files)
View
@@ -1,68 +0,0 @@
-#!/usr/bin/env python
-
-import sys
-import os
-import subprocess
-import logging
-
-BASE = os.path.dirname(__file__)
-sys.path.insert(0, os.path.join(BASE, ".."))
-import settings
-
-logging.basicConfig(level=logging.INFO,
- format='%(asctime)s %(levelname)s %(message)s')
-
-JS_LIB = os.path.join(BASE, "../media/js")
-CLOSURE_LIB = os.path.join(JS_LIB, "closure-library")
-FLOWPLAYER_JS = os.path.join(BASE, "../media/flowplayer/flowplayer-3.2.6.min.js")
-
-calcdeps_js = os.path.join(JS_LIB, 'unisubs-calcdeps.js')
-
-def call_command(command):
- process = subprocess.Popen(command.split(' '),
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
- return process.communicate()
-
-logging.info("Calculating closure dependencies")
-
-output,_ = call_command(("%s/closure/bin/calcdeps.py -i %s/closure-dependencies.js " +
- "-p %s/ -o script") %
- (CLOSURE_LIB, JS_LIB, CLOSURE_LIB))
-
-logging.info("Compiling JavaScript")
-
-def compile(output_file_name, js_file_list):
- output_file_path = os.path.join(JS_LIB, output_file_name)
- with open(output_file_path, 'w') as compiled_js_file:
- compiled_js_file.write('(function(){');
- with open(os.path.join(JS_LIB, 'swfobject.js'), 'r') as swfobject_file:
- compiled_js_file.write(swfobject_file.read())
- with open(FLOWPLAYER_JS, 'r') as flowplayerjs_file:
- compiled_js_file.write(flowplayerjs_file.read())
- compiled_js_file.write(output)
- js_file_paths = [os.path.join(JS_LIB, file) for file in js_file_list]
- for dep_file_name in js_file_paths:
- logging.info('Adding {0}'.format(dep_file_name))
- with open(dep_file_name, 'r') as dep_file:
- compiled_js_file.write(dep_file.read())
- compiled_js_file.write('})();');
-
-# compile('unisubs-offsite-compiled.js', settings.JS_OFFSITE)
-# compile('unisubs-onsite-compiled.js', settings.JS_ONSITE)
-
-# widgetizer_js_files = list(settings.JS_OFFSITE)
-# assumes that some other process has generated widgetizer/widgetizerconfig.js
-# widgetizer_js_files.append('widgetizer/widgetizerconfig.js')
-# widgetizer_js_files.append('widgetizer/widgetizer.js')
-# widgetizer_js_files.append('widgetizer/dowidgetize.js')
-compile('unisubs-widgetizer.js', [])
-
-# extension_js_files = list(settings.JS_OFFSITE)
-# assumes that some other process has generated widgetizer/widgetizerconfig.js
-# extension_js_files.append('widgetizer/widgetizerconfig.js')
-# extension_js_files.append('widgetizer/widgetizer.js')
-# extension_js_files.append('widgetizer/extension.js')
-# compile('unisubs-extension.js', extension_js_files)
-
-logging.info("Success")

0 comments on commit a32d687

Please sign in to comment.