예제 #1
0
파일: build.py 프로젝트: steelejoe/js.js
def translate(**kwargs):
    print("[START] - translate")

    js_combined_ll = util.abspath_join(BUILD_DIR_ABS, "./js_combined.ll")
    if not os.path.isfile(js_combined_ll):
        sys.stderr.write(
            "Could not find expected LLVM output file at '%s'.\n" %
            js_combined_ll)
        sys.stderr.write("Did you forget to run ./build.py compile ?\n")
        sys.exit(1)

    libjs_ll = util.abspath_join(BUILD_DIR_ABS, "./libjs.ll")
    if not os.path.isfile(libjs_ll):
        sys.stderr.write(
            "Could not find expected LLVM output file at '%s'.\n" % libjs_ll)
        sys.stderr.write("Did you forget to run ./build.py compile ?\n")
        sys.exit(1)

    js_js_path = get_jsjs_out(kwargs['out'])

    added_env = dict(EMCC_DEBUG='1')

    opt_level = kwargs['O']
    extra_args = ['-O' + str(opt_level)]

    if opt_level == 0:
        added_env['EMCC_LEAVE_INPUTS_RAW'] = '1'

    if opt_level != 0:
        extra_args.extend(['-s', 'ASMJS=1'])

    extra_args.extend(['--typed-arrays', '2'])
    extra_args.extend(['--closure', str(kwargs['closure'])])
    extra_args.extend(['-s', 'LABEL_DEBUG=%d' % kwargs['label_debug']])

    extra_args.extend(['-s', 'DISABLE_EXCEPTION_CATCHING=0'])

    if kwargs['library_only']:
        extra_args.extend(['-s', 'CLOSURE_ANNOTATIONS=1'])
        extra_args.extend(['-s', 'INCLUDE_FULL_LIBRARY=1'])

    args = [get_emcc_path()]
    args.extend(extra_args)
    args.extend(['-o', js_js_path])
    args.append(libjs_ll if kwargs['library_only'] else js_combined_ll)

    util.run_command(args, added_env=added_env, cwd=BUILD_DIR_ABS)

    #FIXME: we could detect bad return value from emscripten, but it
    # returns 0, even when it fails!
    if not os.path.isfile(js_js_path):
        sys.stderr.write("Translation failed.\n")
        sys.exit(1)

    print("js.js at '%s'" % js_js_path)

    print("[DONE] - translate")
예제 #2
0
파일: build.py 프로젝트: graingert/js.js
def translate(**kwargs):
    print("[START] - translate")
    
    js_combined_ll = util.abspath_join(BUILD_DIR_ABS, "./js_combined.ll")
    if not os.path.isfile(js_combined_ll):
        sys.stderr.write("Could not find expected LLVM output file at '%s'.\n" % js_combined_ll)
        sys.stderr.write("Did you forget to run ./build.py compile ?\n")
        sys.exit(1)
        
    libjs_ll = util.abspath_join(BUILD_DIR_ABS, "./libjs.ll")
    if not os.path.isfile(libjs_ll):
        sys.stderr.write("Could not find expected LLVM output file at '%s'.\n" % libjs_ll)
        sys.stderr.write("Did you forget to run ./build.py compile ?\n")
        sys.exit(1)
    
    js_js_path = get_jsjs_out(kwargs['out'])

    added_env = dict(EMCC_DEBUG='1')
    
    opt_level = kwargs['O']
    extra_args = ['-O' + str(opt_level)]
    
    if opt_level == 0:
        added_env['EMCC_LEAVE_INPUTS_RAW']='1'
    
    if opt_level != 0:
	extra_args.extend(['-s', 'ASMJS=1'])

    extra_args.extend(['--typed-arrays', '2'])
    extra_args.extend(['--closure', str(kwargs['closure'])])
    extra_args.extend(['-s', 'LABEL_DEBUG=%d' % kwargs['label_debug']])
    
    extra_args.extend(['-s', 'DISABLE_EXCEPTION_CATCHING=0'])
    
    if kwargs['library_only']:
        extra_args.extend(['-s', 'CLOSURE_ANNOTATIONS=1'])
        extra_args.extend(['-s', 'INCLUDE_FULL_LIBRARY=1'])
    
    args = [get_emcc_path()]
    args.extend(extra_args)
    args.extend(['-o', js_js_path])
    args.append(libjs_ll if kwargs['library_only'] else js_combined_ll)
    
    util.run_command(args, added_env=added_env, cwd=BUILD_DIR_ABS)
       
    #FIXME: we could detect bad return value from emscripten, but it
    # returns 0, even when it fails!
    if not os.path.isfile(js_js_path):
        sys.stderr.write("Translation failed.\n")
        sys.exit(1)
        
    print("js.js at '%s'" % js_js_path)
    
    print("[DONE] - translate")
예제 #3
0
def multiconfig(**kwargs):
    jsjswrapper = util.abspath_join(ROOTDIR, "./src/jsjs-wrapper.js")
    if not os.path.isfile(jsjswrapper):
        sys.stderr.write("Failed to find wrapper file '%s'." % jsjswrapper)
        sys.exit(1)

    for opt_level in [0, 1, 2]:
        for library_only in [True, False]:

            base = "libjs" if library_only else "js"
            base_filename = '%s.O%d' % (base, opt_level)
            uncompressed_filename = base_filename + '.js'

            args = {
                'O': opt_level,
                'closure': 0,
                'label_debug': 0,
                'out': uncompressed_filename,
                'library_only': library_only
            }

            print("Working on generating '%s'." % uncompressed_filename)
            translate(**args)

            compressed_filename = util.abspath_join(BUILD_DIR_ABS,
                                                    base_filename + ".min.js")
            uncompressed_filename = util.abspath_join(BUILD_DIR_ABS,
                                                      uncompressed_filename)

            closure_path = get_closure_compiler_path()

            print("Working on closure compiling '%s' into '%s'." %
                  (uncompressed_filename, compressed_filename))

            closure_args = [
                "java", "-jar", closure_path, "--compilation_level",
                "ADVANCED_OPTIMIZATIONS", "--js_output_file",
                compressed_filename, "--js", uncompressed_filename
            ]

            if library_only:
                closure_args.append(jsjswrapper)

            retcode = util.run_command(closure_args)

            if retcode != 0:
                sys.stderr.write("Closure compiling failed.")
                sys.exit(1)
예제 #4
0
def multiconfig(**kwargs):
    jsjswrapper = util.abspath_join(ROOTDIR, "./src/jsjs-wrapper.js")
    if not os.path.isfile(jsjswrapper):
        sys.stderr.write("Failed to find wrapper file '%s'." % jsjswrapper)
        sys.exit(1)
    
    for opt_level in [0, 1, 2]:
        for library_only in [True, False]:

            base = "libjs" if library_only else "js"
            base_filename = '%s.O%d' % (base, opt_level)
            uncompressed_filename = base_filename + '.js'
            
            args = {'O': opt_level,
                    'closure': 0,
                    'label_debug': 0,
                    'out': uncompressed_filename,
                    'library_only': library_only}
            
            print("Working on generating '%s'." % uncompressed_filename)
            translate(**args)
            
            compressed_filename = util.abspath_join(BUILD_DIR_ABS, base_filename + ".min.js")
            uncompressed_filename = util.abspath_join(BUILD_DIR_ABS, uncompressed_filename)
            
            closure_path = get_closure_compiler_path()
            
            print("Working on closure compiling '%s' into '%s'." % (uncompressed_filename, compressed_filename))
            
            closure_args = ["java",
                            "-jar", closure_path,
                            "--compilation_level", "ADVANCED_OPTIMIZATIONS",
                            "--js_output_file", compressed_filename,
                            "--js", uncompressed_filename]
            
            if library_only:
                closure_args.append(jsjswrapper)
            
            retcode = util.run_command(closure_args)
            
            if retcode != 0:
                sys.stderr.write("Closure compiling failed.")
                sys.exit(1)            
예제 #5
0
def get_nodejs_dir():
    return util.abspath_join(BUILD_DIR_ABS, conf.NODEJS_DIR, "node-v0.6.7")
예제 #6
0
import urllib
import zipfile
import shutil
import filecmp
import tempfile
import tarfile
import subprocess

import conf
import jsjs.util as util
import jsjs.compile_filters as compile_filters
from jsjs.filtering import filter_file
import jsjs.emscripten as emscripten

CURDIR = os.path.abspath(os.path.dirname(__file__))
ROOTDIR = util.abspath_join(CURDIR, "..")
BUILD_DIR_ABS = util.abspath_join(CURDIR, conf.BUILD_DIR)
NEEDED_COMMANDS = [("hg", "Mercurial"),
                   ("git", "Git"),
                   ("svn", "Subversion"),
                   ("make", "Make"),
                   ("autoreconf2.13", "autoreconf 2.13"),
                   ("scons", "SCons"),
                   ("java", "Java VM")]

def ensure_needed_commands():
    for command, name in NEEDED_COMMANDS:
        if util.which(command) is None:
            sys.stderr.write(("Could not find command: '%s'\n" + 
                             "Install %s and be sure that '%s' is on the path.\n")
                             % (command, name, command))
예제 #7
0
def get_closure_compiler_path():
    return util.abspath_join(BUILD_DIR_ABS, conf.CLOSURE_COMPILER_DIR,
                             "compiler.jar")
예제 #8
0
def get_emconfigure_path():
    return util.abspath_join(get_emscripten_dir(), "emconfigure")
예제 #9
0
파일: build.py 프로젝트: steelejoe/js.js
def get_llvm_bindir():
    return util.abspath_join(get_llvm_dir(), "Release+Asserts/bin")
예제 #10
0
def get_v8_path():
    return util.abspath_join(BUILD_DIR_ABS, conf.V8_DIR, "d8")
예제 #11
0
def get_v8_path():
    return util.abspath_join(BUILD_DIR_ABS, conf.V8_DIR, "d8")
예제 #12
0
def get_emconfigure_path():
    return util.abspath_join(get_emscripten_dir(), "emconfigure")
예제 #13
0
파일: build.py 프로젝트: steelejoe/js.js
def get_native_spidermonkey_path():
    return util.abspath_join(get_native_spidermonkey_exes_path(), "shell/js")
예제 #14
0
파일: build.py 프로젝트: graingert/js.js
def compile(**kwargs):
    print("[START] - compile")
    
    mozdir = util.abspath_join(BUILD_DIR_ABS, conf.SPIDERMONKEY_DIR)
    js_src_dir = util.abspath_join(mozdir, "js/src")
    spidermonkey_build_path = util.abspath_join(js_src_dir, "results_js")
    print("Using SpiderMonkey js/src directory: '%s'" % js_src_dir)

    # clean up the spidermonkey folder   
    if os.path.exists(spidermonkey_build_path):
        shutil.rmtree(spidermonkey_build_path)
    os.makedirs(spidermonkey_build_path)
    #util.run_command(["hg", "revert"], cwd=mozdir)    
    #os.remove(util.abspath_join(js_src_dir, "configure"))
    if not util.is_exe(util.abspath_join(js_src_dir, "./configure")):
        util.run_command(["autoreconf2.13"], cwd=js_src_dir)
    
    emconfigure = get_emconfigure_path()
    
    configure_line = [emconfigure,
                      "../configure",
                      "--disable-methodjit",
                      "--disable-monoic",
                      "--disable-polyic",
                      "--disable-tracejit",
                      "--disable-methodjit-spew",
                      "--disable-tests",
                      "--disable-debug",
                      "--disable-optimize"
                      ]
    
    os.environ['EMCC_LLVM_TARGET'] = 'i386-pc-linux-gnu' # Avoid vaarg type issues in Emscripten

    makefile_path = util.abspath_join(spidermonkey_build_path, "./Makefile")
    if not os.path.isfile(makefile_path):
        util.run_command(configure_line, cwd=spidermonkey_build_path)
    
    filter_file(makefile_path, compile_filters.makefile_filters)
    
    jsapi_h_path = util.abspath_join(js_src_dir, "./jsapi.h")
    filter_file(jsapi_h_path, compile_filters.jsapi_filters)
    
    MacroAssemblerX86Common_h_path = util.abspath_join(js_src_dir, "./assembler/assembler/MacroAssemblerX86Common.h")
    filter_file(MacroAssemblerX86Common_h_path, compile_filters.MacroAssemblerX86Common_filters)
    
    MacroAssemblerX86Common_cpp_path = util.abspath_join(js_src_dir, "./assembler/assembler/MacroAssemblerX86Common.cpp")
    filter_file(MacroAssemblerX86Common_cpp_path, compile_filters.MacroAssemblerX86Common_cpp_filters)
    
    ExecutableAllocator_h_path = util.abspath_join(js_src_dir, "./assembler/jit/ExecutableAllocator.h")
    filter_file(ExecutableAllocator_h_path, compile_filters.ExecutableAllocator_filters)
    
    expandlibs_config_path = util.abspath_join(spidermonkey_build_path, "./config/expandlibs_config.py")
    filter_file(expandlibs_config_path, compile_filters.expandlibs_config_filters)
    
    jsgcchunk_cpp_path = util.abspath_join(js_src_dir, "./jsgcchunk.cpp")
    filter_file(jsgcchunk_cpp_path, compile_filters.jsgchunk_cpp_filters)
    
    jsinfer_cpp_path = util.abspath_join(js_src_dir, "./jsinfer.cpp")
    filter_file(jsinfer_cpp_path, compile_filters.jsinfer_cpp_filters)
    
    platform_h_path = util.abspath_join(js_src_dir, "./assembler/wtf/Platform.h")
    filter_file(platform_h_path, compile_filters.platform_h_filters)
    
    pcre_exec_cpp_path = util.abspath_join(js_src_dir, "./yarr/pcre/pcre_exec.cpp")
    filter_file(pcre_exec_cpp_path, compile_filters.pcre_exec_cpp_filters)
    
    jsval_h_path = util.abspath_join(js_src_dir, "./jsval.h")
    filter_file(jsval_h_path, compile_filters.jsval_h_filters)
    
    jsinterp_cpp_path = util.abspath_join(js_src_dir, "./jsinterp.cpp")
    filter_file(jsinterp_cpp_path, compile_filters.jsinterp_cpp_filters)
    
    js_shell_bc_out = util.abspath_join(spidermonkey_build_path, "./shell/js")
    libjs_static_out = util.abspath_join(spidermonkey_build_path, "./libjs_static.a")
    make_success = os.path.exists(libjs_static_out) and os.path.exists(js_shell_bc_out)
    
    if not make_success:
        js_dist_path = util.abspath_join(spidermonkey_build_path, "dist")
        if not os.path.exists(js_dist_path):
            os.makedirs(js_dist_path)
        js_bin_path = util.abspath_join(js_dist_path, "bin")
        if not os.path.islink(js_bin_path):
            os.symlink(util.abspath_join(get_native_spidermonkey_exes_path(), "dist/bin"), js_bin_path)

        util.run_command(["make", "-C", "config"], cwd=spidermonkey_build_path)
        util.run_command(["make", "jsautocfg.h"], cwd=spidermonkey_build_path)

        jscpucfg_h_path = util.abspath_join(js_src_dir, "./jscpucfg.h")
        filter_file(jscpucfg_h_path, compile_filters.jscpucfg_filters)

        jsautocfg_h_path = util.abspath_join(spidermonkey_build_path, "./jsautocfg.h")
        filter_file(jsautocfg_h_path, compile_filters.jscpucfg_filters)
        
        jsconfig_h_path = util.abspath_join(spidermonkey_build_path, "./js-config.h")
        filter_file(jsconfig_h_path, compile_filters.jsconfig_filters)
        
        jsconfdefs_h_path = util.abspath_join(spidermonkey_build_path, "./js-confdefs.h")
        filter_file(jsconfdefs_h_path, compile_filters.jsconfdefs_filters)
        
        jstypes_h_path = util.abspath_join(js_src_dir, "./jstypes.h")
        filter_file(jstypes_h_path, compile_filters.jstypes_h_filters)
        
        build_args = ['make']
        opt_level = kwargs['O']
        if opt_level != 0:
	    build_args.extend(['-j7'])
        util.run_command(build_args, cwd=spidermonkey_build_path, added_env={"EMCC_DEBUG": "1"})
    
    make_success = os.path.exists(libjs_static_out) and os.path.exists(js_shell_bc_out)
    if not make_success:
        sys.stderr.write("Failed to build spidermonkey. Exiting.\n")
        sys.exit(1)
    
    o_files = subprocess.check_output([get_llvm_ar_path(), 't', libjs_static_out]).strip().split("\n")

    js_combined_bc = util.abspath_join(BUILD_DIR_ABS, "./js_combined.bc")
    js_combined_ll = util.abspath_join(BUILD_DIR_ABS, "./js_combined.ll")
    libjs_ll = util.abspath_join(BUILD_DIR_ABS, "./libjs.ll")
    libjs_bc = util.abspath_join(BUILD_DIR_ABS, "./libjs.bc")

    command = [get_llvm_link_path(), '-o', libjs_bc]
    command.extend(o_files)
    util.run_command(command, cwd=spidermonkey_build_path)
    util.run_command([get_llvm_dis_path(), '-show-annotations', '-o', libjs_ll, libjs_bc])

    js_shell_o_out = util.abspath_join(spidermonkey_build_path, "./shell/js.o")
    jsheaptools_o = util.abspath_join(spidermonkey_build_path, "./shell/jsheaptools.o")
    jsoptparse_o = util.abspath_join(spidermonkey_build_path, "./shell/jsoptparse.o")
    jsworkers_o = util.abspath_join(spidermonkey_build_path, "./shell/jsworkers.o")
    util.run_command([get_llvm_link_path(), '-o', js_combined_bc, libjs_bc, js_shell_o_out, jsheaptools_o, jsoptparse_o, jsworkers_o])
    util.run_command([get_llvm_dis_path(), '-show-annotations', '-o', js_combined_ll, js_combined_bc])
    
    if not os.path.isfile(js_combined_ll):
        sys.stderr.write("Failed to build combined LLVM file.\n")
        sys.exit(1)
    
    print("Built LLVM file:\n -- %s" % js_combined_ll)
    print(" -- %g MB" % (float(os.path.getsize(js_combined_ll)) / 1024 / 1024,))
    
    print("[DONE] - compile")
