aboutsummaryrefslogtreecommitdiff
path: root/tools/shared.py
diff options
context:
space:
mode:
authorEhsan Akhgari <ehsan.akhgari@gmail.com>2012-02-01 19:37:21 -0500
committerEhsan Akhgari <ehsan.akhgari@gmail.com>2012-02-02 22:26:16 -0500
commit43c7d8a24ee94dff752036585a3a8711df61c7c4 (patch)
treea1b0b94ea005322ad5dc41d7041d41d5e13c03b1 /tools/shared.py
parent1549a85427fe76243a5cd1191e57b0a9cb867e5a (diff)
Support CMake in emconfigure
This adds a CMAKE_TOOLCHAIN_FILE argument to CMake based build systems so that they don't attempt to find headers, libraries and packages which Emscripten does not support
Diffstat (limited to 'tools/shared.py')
-rw-r--r--tools/shared.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/tools/shared.py b/tools/shared.py
index 2304d817..be45633a 100644
--- a/tools/shared.py
+++ b/tools/shared.py
@@ -1,5 +1,6 @@
import shutil, time, os, sys, json, tempfile, copy
from subprocess import Popen, PIPE, STDOUT
+from tempfile import mkstemp
__rootpath__ = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
def path_from_root(*pathelems):
@@ -366,10 +367,36 @@ class Building:
return env
@staticmethod
+ def handle_CMake_toolchain(args):
+ CMakeToolchain = '''# the name of the target operating system
+SET(CMAKE_SYSTEM_NAME Linux)
+
+# which C and C++ compiler to use
+SET(CMAKE_C_COMPILER $EMSCRIPTEN_ROOT/emcc)
+SET(CMAKE_CXX_COMPILER $EMSCRIPTEN_ROOT/em++)
+
+# here is the target environment located
+SET(CMAKE_FIND_ROOT_PATH $EMSCRIPTEN_ROOT/system/include )
+
+# adjust the default behaviour of the FIND_XXX() commands:
+# search headers and libraries in the target environment, search
+# programs in the host environment
+set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
+set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
+set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)
+set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)'''.replace('$EMSCRIPTEN_ROOT', path_from_root(''))
+ toolchainFile = mkstemp(suffix='.txt')[1]
+ open(toolchainFile, 'w').write(CMakeToolchain)
+ args.append('-DCMAKE_TOOLCHAIN_FILE=%s' % os.path.abspath(toolchainFile))
+ return args
+
+ @staticmethod
def configure(args, stdout=None, stderr=None, env=None):
if env is None:
env = Building.get_building_env()
env['EMMAKEN_JUST_CONFIGURE'] = '1'
+ if args[0].find('cmake') > -1:
+ args = Building.handle_CMake_toolchain(args)
Popen(args, stdout=stdout, stderr=stderr, env=env).communicate()[0]
del env['EMMAKEN_JUST_CONFIGURE']