aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2011-04-27 16:58:13 -0700
committerAlon Zakai <alonzakai@gmail.com>2011-04-27 16:58:13 -0700
commit85cba40ddc63e34f7f5ebc06a53e1f00137662c7 (patch)
tree0a812aaa5b200b6abc5292210780d341d685c567
parent6345f59ce83d57b08866083dde88f1157dfb8921 (diff)
emmakenxx.py to handle .c files in projects that are really c++
-rwxr-xr-xtools/emmaken.py16
-rwxr-xr-xtools/emmakenxx.py16
2 files changed, 31 insertions, 1 deletions
diff --git a/tools/emmaken.py b/tools/emmaken.py
index 1b3b6643..62a367c7 100755
--- a/tools/emmaken.py
+++ b/tools/emmaken.py
@@ -24,7 +24,7 @@ Example uses:
* With CMake, do something like
SET(CMAKE_C_COMPILER "PATH/emmaken.py")
- SET(CMAKE_CXX_COMPILER "PATH/emmaken.py")
+ SET(CMAKE_CXX_COMPILER "PATH/emmakenxx.py")
SET(CMAKE_LINKER "PATH/emmaken.py")
SET(CMAKE_CXX_LINKER "PATH/emmaken.py")
SET(CMAKE_C_LINK_EXECUTABLE "PATH/emmaken.py")
@@ -37,6 +37,15 @@ LLVM instead of the normal output, and end up with .ll files that you can
give to Emscripten. Note that this tool doesn't run Emscripten itself. Note
also that you may need to do some manual fiddling later, for example to
link files that weren't linked, and them llvm-dis them.
+
+Note the appearance of emmakenxx.py instead of emmaken.py
+for the C++ compiler. This is needed for cases where we get
+a C++ file with a C extension, in which case CMake can be told
+to run g++ on it despite the .c extension, see
+
+ https://github.com/kripken/emscripten/issues/6
+
+(If a similar situation occurs with ./configure, you can do the same there too.)
'''
import sys
@@ -65,6 +74,11 @@ try:
CXX = os.environ.get('EMMAKEN_COMPILER') or LLVM_GCC
CC = to_cc(CXX)
+ # If we got here from a redirection through emmakenxx.py, then force a C++ compiler here
+ if sys.argv[-1] == '-EMMAKEN_CXX':
+ CC = CXX
+ sys.argv = sys.argv[:-1]
+
CC_ARG_SKIP = ['-O1', '-O2', '-O3']
CC_ADDITIONAL_ARGS = ['-m32', '-U__i386__', '-U__x86_64__', '-U__SSE__', '-UX87_DOUBLE_ROUNDING', '-UHAVE_GCC_ASM_FOR_X87']
ALLOWED_LINK_ARGS = ['-f', '-help', '-o', '-print-after', '-print-after-all', '-print-before',
diff --git a/tools/emmakenxx.py b/tools/emmakenxx.py
new file mode 100755
index 00000000..e271d765
--- /dev/null
+++ b/tools/emmakenxx.py
@@ -0,0 +1,16 @@
+#!/usr/bin/env python
+
+'''
+see emmaken.py
+'''
+
+import os, sys
+
+abspath = os.path.abspath(os.path.dirname(__file__))
+def path_from_root(*pathelems):
+ return os.path.join(os.path.sep, *(abspath.split(os.sep)[:-1] + list(pathelems)))
+exec(open(path_from_root('tools', 'shared.py'), 'r').read())
+
+emmaken = path_from_root('tools', 'emmaken.py')
+exit(os.execvp('python', ['python', emmaken] + sys.argv[1:] + ['-EMMAKEN_CXX']))
+