예제 #15
0
파일: build.py 프로젝트: steelejoe/js.js
def get_native_spidermonkey_exes_path():
    return util.abspath_join(BUILD_DIR_ABS, conf.SPIDERMONKEY_DIR,
                             "js/src/results_native")
예제 #16
0
파일: build.py 프로젝트: steelejoe/js.js
def get_llvm_dis_path():
    return util.abspath_join(get_llvm_dir(), "Release+Asserts/bin/llvm-dis")
예제 #17
0
파일: build.py 프로젝트: steelejoe/js.js
def get_clang_path():
    return util.abspath_join(get_llvm_dir(), "Release+Asserts/bin/clang")
예제 #18
0
def get_llvm_bindir():
    return util.abspath_join(get_llvm_dir(), "Debug/bin")
예제 #19
0
def get_jsjs_out(filename="js.js"):
    return util.abspath_join(BUILD_DIR_ABS, "./%s" % filename)
예제 #20
0
def get_llvm_link_path():
    return util.abspath_join(get_llvm_dir(), "Debug/bin/llvm-link")
예제 #21
0
파일: build.py 프로젝트: steelejoe/js.js
def compile(**kwargs):
    print("[START] - compile")

    mozdir = util.abspath_join(BUILD_DIR_ABS, conf.SPIDERMONKEY_DIR)
    js_src_dir = util.abspath_join(mozdir, "js/src")
    spidermonkey_build_path = util.abspath_join(js_src_dir, "results_js")
    print("Using SpiderMonkey js/src directory: '%s'" % js_src_dir)

    # clean up the spidermonkey folder
    if os.path.exists(spidermonkey_build_path):
        shutil.rmtree(spidermonkey_build_path)
    os.makedirs(spidermonkey_build_path)
    #util.run_command(["hg", "revert"], cwd=mozdir)
    #os.remove(util.abspath_join(js_src_dir, "configure"))
    if not util.is_exe(util.abspath_join(js_src_dir, "./configure")):
        util.run_command(["autoreconf2.13"], cwd=js_src_dir)

    emconfigure = get_emconfigure_path()

    configure_line = [
        emconfigure, "../configure", "--disable-methodjit", "--disable-monoic",
        "--disable-polyic", "--disable-tracejit", "--disable-methodjit-spew",
        "--disable-tests", "--disable-debug", "--disable-optimize"
    ]

    os.environ[
        'EMCC_LLVM_TARGET'] = 'i386-pc-linux-gnu'  # Avoid vaarg type issues in Emscripten

    makefile_path = util.abspath_join(spidermonkey_build_path, "./Makefile")
    if not os.path.isfile(makefile_path):
        util.run_command(configure_line, cwd=spidermonkey_build_path)

    filter_file(makefile_path, compile_filters.makefile_filters)

    jsapi_h_path = util.abspath_join(js_src_dir, "./jsapi.h")
    filter_file(jsapi_h_path, compile_filters.jsapi_filters)

    MacroAssemblerX86Common_h_path = util.abspath_join(
        js_src_dir, "./assembler/assembler/MacroAssemblerX86Common.h")
    filter_file(MacroAssemblerX86Common_h_path,
                compile_filters.MacroAssemblerX86Common_filters)

    MacroAssemblerX86Common_cpp_path = util.abspath_join(
        js_src_dir, "./assembler/assembler/MacroAssemblerX86Common.cpp")
    filter_file(MacroAssemblerX86Common_cpp_path,
                compile_filters.MacroAssemblerX86Common_cpp_filters)

    ExecutableAllocator_h_path = util.abspath_join(
        js_src_dir, "./assembler/jit/ExecutableAllocator.h")
    filter_file(ExecutableAllocator_h_path,
                compile_filters.ExecutableAllocator_filters)

    expandlibs_config_path = util.abspath_join(
        spidermonkey_build_path, "./config/expandlibs_config.py")
    filter_file(expandlibs_config_path,
                compile_filters.expandlibs_config_filters)

    jsgcchunk_cpp_path = util.abspath_join(js_src_dir, "./jsgcchunk.cpp")
    filter_file(jsgcchunk_cpp_path, compile_filters.jsgchunk_cpp_filters)

    jsinfer_cpp_path = util.abspath_join(js_src_dir, "./jsinfer.cpp")
    filter_file(jsinfer_cpp_path, compile_filters.jsinfer_cpp_filters)

    platform_h_path = util.abspath_join(js_src_dir,
                                        "./assembler/wtf/Platform.h")
    filter_file(platform_h_path, compile_filters.platform_h_filters)

    pcre_exec_cpp_path = util.abspath_join(js_src_dir,
                                           "./yarr/pcre/pcre_exec.cpp")
    filter_file(pcre_exec_cpp_path, compile_filters.pcre_exec_cpp_filters)

    jsval_h_path = util.abspath_join(js_src_dir, "./jsval.h")
    filter_file(jsval_h_path, compile_filters.jsval_h_filters)

    jsinterp_cpp_path = util.abspath_join(js_src_dir, "./jsinterp.cpp")
    filter_file(jsinterp_cpp_path, compile_filters.jsinterp_cpp_filters)

    js_shell_bc_out = util.abspath_join(spidermonkey_build_path, "./shell/js")
    libjs_static_out = util.abspath_join(spidermonkey_build_path,
                                         "./libjs_static.a")
    make_success = os.path.exists(libjs_static_out) and os.path.exists(
        js_shell_bc_out)

    if not make_success:
        js_dist_path = util.abspath_join(spidermonkey_build_path, "dist")
        if not os.path.exists(js_dist_path):
            os.makedirs(js_dist_path)
        js_bin_path = util.abspath_join(js_dist_path, "bin")
        if not os.path.islink(js_bin_path):
            os.symlink(
                util.abspath_join(get_native_spidermonkey_exes_path(),
                                  "dist/bin"), js_bin_path)

        util.run_command(["make", "-C", "config"], cwd=spidermonkey_build_path)
        util.run_command(["make", "jsautocfg.h"], cwd=spidermonkey_build_path)

        jscpucfg_h_path = util.abspath_join(js_src_dir, "./jscpucfg.h")
        filter_file(jscpucfg_h_path, compile_filters.jscpucfg_filters)

        jsautocfg_h_path = util.abspath_join(spidermonkey_build_path,
                                             "./jsautocfg.h")
        filter_file(jsautocfg_h_path, compile_filters.jscpucfg_filters)

        jsconfig_h_path = util.abspath_join(spidermonkey_build_path,
                                            "./js-config.h")
        filter_file(jsconfig_h_path, compile_filters.jsconfig_filters)

        jsconfdefs_h_path = util.abspath_join(spidermonkey_build_path,
                                              "./js-confdefs.h")
        filter_file(jsconfdefs_h_path, compile_filters.jsconfdefs_filters)

        jstypes_h_path = util.abspath_join(js_src_dir, "./jstypes.h")
        filter_file(jstypes_h_path, compile_filters.jstypes_h_filters)

        build_args = ['make']
        opt_level = kwargs['O']
        if opt_level != 0:
            build_args.extend(['-j7'])
        util.run_command(build_args,
                         cwd=spidermonkey_build_path,
                         added_env={"EMCC_DEBUG": "1"})

    make_success = os.path.exists(libjs_static_out) and os.path.exists(
        js_shell_bc_out)
    if not make_success:
        sys.stderr.write("Failed to build spidermonkey. Exiting.\n")
        sys.exit(1)

    o_files = subprocess.check_output(
        [get_llvm_ar_path(), 't', libjs_static_out]).strip().split("\n")

    js_combined_bc = util.abspath_join(BUILD_DIR_ABS, "./js_combined.bc")
    js_combined_ll = util.abspath_join(BUILD_DIR_ABS, "./js_combined.ll")
    libjs_ll = util.abspath_join(BUILD_DIR_ABS, "./libjs.ll")
    libjs_bc = util.abspath_join(BUILD_DIR_ABS, "./libjs.bc")

    command = [get_llvm_link_path(), '-o', libjs_bc]
    command.extend(o_files)
    util.run_command(command, cwd=spidermonkey_build_path)
    util.run_command(
        [get_llvm_dis_path(), '-show-annotations', '-o', libjs_ll, libjs_bc])

    js_shell_o_out = util.abspath_join(spidermonkey_build_path, "./shell/js.o")
    jsheaptools_o = util.abspath_join(spidermonkey_build_path,
                                      "./shell/jsheaptools.o")
    jsoptparse_o = util.abspath_join(spidermonkey_build_path,
                                     "./shell/jsoptparse.o")
    jsworkers_o = util.abspath_join(spidermonkey_build_path,
                                    "./shell/jsworkers.o")
    util.run_command([
        get_llvm_link_path(), '-o', js_combined_bc, libjs_bc, js_shell_o_out,
        jsheaptools_o, jsoptparse_o, jsworkers_o
    ])
    util.run_command([
        get_llvm_dis_path(), '-show-annotations', '-o', js_combined_ll,
        js_combined_bc
    ])

    if not os.path.isfile(js_combined_ll):
        sys.stderr.write("Failed to build combined LLVM file.\n")
        sys.exit(1)

    print("Built LLVM file:\n -- %s" % js_combined_ll)
    print(" -- %g MB" %
          (float(os.path.getsize(js_combined_ll)) / 1024 / 1024, ))

    print("[DONE] - compile")
