aboutsummaryrefslogtreecommitdiff
path: root/scons-tools
diff options
context:
space:
mode:
authorChad Austin <chad@imvu.com>2013-05-17 12:08:55 -0700
committerChad Austin <chad@imvu.com>2013-05-17 13:04:02 -0700
commitec19fe482bf564de68a076ed093af131d502bb30 (patch)
treeee317bc543e16c363ceb8601cc9dacddd1a8dd91 /scons-tools
parentd641184152923a119b3c2b7fd51acc71997ff0cd (diff)
Move emscripten SCons tools into emscripten/scons-tools/
Diffstat (limited to 'scons-tools')
-rw-r--r--scons-tools/closure.py28
-rwxr-xr-xscons-tools/emscripten.py9
-rwxr-xr-xscons-tools/llvm.py26
3 files changed, 61 insertions, 2 deletions
diff --git a/scons-tools/closure.py b/scons-tools/closure.py
new file mode 100644
index 00000000..8f53e507
--- /dev/null
+++ b/scons-tools/closure.py
@@ -0,0 +1,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
diff --git a/scons-tools/emscripten.py b/scons-tools/emscripten.py
index bfe4c493..cdf960ac 100755
--- a/scons-tools/emscripten.py
+++ b/scons-tools/emscripten.py
@@ -47,14 +47,17 @@ def build_version_file(env):
return emscripten_version_file
-def depend_on_emscripten(node, env, path):
+def get_emscripten_version_file(env):
EMSCRIPTEN_HOME = env.Dir('$EMSCRIPTEN_HOME').abspath
try:
version_file = emscripten_version_files[EMSCRIPTEN_HOME]
except KeyError:
version_file = build_version_file(env)
emscripten_version_files[EMSCRIPTEN_HOME] = version_file
- return [version_file]
+ return version_file
+
+def depend_on_emscripten(node, env, path):
+ return [get_emscripten_version_file(env)]
EmscriptenScanner = Scanner(
name='emscripten',
@@ -211,6 +214,7 @@ def build_libembind(env):
libembind = env.Object(
'$EMSCRIPTEN_TEMP_DIR/internal_libs/bind',
'$EMSCRIPTEN_HOME/system/lib/embind/bind.cpp')
+ env.Depends(libembind, get_emscripten_version_file(env))
libembind_cache[emscripten_temp_dir] = libembind
return libembind
@@ -235,6 +239,7 @@ def build_libcxx(env):
'${EMSCRIPTEN_TEMP_DIR}/libcxx_objects/' + os.path.splitext(o)[0] + '.bc',
'${EMSCRIPTEN_HOME}/' + o)
for o in LIBC_SOURCES + LIBCXXABI_SOURCES + LIBCXX_SOURCES]
+ env.Depends(objs, get_emscripten_version_file(env))
libcxx = env.Library('${EMSCRIPTEN_TEMP_DIR}/internal_libs/libcxx', objs)
libcxx_cache[emscripten_temp_dir] = libcxx
diff --git a/scons-tools/llvm.py b/scons-tools/llvm.py
new file mode 100755
index 00000000..2e03caa3
--- /dev/null
+++ b/scons-tools/llvm.py
@@ -0,0 +1,26 @@
+from SCons.Scanner.Prog import scan
+from SCons.Builder import Builder
+
+def exists(env):
+ return True
+
+def add_libraries(target, source, env):
+ unique = []
+ lib_nodes = set()
+ for x in scan(None, env, tuple(map(env.Dir, env['LIBPATH']))):
+ if x in lib_nodes:
+ continue
+ lib_nodes.add(x)
+ unique.append(x)
+ return (target, source + unique)
+
+def generate(env):
+ env['BUILDERS']['LLVMDis'] = Builder(
+ action='${LLVM_ROOT}/llvm-dis -o=$TARGET $SOURCE')
+
+ env['BUILDERS']['LLVMOpt'] = Builder(
+ action='${LLVM_ROOT}/opt $LLVM_OPT_FLAGS $LLVM_OPT_PASSES -o=$TARGET $SOURCE')
+
+ env['BUILDERS']['LLVMLink'] = Builder(
+ action='${LLVM_ROOT}/llvm-link -o=$TARGET $SOURCES',
+ emitter=add_libraries)