Skip to content

Instantly share code, notes, and snippets.

@camshaft
Created January 19, 2012 19:07
Show Gist options
  • Save camshaft/1641869 to your computer and use it in GitHub Desktop.
Save camshaft/1641869 to your computer and use it in GitHub Desktop.
Closure wscript file
#!/usr/bin/env python
# encoding: utf-8
# Cameron Bytheway, 2011
import os
APPNAME = 'closure_app'
VERSION = '0.1'
top = '.'
out = 'build'
def options(ctx):
lessc_default = ctx.path.abspath() + '/bin/less/bin/lessc'
ctx.add_option('--lessc', action='store', default=lessc_default, help='LESS Compiler path')
plovr_default = ctx.path.abspath() + '/bin/plovr.jar'
ctx.add_option('--plovr', action='store', default=plovr_default, help='Plovr build tool path')
plovr_config = ctx.path.abspath() + '/etc/config.json'
ctx.add_option('--plovr_config', action='store', default=plovr_config, help='Plovr config path')
def configure(ctx):
pass
def build(bld):
_buildClosure(bld)
_buildLESS(bld)
def _buildClosure(bld):
src = bld.path.ant_glob('apps/**/*js') + bld.path.ant_glob('lib/**/*js')
bld(rule='java -jar "'+bld.options.plovr+'" build "'+bld.options.plovr_config+'"', source=src)
def _buildLESS(bld):
lessFiles = bld.path.ant_glob('**/*less', excl=['bin'])
search_path = os.path.join(bld.top_dir,'apps')
for infile in os.listdir(search_path):
stylesheet = os.path.join(bld.path.abspath(), 'apps', infile, 'stylesheets', 'style.less')
stylesheet_out = os.path.join(bld.options.out, 'module_'+infile+'.css')
bld(rule='"'+bld.options.lessc+'" "'+stylesheet+'" > "${TGT}"', source=lessFiles, target=stylesheet_out)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment