aboutsummaryrefslogtreecommitdiff
path: root/scons-tools/closure.py
blob: 8f53e507f873df0b0742151d3ed387c480320269 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import os.path
from SCons.Builder import Builder

def generate(env):
    def depend_on_closure_compiler(target, source, env):
        env.Depends(target, env['CLOSURE_COMPILER'])
        return target, source

    ClosureCompiler = Builder(
        action='$JAVA $JAVAFLAGS -jar $CLOSURE_COMPILER $CLOSURE_FLAGS --js_output_file $TARGET $SOURCES',
        emitter=depend_on_closure_compiler
    )

    closure = os.path.join(
        os.path.dirname(__file__),
        '..',
        'third_party',
        'closure-compiler',
        'compiler.jar')
    closure = env.File(closure)

    env['JAVA'] = 'java'
    env['CLOSURE_COMPILER'] = closure
    env.Append(
        BUILDERS={'ClosureCompiler':ClosureCompiler})

def exists(_env):
    return True