def run(filename, profile=False, main="run"): if profile: from tools.toolchain_profiler import ToolchainProfiler ToolchainProfiler.record_process_start() sys.exit( run_by_import(filename, main) if on_allowed_version( ) else run_by_subprocess(filename))
def main(): ToolchainProfiler.record_process_start() last = sys.argv[-1] if '{' in last: extra_info = json.loads(last) sys.argv = sys.argv[:-1] else: extra_info = None out = run(sys.argv[1], sys.argv[2:], extra_info=extra_info) shutil.copyfile(out, sys.argv[1] + '.jsopt.js') return 0
def run(filename): """Runs filename+'.py' in subprocess of the correct python version """ if os.environ.get('EM_PROFILE_TOOLCHAIN'): from tools.toolchain_profiler import ToolchainProfiler ToolchainProfiler.record_process_start() # In the future we might froce a particular python version here. # Python on Windows does not provide `python2` but instead `py` that receives version parameter # python = ['py', '-2'] if sys.platform.startswith('win') else ['python2'] python = sys.executable sys.exit( subprocess.call([python, os.path.realpath(filename) + '.py'] + sys.argv[1:]))
# TODO(sbc): Implement `ar x` within emscripten, in python, to avoid this issue # and delete this file. from __future__ import print_function import hashlib import os import shutil import sys from tools.toolchain_profiler import ToolchainProfiler from tools import shared from tools.response_file import substitute_response_files, create_response_file if __name__ == '__main__': ToolchainProfiler.record_process_start() # # Main run() function # def run(): args = substitute_response_files(sys.argv) newargs = [shared.LLVM_AR] + args[1:] to_delete = [] # The 3 argmuent form of ar doesn't involve other files. For example # 'ar x libfoo.a'. if len(newargs) > 3: cmd = newargs[1]
while i < len(newargs): if newargs[i].endswith('.a'): import hashlib, shutil for j in range(i+1, len(newargs)): orig_name = newargs[j] full_name = os.path.abspath(orig_name) dir_name = os.path.dirname(full_name) base_name = os.path.basename(full_name) h = hashlib.md5(full_name).hexdigest()[:8] parts = base_name.split('.') parts[0] += '_' + h newname = '.'.join(parts) full_newname = os.path.join(dir_name, newname) if not os.path.exists(full_newname): try: # it is ok to fail here, we just don't get hashing shutil.copyfile(orig_name, full_newname) newargs[j] = full_newname to_delete.append(full_newname) except: pass break i += 1 subprocess.call(newargs) for d in to_delete: shared.try_delete(d) if __name__ == '__main__': ToolchainProfiler.record_process_start() run() sys.exit(0)
def run(filename, profile=False, main="run"): if os.environ.get('EM_PROFILE_TOOLCHAIN'): from tools.toolchain_profiler import ToolchainProfiler ToolchainProfiler.record_process_start() sys.exit(run_by_import(filename, main) if on_allowed_version() else run_by_subprocess(filename))