Пример #1
0
def main():
    args = parse_args()
    print("Building hermes using {} into {}".format(
        args.build_system, args.hermes_build_dir + os.path.sep))

    try:
        os.mkdir(args.hermes_build_dir)
    except OSError:
        # It's alright if the file already exists.
        pass

    cmake_flags = (args.cmake_flags.split() + common_cmake_flags() + [
        "-DLLVM_BUILD_DIR=" + args.llvm_build_dir,
        "-DLLVM_SRC_DIR=" + args.llvm_src_dir,
        "-DCMAKE_BUILD_TYPE=" + args.build_type,
    ])
    if args.is_32_bit:
        cmake_flags += ["-DLLVM_BUILD_32_BITS=On"]

    if (platform.system() == "Windows" and platform.machine().endswith("64")
            and is_visual_studio(args.build_system)):
        cmake_flags += ["-Thost=x64"]
    if not args.distribute:
        cmake_flags += ["-DLLVM_ENABLE_ASSERTIONS=On"]
    if args.enable_asan:
        cmake_flags += ["-DLLVM_USE_SANITIZER=Address"]
    if args.opcode_stats:
        cmake_flags += ["-DHERMESVM_PROFILER_OPCODE=On"]
    if args.basic_block_profiler:
        cmake_flags += ["-DHERMESVM_PROFILER_BB=On"]
    if args.warnings_as_errors:
        cmake_flags += ["-DHERMES_ENABLE_WERROR=On"]
    if args.static_link:
        cmake_flags += ["-DHERMES_STATIC_LINK=On"]
    if args.fbsource_dir:
        cmake_flags += ["-DFBSOURCE_DIR=" + args.fbsource_dir]

    if args.icu_root:
        cmake_flags += ["-DICU_ROOT=" + args.icu_root]
    elif (os.environ.get("SANDCASTLE") and platform.system() != "macos"
          and platform.system() != "Windows"):
        raise Exception("No ICU path provided on sandcastle")

    print("CMake flags: {}".format(" ".join(cmake_flags)))
    hermes_src_dir = os.path.realpath(__file__)
    # The hermes directory is three directories up from this file.
    # If this file is moved, make sure to update this.
    for _ in range(3):
        hermes_src_dir = os.path.dirname(hermes_src_dir)

    cmake = which("cmake")
    # Print the CMake version to assist in diagnosing issues.
    print("CMake version:\n{}".format(
        subprocess.check_output([cmake, "--version"],
                                stderr=subprocess.STDOUT)))
    run_command(
        [cmake, hermes_src_dir, "-G", args.build_system] + cmake_flags,
        env=os.environ,
        cwd=args.hermes_build_dir,
    )
Пример #2
0
def main():
    args = parse_args()

    print("Source Dir: {}".format(args.llvm_src_dir))
    print("Using Build system: {}".format(args.build_system))
    print("Build Dir: {}".format(args.llvm_build_dir))
    print("Build Type: {}".format(args.build_type))

    clone_and_patch_llvm(args)

    cmake_flags = (args.cmake_flags.split() + common_cmake_flags() + [
        "-DLLVM_TARGETS_TO_BUILD=", "-DCMAKE_BUILD_TYPE={}".format(
            args.build_type)
    ])
    if args.is_32_bit:
        cmake_flags += ["-DLLVM_BUILD_32_BITS=On"]
    if platform.system() == "Windows":
        if platform.machine().endswith("64") and is_visual_studio(
                args.build_system):
            cmake_flags += ["-Thost=x64"]
        cmake_flags += ["-DLLVM_INCLUDE_EXAMPLES=Off"]
    if args.enable_asan:
        cmake_flags += ["-DLLVM_USE_SANITIZER=Address"]
    cmake_flags += ["-DLLVM_VERSION_PRINTER_SHOW_HOST_TARGET_INFO=Off"]

    if args.target_platform.startswith("iphone"):
        cmake_flags += [
            "-DCMAKE_C_FLAGS=-miphoneos-version-min=8.0",
            "-DCMAKE_CXX_FLAGS=-miphoneos-version-min=8.0",
            "-DCMAKE_TOOLCHAIN_FILE={}".format(
                os.path.join(args.llvm_src_dir, "cmake", "platforms",
                             "iOS.cmake")),
            "-DLLVM_BUILD_RUNTIME=Off",
            "-DLLVM_INCLUDE_TESTS=Off",
            "-DLLVM_INCLUDE_EXAMPLES=Off",
            "-DLLVM_ENABLE_BACKTRACES=Off",
            "-DLLVM_INCLUDE_UTILS=Off",
            "-DLLVM_ENABLE_TERMINFO=Off",
        ]
    if args.target_platform == "iphoneos":
        cmake_flags += ["-DCMAKE_OSX_ARCHITECTURES=armv7;arm64"]
    elif args.target_platform == "iphonesimulator":
        xcode_sysroot = subprocess.check_output([
            which("xcodebuild"), "-version", "-sdk", "iphonesimulator", "Path"
        ])
        cmake_flags += [
            "-DCMAKE_OSX_ARCHITECTURES=x86_64",
            "-DCMAKE_OSX_SYSROOT={}".format(xcode_sysroot),
        ]
    elif args.target_platform == "macosx":
        cmake_flags += [
            "-DCMAKE_C_FLAGS=-mmacosx-version-min=10.9",
            "-DCMAKE_CXX_FLAGS=-mmacosx-version-min=10.9",
        ]

    try:
        os.mkdir(args.llvm_build_dir)
    except OSError:
        # It's alright if the file already exists.
        pass

    print("CMake flags: {}".format(" ".join(cmake_flags)))
    cmake = which("cmake")
    # Print the CMake version to assist in diagnosing issues.
    print("CMake version:\n{}".format(
        subprocess.check_output([cmake, "--version"],
                                stderr=subprocess.STDOUT)))

    run_command(
        [cmake, "-G", args.build_system, args.llvm_src_dir] + cmake_flags,
        env=os.environ,
        cwd=args.llvm_build_dir,
    )
    # MSBuild needs retries to handle an unexplainable linker error: LNK1000.
    # Retry the build in case of failures.
    tries = 3
    for i in range(tries):
        try:
            build_cmd = [cmake, "--build", args.llvm_build_dir]
            for target in args.target:
                build_cmd += ["--target", target]
            if args.distribute and is_visual_studio(args.build_system):
                build_cmd += ["--config", "Release"]
            run_command(build_cmd, env=os.environ)
            break
        except subprocess.CalledProcessError as e:
            if i == tries - 1:
                # If all retries failed, re-throw the last exception
                raise
            else:
                print("Exec failed: {}\nRetrying...".format(str(e)))
                continue
