NATIVE_OPTIMIZER=os.environ.get('EMCC_NATIVE_OPTIMIZER') or'2'# use optimized native optimizer by default, unless disabled by EMCC_NATIVE_OPTIMIZER=0 in the env
logging.critical('Non-fastcomp compiler is no longer available, please use fastcomp or an older version of emscripten')
sys.exit(1)
# Allow users to override the location of the optimizer executable by setting an environment variable EMSCRIPTEN_NATIVE_OPTIMIZER=/path/to/optimizer(.exe)
ifcompiler==shared.CLANG: raise# otherwise, OSError is likely due to g++ or clang++ not being in the path
ifos.path.exists(output): returnoutput
raiseNativeOptimizerCreationException()
use_cmake_to_configure=WINDOWS# Currently only Windows uses CMake to drive the optimizer build, but set this to True to use on other platforms as well.
# 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()
ifDEBUGandnotshared.WINDOWS: print>>sys.stderr, '.'# Skip debug progress indicator on Windows, since it doesn't buffer well with multiple threads printing to console.
returnfilename
exceptKeyboardInterrupt:
# avoid throwing keyboard interrupts from a child process
print>>sys.stderr, 'warning: Output contains some very large functions (%s lines in %s), consider building source files with -Os or -Oz, and/or trying OUTLINING_LIMIT to break them up (see settings.js; note that the parameter there affects AST nodes, while we measure lines here, so the two may not match up)'% (count, funcs[0][0])
forfuncinfuncs:
f.write(func[1])
funcs=None
else:
# just concat the outputs
forout_fileinfilenames:
f.write(open(out_file).read())
f.write('\n')
f.write(post);
# No need to write suffix: if there was one, it is inside post which exists when suffix is there