def run_on_chunk(command): try: if JS_OPTIMIZER in command: # XXX hackish index = command.index(JS_OPTIMIZER) filename = command[index + 1] else: filename = command[1] if os.environ.get('EMCC_SAVE_OPT_TEMP') and os.environ.get('EMCC_SAVE_OPT_TEMP') != '0': saved = 'save_' + os.path.basename(filename) while os.path.exists(saved): saved = 'input' + str(int(saved.replace('input', '').replace('.txt', ''))+1) + '.txt' print >> sys.stderr, 'running js optimizer command', ' '.join(map(lambda c: c if c != filename else saved, command)) shutil.copyfile(filename, os.path.join(shared.get_emscripten_temp_dir(), saved)) if shared.EM_BUILD_VERBOSE_LEVEL >= 3: print >> sys.stderr, 'run_on_chunk: ' + str(command) proc = subprocess.Popen(command, stdout=subprocess.PIPE) output = proc.communicate()[0] assert proc.returncode == 0, 'Error in optimizer (return code ' + str(proc.returncode) + '): ' + output assert len(output) > 0 and not output.startswith('Assertion failed'), 'Error in optimizer: ' + output filename = temp_files.get(os.path.basename(filename) + '.jo.js').name # Important to write out in binary mode, because the data we are writing contains Windows line endings '\r\n' because it was PIPED from console. # Otherwise writing \r\n to ascii mode file will result in Windows amplifying \n to \r\n, generating bad \r\r\n line endings. f = open(filename, 'wb') f.write(output) f.close() if DEBUG and not shared.WINDOWS: print >> sys.stderr, '.' # Skip debug progress indicator on Windows, since it doesn't buffer well with multiple threads printing to console. return filename except KeyboardInterrupt: # avoid throwing keyboard interrupts from a child process raise Exception()
def run_on_chunk(command): try: file_suffix = ".js" index = command.index(DUPLICATE_FUNCTION_ELIMINATOR) filename = command[index + 1] if "--gen-hash-info" in command: file_suffix = ".json" if os.environ.get("EMCC_SAVE_OPT_TEMP") and os.environ.get("EMCC_SAVE_OPT_TEMP") != "0": saved = "save_" + os.path.basename(filename) while os.path.exists(saved): saved = "input" + str(int(saved.replace("input", "").replace(".txt", "")) + 1) + ".txt" print >>sys.stderr, "running DFE command", " ".join(map(lambda c: c if c != filename else saved, command)) shutil.copyfile(filename, os.path.join(shared.get_emscripten_temp_dir(), saved)) if shared.EM_BUILD_VERBOSE_LEVEL >= 3: print >>sys.stderr, "run_on_chunk: " + str(command) proc = subprocess.Popen(command, stdout=subprocess.PIPE) output = proc.communicate()[0] assert proc.returncode == 0, "Error in optimizer (return code " + str(proc.returncode) + "): " + output assert len(output) > 0 and not output.startswith("Assertion failed"), "Error in optimizer: " + output filename = temp_files.get(os.path.basename(filename) + ".jo" + file_suffix).name # Important to write out in binary mode, because the data we are writing contains Windows line endings '\r\n' because it was PIPED from console. # Otherwise writing \r\n to ascii mode file will result in Windows amplifying \n to \r\n, generating bad \r\r\n line endings. f = open(filename, "wb") f.write(output) f.close() if DEBUG and not shared.WINDOWS: print >>sys.stderr, "." # Skip debug progress indicator on Windows, since it doesn't buffer well with multiple threads printing to console. return filename except KeyboardInterrupt: # avoid throwing keyboard interrupts from a child process raise Exception() except (TypeError, ValueError) as e: formatted_lines = traceback.format_exc().splitlines() print >>sys.stderr, ">>>>>>>>>>>>>>>>>" for formatted_line in formatted_lines: print >>sys.stderr, formatted_line print >>sys.stderr, "<<<<<<<<<<<<<<<<<" raise
import os, sys from subprocess import Popen, PIPE, STDOUT import shared print 'Building zlib' emscripten_temp_dir = shared.get_emscripten_temp_dir() zlib = shared.Building.build_library('zlib', emscripten_temp_dir, emscripten_temp_dir, ['libz.a'], make_args=['libz.a'], copy_project=True, source_dir=shared.path_from_root('tests', 'zlib'))[0] print 'Building minigzip' Popen([shared.PYTHON, shared.EMCC, '-O2', shared.path_from_root('tests', 'zlib', 'minigzip.c'), zlib, '-o', shared.path_from_root('tools', 'minigzip.js')]).communicate()
import os, sys from subprocess import Popen, PIPE, STDOUT import shared print 'Building zlib' emscripten_temp_dir = shared.get_emscripten_temp_dir() zlib = shared.Building.build_library('zlib', emscripten_temp_dir, emscripten_temp_dir, ['libz.a'], make_args=['libz.a'], copy_project=True, source_dir=shared.path_from_root( 'tests', 'zlib'))[0] print 'Building minigzip' Popen([ shared.PYTHON, shared.EMCC, '-O2', shared.path_from_root('tests', 'zlib', 'minigzip.c'), zlib, '-o', shared.path_from_root('tools', 'minigzip.js') ]).communicate()