diff options
author | LCID Fire <lcid-fire@gmx.net> | 2012-03-03 21:20:20 +0100 |
---|---|---|
committer | LCID Fire <lcid-fire@gmx.net> | 2012-03-03 21:20:20 +0100 |
commit | 9bcecf42ed7dbfe82e68e9299980349f827aff89 (patch) | |
tree | b795a333df3cf0fa5bc64ffd84b981bf3f7cff20 /tools/scons | |
parent | 6f57ea8f0eeb220fc81726b4e3a3c02f4232b667 (diff) |
Add Tool support for SCons
To use:
* Link emscripten directory to <ProjectRoot>/site_scons/site_tools/emscripten
* Load into an Environment via env.Tool("emscripten")
* Use Program and Library normally in SCons
Diffstat (limited to 'tools/scons')
-rw-r--r-- | tools/scons/site_scons/site_tools/emscripten/__init__.py | 3 | ||||
-rw-r--r-- | tools/scons/site_scons/site_tools/emscripten/emscripten.py | 44 |
2 files changed, 47 insertions, 0 deletions
diff --git a/tools/scons/site_scons/site_tools/emscripten/__init__.py b/tools/scons/site_scons/site_tools/emscripten/__init__.py new file mode 100644 index 00000000..8ae2288e --- /dev/null +++ b/tools/scons/site_scons/site_tools/emscripten/__init__.py @@ -0,0 +1,3 @@ +#!/usr/bin/env python + +from emscripten import exists, generate diff --git a/tools/scons/site_scons/site_tools/emscripten/emscripten.py b/tools/scons/site_scons/site_tools/emscripten/emscripten.py new file mode 100644 index 00000000..cb14b58e --- /dev/null +++ b/tools/scons/site_scons/site_tools/emscripten/emscripten.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python + +import os + +def generate(env, emscripten_path=None, **kw): + """ SCons tool entry point """ + + if emscripten_path is None: + # Try to find emscripten + # Use same method as Emscripten's shared.py + EM_CONFIG = os.environ.get('EM_CONFIG') + if not EM_CONFIG: + EM_CONFIG = '~/.emscripten' + + CONFIG_FILE = os.path.expanduser(EM_CONFIG) + try: + exec(open(CONFIG_FILE, 'r').read()) + except Exception, e: + print >> sys.stderr, 'Error in evaluating %s (at %s): %s' % (EM_CONFIG, CONFIG_FILE, str(e)) + sys.exit(1) + + emscripten_path = EMSCRIPTEN_ROOT + + try: + emscPath = emscripten_path.abspath + except: + emscPath = emscripten_path + + env.Replace(CC = os.path.join(emscPath, "emcc" )) + env.Replace(CXX = os.path.join(emscPath, "em++" )) + env.Replace(LINK = os.path.join(emscPath, "emld" )) + # SHLINK and LDMODULE should use LINK so no + # need to change them here + + env.Replace(AR = os.path.join(emscPath, "emar" )) + env.Replace(RANLIB = os.path.join(emscPath, "emranlib")) + + env.Replace(OBJSUFFIX = [".js", ".bc", ".o"][2]) + env.Replace(LIBSUFFIX = [".js", ".bc", ".o"][2]) + env.Replace(PROGSUFFIX = [".html", ".js" ][1]) + +def exists(env): + """ NOOP method required by SCons """ + return 1 |