Skip to content

Commit

Permalink
emmakenxx.py to handle .c files in projects that are really c++
Browse files Browse the repository at this point in the history
  • Loading branch information
kripken committed Apr 27, 2011
1 parent 6345f59 commit 85cba40
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
16 changes: 15 additions & 1 deletion tools/emmaken.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* 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")
Expand All @@ -37,6 +37,15 @@
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
Expand Down Expand Up @@ -65,6 +74,11 @@ def path_from_root(*pathelems):
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',
Expand Down
16 changes: 16 additions & 0 deletions tools/emmakenxx.py
Original file line number Diff line number Diff line change
@@ -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']))

0 comments on commit 85cba40

Please sign in to comment.