예제 #22
0
def get_closure_compiler_path():
    return util.abspath_join(BUILD_DIR_ABS, conf.CLOSURE_COMPILER_DIR, "compiler.jar")
예제 #23
0
파일: build.py 프로젝트: graingert/js.js
def get_llvm_bindir():
    return util.abspath_join(get_llvm_dir(), "Release+Asserts/bin")
예제 #24
0
def get_nodejs_dir():
    return util.abspath_join(BUILD_DIR_ABS, conf.NODEJS_DIR, "node-v0.6.7")
예제 #25
0
파일: build.py 프로젝트: graingert/js.js
def get_clangpp_path():
    return util.abspath_join(get_llvm_dir(), "Release+Asserts/bin/clang++")
예제 #26
0
파일: build.py 프로젝트: Happy-Ferret/js.js
def get_llvm_dis_path():
    return util.abspath_join(get_llvm_dir(), "Debug+Asserts/bin/llvm-dis")
예제 #27
0
파일: build.py 프로젝트: graingert/js.js
def get_llvm_link_path():
    return util.abspath_join(get_llvm_dir(), "Release+Asserts/bin/llvm-link")
예제 #28
0
def get_spidermonkey_path():
    return util.abspath_join(BUILD_DIR_ABS, conf.SPIDERMONKEY_DIR,
                             "js/src/shell/js")
예제 #29
0
파일: build.py 프로젝트: graingert/js.js
def get_llvm_ar_path():
    return util.abspath_join(get_llvm_dir(), "Release+Asserts/bin/llvm-ar")
예제 #30
0
def get_emscripten_dir():
    return util.abspath_join(CURDIR, "../external/emscripten")
예제 #31
0
파일: build.py 프로젝트: graingert/js.js
def get_native_spidermonkey_exes_path():
    return util.abspath_join(BUILD_DIR_ABS, conf.SPIDERMONKEY_DIR, "js/src/results_native")
예제 #32
0
def get_emcc_path():
    return util.abspath_join(get_emscripten_dir(), "emcc")
예제 #33
0
파일: build.py 프로젝트: graingert/js.js
def get_native_spidermonkey_path():
    return util.abspath_join(get_native_spidermonkey_exes_path(), "shell/js")
예제 #34
0
def get_nodejs_path():
    return util.abspath_join(get_nodejs_dir(), "node")
예제 #35
0
import urllib
import zipfile
import shutil
import filecmp
import tempfile
import tarfile
import subprocess

import conf
import jsjs.util as util
import jsjs.compile_filters as compile_filters
from jsjs.filtering import filter_file
import jsjs.emscripten as emscripten

