diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-10-29 18:10:35 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-10-29 18:10:35 -0700 |
commit | 99fb6b9b81f453857b111452038cf4a182a2323e (patch) | |
tree | ba4f00ff8acf6ed1c0cd791b2ceec46dcb11c0ca /emcc | |
parent | 83faf3466056ed70bcf62cd9a63cb23bc4fa40cf (diff) |
more non-clang configure work and debugging tools
Diffstat (limited to 'emcc')
-rwxr-xr-x | emcc | 32 |
1 files changed, 23 insertions, 9 deletions
@@ -371,9 +371,30 @@ def is_minus_s_for_emcc(newargs,i): CONFIGURE_CONFIG = (os.environ.get('EMMAKEN_JUST_CONFIGURE') or 'conftest.c' in sys.argv) and not os.environ.get('EMMAKEN_JUST_CONFIGURE_RECURSE') CMAKE_CONFIG = 'CMakeFiles/cmTryCompileExec.dir' in ' '.join(sys.argv)# or 'CMakeCCompilerId' in ' '.join(sys.argv) if CONFIGURE_CONFIG or CMAKE_CONFIG: + debug_configure = False # XXX use this to debug configure stuff. ./configure's generally hide our normal output including stderr so we write to a file use_clang = True # whether we fake configure tests using clang - the local, native compiler - or not. if not, we generate JS and use node with a shebang # neither approach is perfect, you can try both, but may need to edit configure scripts in some cases # XXX False is not fully tested yet + + if debug_configure: + tempout = '/tmp/emscripten_temp/out' + if not os.path.exists(tempout): + open(tempout, 'w').write('//\n') + + src = None + for i in range(len(sys.argv)): + if sys.argv[i].endswith('.c'): + try: + src = open(sys.argv[i]).read() + except: + pass + + if src: + if debug_configure: open(tempout, 'a').write('=============\n' + src + '\n=============\n\n') + if 'fopen' in src and '"w"' in src: + use_clang = True # we cannot write to files from js! + if debug_configure: open(tempout, 'a').write('Forcing clang since uses fopen to write\n') + compiler = os.environ.get('CONFIGURE_CC') or (shared.CLANG if use_clang else shared.EMCC) # if CONFIGURE_CC is defined, use that. let's you use local gcc etc. if you need that if not ('CXXCompiler' in ' '.join(sys.argv) or os.environ.get('EMMAKEN_CXX')): compiler = shared.to_cc(compiler) @@ -396,14 +417,7 @@ if CONFIGURE_CONFIG or CMAKE_CONFIG: if use_clang: cmd += shared.EMSDK_OPTS + ['-DEMSCRIPTEN'] if DEBUG: print >> sys.stderr, 'emcc, just configuring: ', ' '.join(cmd) - if 0: # XXX use this to debug non-clang configure; ./configure's generally hide our normal output including stderr so we write to a file - tempout = '/tmp/emscripten_temp/out' - if not os.path.exists(tempout): - open(tempout, 'w').write('//\n') - open(tempout, 'a').write('emcc, just configuring: ' + ' '.join(cmd) + '\n\n') - for i in range(len(sys.argv)): - if sys.argv[i].endswith('.c'): - open(tempout, 'a').write('============= ' + sys.argv[i] + '\n' + open(sys.argv[i]).read() + '\n=============\n\n') + if debug_configure: open(tempout, 'a').write('emcc, just configuring: ' + ' '.join(cmd) + '\n\n') if use_clang: exit(subprocess.call(cmd)) @@ -418,7 +432,7 @@ if CONFIGURE_CONFIG or CMAKE_CONFIG: break if not target: target = 'a.out' - if not os.path.exists(target): exit(1) + if not os.path.exists(target + '.js'): exit(1) shutil.copyfile(target + '.js', target) else: if not os.path.exists(target): exit(2) |