Пример #3
0
def main():
    args = parse_args()
    print("Building hermes using {} into {}".format(
        args.build_system, args.hermes_build_dir + os.path.sep))

    try:
        os.mkdir(args.hermes_build_dir)
    except OSError:
        # It's alright if the file already exists.
        pass

    cmake_flags = (args.cmake_flags.split() + common_cmake_flags() +
                   ["-DCMAKE_BUILD_TYPE=" + args.build_type])

    if (platform.system() == "Windows" and platform.machine().endswith("64")
            and is_visual_studio(args.build_system)):
        cmake_flags += ["-Thost=x64"]
    if args.opcode_stats:
        cmake_flags += ["-DHERMESVM_PROFILER_OPCODE=On"]
    if args.basic_block_profiler:
        cmake_flags += ["-DHERMESVM_PROFILER_BB=On"]
    if args.warnings_as_errors:
        cmake_flags += ["-DHERMES_ENABLE_WERROR=On"]
    if args.static_link:
        cmake_flags += ["-DHERMES_STATIC_LINK=On"]
    if args.fbsource_dir:
        cmake_flags += ["-DFBSOURCE_DIR=" + args.fbsource_dir]
    if args.wasm:
        cmake_flags += [
            "-DCMAKE_TOOLCHAIN_FILE={}".format(
                os.path.join(
                    args.emscripten_root,
                    "cmake",
                    "Modules",
                    "Platform",
                    "Emscripten.cmake",
                )),
            "-DCMAKE_EXE_LINKER_FLAGS="
            "-s NODERAWFS=1 -s WASM=1 -s ALLOW_MEMORY_GROWTH=1",
        ]
        if args.emscripten_platform == "fastcomp":
            cmake_flags += ["-DEMSCRIPTEN_FASTCOMP=1"]

    if args.icu_root:
        cmake_flags += ["-DICU_ROOT=" + args.icu_root]
    elif os.environ.get("SANDCASTLE") and platform.system() not in (
            "macos",
            "Darwin",
            "Windows",
    ):
        raise Exception("No ICU path provided on sandcastle")

    print("CMake flags: {}".format(" ".join(cmake_flags)))
    hermes_src_dir = os.path.realpath(__file__)
    # The hermes directory is three directories up from this file.
    # If this file is moved, make sure to update this.
    for _ in range(3):
        hermes_src_dir = os.path.dirname(hermes_src_dir)

    cmake = which("cmake")
    # Print the CMake version to assist in diagnosing issues.
    print("CMake version:\n{}".format(
        subprocess.check_output([cmake, "--version"],
                                stderr=subprocess.STDOUT)))
    run_command(
        [cmake, hermes_src_dir, "-G", args.build_system] + cmake_flags,
        env=os.environ,
        cwd=args.hermes_build_dir,
    )