CURDIR = os.path.abspath(os.path.dirname(__file__))
ROOTDIR = util.abspath_join(CURDIR, "..")
BUILD_DIR_ABS = util.abspath_join(CURDIR, conf.BUILD_DIR)
NEEDED_COMMANDS = [("hg", "Mercurial"), ("git", "Git"), ("svn", "Subversion"),
                   ("make", "Make"), ("autoreconf2.13", "autoreconf 2.13"),
                   ("scons", "SCons"), ("java", "Java VM")]


def ensure_needed_commands():
    for command, name in NEEDED_COMMANDS:
        if util.which(command) is None:
            sys.stderr.write(
                ("Could not find command: '%s'\n" +
                 "Install %s and be sure that '%s' is on the path.\n") %
                (command, name, command))
            sys.exit(1)
예제 #36
0
def compile(**kwargs):
    print("[START] - compile")
    
    mozdir = util.abspath_join(BUILD_DIR_ABS, conf.MOZILLA_CENTRAL_DIR)
    js_src_dir = util.abspath_join(mozdir, "js/src")
    if not os.path.isdir(util.abspath_join(mozdir, "browser")):
        util.hg_clone(conf.MOZILLA_CENTRAL_URL, mozdir, conf.MOZILLA_CENTRAL_TAG)
    print("Using mozilla-central js/src directory: '%s'" % js_src_dir)
    
    if kwargs.get('clean', False):
        try:
            shutil.rmtree(js_src_dir)
        except OSError:
            pass
        
        util.run_command(["hg", "revert", "js/src"], cwd=mozdir)
    
    if not util.is_exe(util.abspath_join(js_src_dir, "./configure")):
        util.run_command(["autoreconf2.13"], cwd=js_src_dir)
    
    emconfigure = get_emconfigure_path()
    
    configure_line = [emconfigure,
                      "./configure",
                      "--disable-methodjit",
                      "--disable-monoic",
                      "--disable-polyic",
                      "--disable-tracejit",
                      "--disable-methodjit-spew",
                      "--disable-tests",
                      "--disable-debug",
                      "--disable-optimize"
                      ]
    
    makefile_path = util.abspath_join(js_src_dir, "./Makefile")
    if not os.path.isfile(makefile_path):
        util.run_command(configure_line, cwd=js_src_dir)
    
    filter_file(makefile_path, compile_filters.makefile_filters)
    
    jsapi_h_path = util.abspath_join(js_src_dir, "./jsapi.h")
    filter_file(jsapi_h_path, compile_filters.jsapi_filters)
    
    MacroAssemblerX86Common_h_path = util.abspath_join(js_src_dir, "./assembler/assembler/MacroAssemblerX86Common.h")
    filter_file(MacroAssemblerX86Common_h_path, compile_filters.MacroAssemblerX86Common_filters)
    
    MacroAssemblerX86Common_cpp_path = util.abspath_join(js_src_dir, "./assembler/assembler/MacroAssemblerX86Common.cpp")
    filter_file(MacroAssemblerX86Common_cpp_path, compile_filters.MacroAssemblerX86Common_cpp_filters)
    
    expandlibs_config_path = util.abspath_join(js_src_dir, "./config/expandlibs_config.py")
    filter_file(expandlibs_config_path, compile_filters.expandlibs_config_filters)
    
    jsgcchunk_cpp_path = util.abspath_join(js_src_dir, "./jsgcchunk.cpp")
    filter_file(jsgcchunk_cpp_path, compile_filters.jsgchunk_cpp_filters)
    
    jsinfer_cpp_path = util.abspath_join(js_src_dir, "./jsinfer.cpp")
    filter_file(jsinfer_cpp_path, compile_filters.jsinfer_cpp_filters)
    
    platform_h_path = util.abspath_join(js_src_dir, "./assembler/wtf/Platform.h")
    filter_file(platform_h_path, compile_filters.platform_h_filters)
    
    pcre_exec_cpp_path = util.abspath_join(js_src_dir, "./yarr/pcre/pcre_exec.cpp")
    filter_file(pcre_exec_cpp_path, compile_filters.pcre_exec_cpp_filters)
    
    jsval_h_path = util.abspath_join(js_src_dir, "./jsval.h")
    filter_file(jsval_h_path, compile_filters.jsval_h_filters)
    
    jsinterp_cpp_path = util.abspath_join(js_src_dir, "./jsinterp.cpp")
    filter_file(jsinterp_cpp_path, compile_filters.jsinterp_cpp_filters)
    
    js_shell_bc_out = util.abspath_join(js_src_dir, "./shell/js")
    libjs_static_out = util.abspath_join(js_src_dir, "./libjs_static.a")
    make_success = os.path.exists(libjs_static_out) and os.path.exists(js_shell_bc_out)
    
    if not make_success:
        util.run_command(["make", "-C", "config"], cwd=js_src_dir)
        util.run_command(["make", "jsautocfg.h"], cwd=js_src_dir)
        
        jscpucfg_h_path = util.abspath_join(js_src_dir, "./jscpucfg.h")
        filter_file(jscpucfg_h_path, compile_filters.jscpucfg_filters)
        jsautocfg_h_path = util.abspath_join(js_src_dir, "./jsautocfg.h")
        filter_file(jsautocfg_h_path, compile_filters.jscpucfg_filters)
        
        jsconfig_h_path = util.abspath_join(js_src_dir, "./js-config.h")
        filter_file(jsconfig_h_path, compile_filters.jsconfig_filters)
        
        jsconfdefs_h_path = util.abspath_join(js_src_dir, "./js-confdefs.h")
        filter_file(jsconfdefs_h_path, compile_filters.jsconfdefs_filters)
        
        jstypes_h_path = util.abspath_join(js_src_dir, "./jstypes.h")
        filter_file(jstypes_h_path, compile_filters.jstypes_h_filters)
        
        util.run_command(["make"], cwd=js_src_dir, added_env={"EMCC_DEBUG": "1"})
    
    make_success = os.path.exists(libjs_static_out) and os.path.exists(js_shell_bc_out)
    if not make_success:
        sys.stderr.write("Failed to build spidermonkey. Exiting.\n")
        sys.exit(1)
    
    o_files = subprocess.check_output([get_llvm_ar_path(), 't', libjs_static_out]).strip().split("\n")

    js_combined_bc = util.abspath_join(BUILD_DIR_ABS, "./js_combined.bc")
    js_combined_ll = util.abspath_join(BUILD_DIR_ABS, "./js_combined.ll")
    libjs_ll = util.abspath_join(BUILD_DIR_ABS, "./libjs.ll")
    libjs_bc = util.abspath_join(BUILD_DIR_ABS, "./libjs.bc")

    command = [get_llvm_link_path(), '-o', libjs_bc]
    command.extend(o_files)
    util.run_command(command, cwd=js_src_dir)
    util.run_command([get_llvm_dis_path(), '-show-annotations', '-o', libjs_ll, libjs_bc])

    js_shell_o_out = util.abspath_join(js_src_dir, "./shell/js.o")
    jsheaptools_o = util.abspath_join(js_src_dir, "./shell/jsheaptools.o")
    jsoptparse_o = util.abspath_join(js_src_dir, "./shell/jsoptparse.o")
    jsworkers_o = util.abspath_join(js_src_dir, "./shell/jsworkers.o")
    util.run_command([get_llvm_link_path(), '-o', js_combined_bc, libjs_bc, js_shell_o_out, jsheaptools_o, jsoptparse_o, jsworkers_o])
    util.run_command([get_llvm_dis_path(), '-show-annotations', '-o', js_combined_ll, js_combined_bc])
    
    if not os.path.isfile(js_combined_ll):
        sys.stderr.write("Failed to build combined LLVM file.\n")
        sys.exit(1)
    
    print("Built LLVM file:\n -- %s" % js_combined_ll)
    print(" -- %g MB" % (float(os.path.getsize(js_combined_ll)) / 1024 / 1024,))
    
    print("[DONE] - compile")
예제 #37
0
def get_jsjs_out(filename="js.js"):
    return util.abspath_join(BUILD_DIR_ABS, "./%s" % filename)
예제 #38
0
def get_llvm_dir():
    return util.abspath_join(BUILD_DIR_ABS, conf.LLVM_DIR)
예제 #39
0
def deps(**kwargs):
    print("[START] - deps")

    print("Checking for needed commands: " +
          ", ".join(c[0] for c in NEEDED_COMMANDS))
    ensure_needed_commands()

    print("Creating build directory: '%s'" % BUILD_DIR_ABS)
    util.mkdir(BUILD_DIR_ABS)

    llvmdir = get_llvm_dir()
    print("Checking for LLVM: '%s'" % llvmdir)
    if not os.path.isdir(util.abspath_join(llvmdir, "lib")):
        util.svn_co(conf.LLVM_URL, llvmdir)

    clangdir = util.abspath_join(llvmdir, "tools/clang")
    print("Checking for Clang: '%s'" % clangdir)
    if not os.path.isdir(util.abspath_join(clangdir, "lib")):
        util.svn_co(conf.CLANG_URL, clangdir)

    compilerrtdir = util.abspath_join(llvmdir, "projects/compiler-rt")
    print("Checking for Compiler RT: '%s'" % compilerrtdir)
    if not os.path.isdir(util.abspath_join(compilerrtdir, "lib")):
        util.svn_co(conf.COMPILER_RT_URL, compilerrtdir)

    if not os.path.exists(util.abspath_join(llvmdir, "Makefile.config")):
        util.run_command(["./configure"], cwd=llvmdir)

    clang_path = get_clang_path()
    clangpp_path = get_clangpp_path()
    clang_found = util.is_exe(clang_path) and util.is_exe(clangpp_path)
    if not clang_found:
        util.run_command(["make"], cwd=llvmdir)
    clang_found = util.is_exe(clang_path) and util.is_exe(clangpp_path)
    if not clang_found:
        sys.stderr.write("Failed to build LLVM clang/clang++\n")
        sys.exit(1)
    print("Using clang: " + clang_path)
    print("Using clang++: " + clangpp_path)

    v8dir = util.abspath_join(BUILD_DIR_ABS, conf.V8_DIR)
    print("Checking for V8: '%s'" % v8dir)
    if not os.path.isdir(util.abspath_join(v8dir, "src")):
        util.svn_co(conf.V8_URL, v8dir)
    v8_path = get_v8_path()
    if not util.is_exe(v8_path):
        util.run_command(["scons", "d8"], cwd=v8dir)
    if not util.is_exe(v8_path):
        sys.stderr.write("Failed to build v8 d8 executable\n")
        sys.exit(1)
    print("Using d8: " + v8_path)

    closure_compiler_dir = util.abspath_join(BUILD_DIR_ABS,
                                             conf.CLOSURE_COMPILER_DIR)
    util.mkdir(closure_compiler_dir)
    closure_compiler_zip = util.abspath_join(closure_compiler_dir,
                                             "compiler-latest.zip")
    if not os.path.isfile(closure_compiler_zip):
        print("Downloading '%s' -> '%s'" %
              (conf.CLOSURE_COMPILER_URL, closure_compiler_zip))
        urllib.urlretrieve(conf.CLOSURE_COMPILER_URL, closure_compiler_zip)
    closure_compiler = get_closure_compiler_path()
    if not os.path.isfile(closure_compiler):
        z = zipfile.ZipFile(closure_compiler_zip)
        z.extractall(path=closure_compiler_dir)
    if not os.path.isfile(closure_compiler):
        sys.stderr.write("Failed to get closure compiler\n")
        sys.exit(1)
    print("Using compiler.jar: " + closure_compiler)

    spidermonkey_dir = util.abspath_join(BUILD_DIR_ABS, conf.SPIDERMONKEY_DIR)
    print("Checking for SpiderMonkey: '%s'" % spidermonkey_dir)
    if not os.path.isdir(util.abspath_join(spidermonkey_dir, "browser")):
        util.hg_clone(conf.SPIDERMONKEY_URL, spidermonkey_dir,
                      conf.SPIDERMONKEY_TAG)
    spidermonkey_build_dir = util.abspath_join(spidermonkey_dir, "js/src")
    spidermonkey_path = get_spidermonkey_path()
    if not os.path.isfile(
            util.abspath_join(spidermonkey_build_dir, "configure")):
        util.run_command(["autoreconf2.13"], cwd=spidermonkey_build_dir)
    if not os.path.isfile(util.abspath_join(spidermonkey_build_dir,
                                            "Makefile")):
        util.run_command(["./configure"], cwd=spidermonkey_build_dir)
    if not util.is_exe(spidermonkey_path):
        util.run_command(["make"], cwd=spidermonkey_build_dir)
    if not util.is_exe(spidermonkey_path):
        sys.stderr.write("Failed to build SpiderMonkey js executable\n")
        sys.exit(1)
    print("Using js: " + spidermonkey_path)

    nodejs_dir = util.abspath_join(BUILD_DIR_ABS, conf.NODEJS_DIR)
    util.mkdir(nodejs_dir)
    nodejs_tgz = util.abspath_join(nodejs_dir,
                                   os.path.basename(conf.NODEJS_URL))
    if not os.path.isfile(nodejs_tgz):
        print("Downloading '%s' -> '%s'" % (conf.NODEJS_URL, nodejs_tgz))
        urllib.urlretrieve(conf.NODEJS_URL, nodejs_tgz)
    nodejs_dir_path = get_nodejs_dir()
    if not os.path.isfile(util.abspath_join(nodejs_dir_path, "./configure")):
        print("Extracting '%s' -> '%s'" % (nodejs_tgz, nodejs_dir))
        t = tarfile.open(nodejs_tgz)
        t.extractall(path=nodejs_dir)
    nodejs_path = get_nodejs_path()
    if not util.is_exe(nodejs_path):
        util.run_command(["./configure"], cwd=nodejs_dir_path)
        util.run_command(["make"], cwd=nodejs_dir_path)
    if not util.is_exe(nodejs_path):
        sys.stderr.write("Failed to build nodejs.\n")
        sys.exit(1)
    print("Using node: " + nodejs_path)

    emscripten_dir = get_emscripten_dir()
    print("Checking for emscripten: '%s'" % emscripten_dir)
    if not util.is_exe(util.abspath_join(emscripten_dir, "emscripten.py")):
        sys.stderr.write(
            "Could not find emscripten.py in emscripten directory '%s'.\n" %
            emscripten_dir)
        sys.stderr.write(
            "Did you forget to run 'git submodule update --init --recursive' after cloning?\n"
        )
        sys.exit(1)

    emscripten.write_emscripten_config(get_llvm_bindir(), get_v8_path(),
                                       get_closure_compiler_path(),
                                       get_emscripten_dir(),
                                       get_spidermonkey_path(),
                                       get_nodejs_path(),
                                       ['-Wno-return-type-c-linkage'])

    print("[DONE] - deps")
예제 #40
0
def get_clangpp_path():
    return util.abspath_join(get_llvm_dir(), "Debug/bin/clang++")
예제 #41
0
def compile(**kwargs):
    print("[START] - compile")

    mozdir = util.abspath_join(BUILD_DIR_ABS, conf.MOZILLA_CENTRAL_DIR)
    js_src_dir = util.abspath_join(mozdir, "js/src")
    if not os.path.isdir(util.abspath_join(mozdir, "browser")):
        util.hg_clone(conf.MOZILLA_CENTRAL_URL, mozdir,
                      conf.MOZILLA_CENTRAL_TAG)
    print("Using mozilla-central js/src directory: '%s'" % js_src_dir)

    if kwargs.get('clean', False):
        try:
            shutil.rmtree(js_src_dir)
        except OSError:
            pass

        util.run_command(["hg", "revert", "js/src"], cwd=mozdir)

    if not util.is_exe(util.abspath_join(js_src_dir, "./configure")):
        util.run_command(["autoreconf2.13"], cwd=js_src_dir)

    emconfigure = get_emconfigure_path()

    configure_line = [
        emconfigure, "./configure", "--disable-methodjit", "--disable-monoic",
        "--disable-polyic", "--disable-tracejit", "--disable-methodjit-spew",
        "--disable-tests", "--disable-debug", "--disable-optimize"
    ]

    makefile_path = util.abspath_join(js_src_dir, "./Makefile")
    if not os.path.isfile(makefile_path):
        util.run_command(configure_line, cwd=js_src_dir)

    filter_file(makefile_path, compile_filters.makefile_filters)

    jsapi_h_path = util.abspath_join(js_src_dir, "./jsapi.h")
    filter_file(jsapi_h_path, compile_filters.jsapi_filters)

    MacroAssemblerX86Common_h_path = util.abspath_join(
        js_src_dir, "./assembler/assembler/MacroAssemblerX86Common.h")
    filter_file(MacroAssemblerX86Common_h_path,
                compile_filters.MacroAssemblerX86Common_filters)

    MacroAssemblerX86Common_cpp_path = util.abspath_join(
        js_src_dir, "./assembler/assembler/MacroAssemblerX86Common.cpp")
    filter_file(MacroAssemblerX86Common_cpp_path,
                compile_filters.MacroAssemblerX86Common_cpp_filters)

    expandlibs_config_path = util.abspath_join(
        js_src_dir, "./config/expandlibs_config.py")
    filter_file(expandlibs_config_path,
                compile_filters.expandlibs_config_filters)

    jsgcchunk_cpp_path = util.abspath_join(js_src_dir, "./jsgcchunk.cpp")
    filter_file(jsgcchunk_cpp_path, compile_filters.jsgchunk_cpp_filters)

    jsinfer_cpp_path = util.abspath_join(js_src_dir, "./jsinfer.cpp")
    filter_file(jsinfer_cpp_path, compile_filters.jsinfer_cpp_filters)

    platform_h_path = util.abspath_join(js_src_dir,
                                        "./assembler/wtf/Platform.h")
    filter_file(platform_h_path, compile_filters.platform_h_filters)

    pcre_exec_cpp_path = util.abspath_join(js_src_dir,
                                           "./yarr/pcre/pcre_exec.cpp")
    filter_file(pcre_exec_cpp_path, compile_filters.pcre_exec_cpp_filters)

    jsval_h_path = util.abspath_join(js_src_dir, "./jsval.h")
    filter_file(jsval_h_path, compile_filters.jsval_h_filters)

    jsinterp_cpp_path = util.abspath_join(js_src_dir, "./jsinterp.cpp")
    filter_file(jsinterp_cpp_path, compile_filters.jsinterp_cpp_filters)

    js_shell_bc_out = util.abspath_join(js_src_dir, "./shell/js")
    libjs_static_out = util.abspath_join(js_src_dir, "./libjs_static.a")
    make_success = os.path.exists(libjs_static_out) and os.path.exists(
        js_shell_bc_out)

    if not make_success:
        util.run_command(["make", "-C", "config"], cwd=js_src_dir)
        util.run_command(["make", "jsautocfg.h"], cwd=js_src_dir)

        jscpucfg_h_path = util.abspath_join(js_src_dir, "./jscpucfg.h")
        filter_file(jscpucfg_h_path, compile_filters.jscpucfg_filters)
        jsautocfg_h_path = util.abspath_join(js_src_dir, "./jsautocfg.h")
        filter_file(jsautocfg_h_path, compile_filters.jscpucfg_filters)

        jsconfig_h_path = util.abspath_join(js_src_dir, "./js-config.h")
        filter_file(jsconfig_h_path, compile_filters.jsconfig_filters)

        jsconfdefs_h_path = util.abspath_join(js_src_dir, "./js-confdefs.h")
        filter_file(jsconfdefs_h_path, compile_filters.jsconfdefs_filters)

        jstypes_h_path = util.abspath_join(js_src_dir, "./jstypes.h")
        filter_file(jstypes_h_path, compile_filters.jstypes_h_filters)

        util.run_command(["make"],
                         cwd=js_src_dir,
                         added_env={"EMCC_DEBUG": "1"})

    make_success = os.path.exists(libjs_static_out) and os.path.exists(
        js_shell_bc_out)
    if not make_success:
        sys.stderr.write("Failed to build spidermonkey. Exiting.\n")
        sys.exit(1)

    o_files = subprocess.check_output(
        [get_llvm_ar_path(), 't', libjs_static_out]).strip().split("\n")

    js_combined_bc = util.abspath_join(BUILD_DIR_ABS, "./js_combined.bc")
    js_combined_ll = util.abspath_join(BUILD_DIR_ABS, "./js_combined.ll")
    libjs_ll = util.abspath_join(BUILD_DIR_ABS, "./libjs.ll")
    libjs_bc = util.abspath_join(BUILD_DIR_ABS, "./libjs.bc")

    command = [get_llvm_link_path(), '-o', libjs_bc]
    command.extend(o_files)
    util.run_command(command, cwd=js_src_dir)
    util.run_command(
        [get_llvm_dis_path(), '-show-annotations', '-o', libjs_ll, libjs_bc])

    js_shell_o_out = util.abspath_join(js_src_dir, "./shell/js.o")
    jsheaptools_o = util.abspath_join(js_src_dir, "./shell/jsheaptools.o")
    jsoptparse_o = util.abspath_join(js_src_dir, "./shell/jsoptparse.o")
    jsworkers_o = util.abspath_join(js_src_dir, "./shell/jsworkers.o")
    util.run_command([
        get_llvm_link_path(), '-o', js_combined_bc, libjs_bc, js_shell_o_out,
        jsheaptools_o, jsoptparse_o, jsworkers_o
    ])
    util.run_command([
        get_llvm_dis_path(), '-show-annotations', '-o', js_combined_ll,
        js_combined_bc
    ])

    if not os.path.isfile(js_combined_ll):
        sys.stderr.write("Failed to build combined LLVM file.\n")
        sys.exit(1)

    print("Built LLVM file:\n -- %s" % js_combined_ll)
    print(" -- %g MB" %
          (float(os.path.getsize(js_combined_ll)) / 1024 / 1024, ))

    print("[DONE] - compile")
예제 #42
0
def get_llvm_ar_path():
    return util.abspath_join(get_llvm_dir(), "Debug/bin/llvm-ar")
예제 #43
0
def get_llvm_dir():
    return util.abspath_join(BUILD_DIR_ABS, conf.LLVM_DIR)
예제 #44
0
def get_spidermonkey_path():
    return util.abspath_join(BUILD_DIR_ABS, conf.SPIDERMONKEY_DIR, "js/src/shell/js")
예제 #45
0
def get_llvm_bindir():
    return util.abspath_join(get_llvm_dir(), "Debug+Asserts/bin")
예제 #46
0
def get_emscripten_dir():
    return util.abspath_join(CURDIR, "../external/emscripten")
예제 #47
0
def get_clangpp_path():
    return util.abspath_join(get_llvm_dir(), "Debug+Asserts/bin/clang++")
예제 #48
0
def get_emcc_path():
    return util.abspath_join(get_emscripten_dir(), "emcc")
예제 #49
0
def get_llvm_link_path():
    return util.abspath_join(get_llvm_dir(), "Debug+Asserts/bin/llvm-link")
예제 #50
0
def get_nodejs_path():
    return util.abspath_join(get_nodejs_dir(), "node")
예제 #51
0
def get_llvm_ar_path():
    return util.abspath_join(get_llvm_dir(), "Debug+Asserts/bin/llvm-ar")
예제 #52
0
def deps(**kwargs):
    print("[START] - deps")
    
    print("Checking for needed commands: " + ", ".join(c[0] for c in NEEDED_COMMANDS))
    ensure_needed_commands()
    
    print("Creating build directory: '%s'" % BUILD_DIR_ABS)
    util.mkdir(BUILD_DIR_ABS)
    
    llvmdir = get_llvm_dir()
    print("Checking for LLVM: '%s'" % llvmdir)
    if not os.path.isdir(util.abspath_join(llvmdir, "lib")):
        util.svn_co(conf.LLVM_URL, llvmdir)
    
    clangdir = util.abspath_join(llvmdir, "tools/clang")
    print("Checking for Clang: '%s'" % clangdir)
    if not os.path.isdir(util.abspath_join(clangdir, "lib")):
        util.svn_co(conf.CLANG_URL, clangdir)
    
    compilerrtdir = util.abspath_join(llvmdir, "projects/compiler-rt")
    print("Checking for Compiler RT: '%s'" % compilerrtdir)
    if not os.path.isdir(util.abspath_join(compilerrtdir, "lib")):
        util.svn_co(conf.COMPILER_RT_URL, compilerrtdir)
    
    if not os.path.exists(util.abspath_join(llvmdir, "Makefile.config")):
        util.run_command(["./configure"], cwd=llvmdir)
    
    clang_path = get_clang_path()
    clangpp_path = get_clangpp_path()
    clang_found = util.is_exe(clang_path) and util.is_exe(clangpp_path)
    if not clang_found:
        util.run_command(["make"], cwd=llvmdir)
    clang_found = util.is_exe(clang_path) and util.is_exe(clangpp_path)
    if not clang_found:
        sys.stderr.write("Failed to build LLVM clang/clang++\n")
        sys.exit(1)
    print("Using clang: " + clang_path)
    print("Using clang++: " + clangpp_path)
    
    v8dir = util.abspath_join(BUILD_DIR_ABS, conf.V8_DIR)
    print("Checking for V8: '%s'" % v8dir)
    if not os.path.isdir(util.abspath_join(v8dir, "src")):
        util.svn_co(conf.V8_URL, v8dir)
    v8_path = get_v8_path()
    if not util.is_exe(v8_path):
        util.run_command(["scons", "d8"], cwd=v8dir)
    if not util.is_exe(v8_path):
        sys.stderr.write("Failed to build v8 d8 executable\n")
        sys.exit(1)
    print("Using d8: " + v8_path)
    
    closure_compiler_dir = util.abspath_join(BUILD_DIR_ABS, conf.CLOSURE_COMPILER_DIR)
    util.mkdir(closure_compiler_dir)
    closure_compiler_zip = util.abspath_join(closure_compiler_dir, "compiler-latest.zip")
    if not os.path.isfile(closure_compiler_zip):
        print("Downloading '%s' -> '%s'" % (conf.CLOSURE_COMPILER_URL, closure_compiler_zip))
        urllib.urlretrieve(conf.CLOSURE_COMPILER_URL, closure_compiler_zip)
    closure_compiler = get_closure_compiler_path()
    if not os.path.isfile(closure_compiler):
        z = zipfile.ZipFile(closure_compiler_zip)
        z.extractall(path=closure_compiler_dir)
    if not os.path.isfile(closure_compiler):
        sys.stderr.write("Failed to get closure compiler\n")
        sys.exit(1)
    print("Using compiler.jar: " + closure_compiler)
    
    spidermonkey_dir = util.abspath_join(BUILD_DIR_ABS, conf.SPIDERMONKEY_DIR)
    print("Checking for SpiderMonkey: '%s'" % spidermonkey_dir)
    if not os.path.isdir(util.abspath_join(spidermonkey_dir, "browser")):
        util.hg_clone(conf.SPIDERMONKEY_URL, spidermonkey_dir, conf.SPIDERMONKEY_TAG)
    spidermonkey_build_dir = util.abspath_join(spidermonkey_dir, "js/src")
    spidermonkey_path = get_spidermonkey_path()
    if not os.path.isfile(util.abspath_join(spidermonkey_build_dir, "configure")):
        util.run_command(["autoreconf2.13"], cwd=spidermonkey_build_dir)
    if not os.path.isfile(util.abspath_join(spidermonkey_build_dir, "Makefile")):
        util.run_command(["./configure"], cwd=spidermonkey_build_dir)
    if not util.is_exe(spidermonkey_path):
        util.run_command(["make"], cwd=spidermonkey_build_dir)
    if not util.is_exe(spidermonkey_path):
        sys.stderr.write("Failed to build SpiderMonkey js executable\n")
        sys.exit(1)
    print("Using js: " + spidermonkey_path)
    
    nodejs_dir = util.abspath_join(BUILD_DIR_ABS, conf.NODEJS_DIR)
    util.mkdir(nodejs_dir)
    nodejs_tgz = util.abspath_join(nodejs_dir, os.path.basename(conf.NODEJS_URL))
    if not os.path.isfile(nodejs_tgz):
        print("Downloading '%s' -> '%s'" % (conf.NODEJS_URL, nodejs_tgz))
        urllib.urlretrieve(conf.NODEJS_URL, nodejs_tgz)
    nodejs_dir_path = get_nodejs_dir()
    if not os.path.isfile(util.abspath_join(nodejs_dir_path, "./configure")):
        print("Extracting '%s' -> '%s'" % (nodejs_tgz, nodejs_dir))
        t = tarfile.open(nodejs_tgz)
        t.extractall(path=nodejs_dir)
    nodejs_path = get_nodejs_path()
    if not util.is_exe(nodejs_path):
        util.run_command(["./configure"], cwd=nodejs_dir_path)
        util.run_command(["make"], cwd=nodejs_dir_path)
    if not util.is_exe(nodejs_path):
        sys.stderr.write("Failed to build nodejs.\n")
        sys.exit(1)
    print("Using node: " + nodejs_path)
    
    emscripten_dir = get_emscripten_dir()
    print("Checking for emscripten: '%s'" % emscripten_dir)
    if not util.is_exe(util.abspath_join(emscripten_dir, "emscripten.py")):
        sys.stderr.write("Could not find emscripten.py in emscripten directory '%s'.\n" % emscripten_dir)
        sys.stderr.write("Did you forget to run 'git submodule update --init --recursive' after cloning?\n")
        sys.exit(1)
    
    emscripten.write_emscripten_config(get_llvm_bindir(),
                                       get_v8_path(),
                                       get_closure_compiler_path(),
                                       get_emscripten_dir(),
                                       get_spidermonkey_path(),
                                       get_nodejs_path())
    
    print("[DONE] - deps")
예제 #53
0
파일: build.py 프로젝트: Happy-Ferret/js.js
def get_clang_path():
    return util.abspath_join(get_llvm_dir(), "Debug+Asserts/bin/clang")