Exemplo n.º 1
0
def parse_args():
    parser = get_parser()
    parser.add_argument("hermes_build_dir", type=str, nargs="?", default="build")
    parser.add_argument("--icu", type=str, dest="icu_root", default="")
    parser.add_argument("--fbsource", type=str, dest="fbsource_dir", default="")
    parser.add_argument("--opcode-stats", dest="opcode_stats", action="store_true")
    parser.add_argument(
        "--basic-block-profiler", dest="basic_block_profiler", action="store_true"
    )
    parser.add_argument(
        "--warnings-as-errors", dest="warnings_as_errors", action="store_true"
    )
    parser.add_argument("--static-link", dest="static_link", action="store_true")
    args = parser.parse_args()
    args.hermes_build_dir = os.path.realpath(args.hermes_build_dir)
    if args.icu_root:
        args.icu_root = os.path.realpath(args.icu_root)
    if args.fbsource_dir:
        args.fbsource_dir = os.path.realpath(args.fbsource_dir)

    args.build_type = args.build_type or ("MinSizeRel" if args.distribute else "Debug")
    suffix = build_dir_suffix(args)
    args.hermes_build_dir += suffix
    # Guess the ICU directory based on platform.
    if not args.icu_root and platform.system() == "Linux":
        icu_prefs = [
            "/mnt/gvfs/third-party2/icu/4e8f3e00e1c7d7315fd006903a9ff7f073dfc02b/53.1/gcc-5-glibc-2.23/9bc6787",
            "/mnt/gvfs/third-party2/icu/4e8f3e00e1c7d7315fd006903a9ff7f073dfc02b/53.1/gcc-4.8.1-glibc-2.17/c3f970a/",
        ]
        for pref in icu_prefs:
            if os.path.exists(pref):
                args.icu_root = pref
                break
    return args
Exemplo n.º 2
0
def parse_args():
    parser = get_parser()
    parser.add_argument("llvm_src_dir", type=str, nargs="?", default="llvm")
    parser.add_argument("llvm_build_dir", type=str, nargs="?", default="llvm_build")
    parser.add_argument("--target", "-t", action="append", default=[])
    args = parser.parse_args()
    args.llvm_src_dir = os.path.realpath(args.llvm_src_dir)
    args.llvm_build_dir = os.path.realpath(args.llvm_build_dir)
    args.build_type = args.build_type or ("MinSizeRel" if args.distribute else "Debug")
    args.llvm_build_dir += build_dir_suffix(args)
    return args
Exemplo n.º 3
0
def parse_args():
    def default_build_command(args):
        # Choose a default based on the build system chosen
        if args.build_system == "Ninja":
            return "ninja"
        elif args.build_system == "Unix Makefiles":
            return "make"
        elif "Visual Studio" in args.build_system:
            return "MSBuild.exe LLVM.sln -target:build -maxcpucount -verbosity:normal"
        else:
            raise Exception("Unrecognized build system: {}".format(
                args.build_system))

    parser = get_parser()
    parser.add_argument("llvm_src_dir", type=str, nargs="?", default="llvm")
    parser.add_argument("llvm_build_dir",
                        type=str,
                        nargs="?",
                        default="llvm_build")
    parser.add_argument(
        "--build-command",
        type=str,
        dest="build_command",
        default=None,
        help="Command to run once cmake finishes",
    )
    parser.add_argument("--cross-compile-only",
                        dest="cross_compile_only",
                        action="store_true")
    args = parser.parse_args()
    args.llvm_src_dir = os.path.realpath(args.llvm_src_dir)
    args.llvm_build_dir = os.path.realpath(args.llvm_build_dir)
    if not args.build_command:
        args.build_command = default_build_command(args)
    if args.cross_compile_only:
        args.build_command += " " + os.path.join("bin", "llvm-tblgen")
    args.build_type = args.build_type or ("MinSizeRel"
                                          if args.distribute else "Debug")
    args.llvm_build_dir += build_dir_suffix(args)
    return args
Exemplo n.º 4
0
def parse_args():
    parser = get_parser()
    parser.add_argument("hermes_build_dir",
                        type=str,
                        nargs="?",
                        default="build")
    parser.add_argument("--icu", type=str, dest="icu_root", default="")
    parser.add_argument("--fbsource",
                        type=str,
                        dest="fbsource_dir",
                        default="")
    parser.add_argument("--opcode-stats",
                        dest="opcode_stats",
                        action="store_true")
    parser.add_argument("--basic-block-profiler",
                        dest="basic_block_profiler",
                        action="store_true")
    parser.add_argument("--warnings-as-errors",
                        dest="warnings_as_errors",
                        action="store_true")
    parser.add_argument("--static-link",
                        dest="static_link",
                        action="store_true")
    parser.add_argument(
        "--wasm",
        action="store_true",
        help="Build Hermes as WebAssembly instead of a native binary",
    )
    parser.add_argument(
        "--emscripten-root",
        dest="emscripten_root",
        help="Path to the root of emscripten. Use emsdk to download",
    )
    parser.add_argument(
        "--emscripten-platform",
        dest="emscripten_platform",
        choices=("upstream", "fastcomp"),
        default="fastcomp",
        help="Use either the upstream emscripten backend based on LLVM or the "
        "fastcomp backend",
    )
    args = parser.parse_args()
    args.hermes_build_dir = os.path.realpath(args.hermes_build_dir)
    if args.icu_root:
        args.icu_root = os.path.realpath(args.icu_root)
    if args.fbsource_dir:
        args.fbsource_dir = os.path.realpath(args.fbsource_dir)
    if args.emscripten_root:
        args.emscripten_root = os.path.realpath(args.emscripten_root)
    if args.wasm:
        # Check that if wasm is specified, that emscripten_root is also specified.
        if not args.emscripten_root:
            raise ValueError(
                "WASM build requested, but emscripten-root not given")
        if not os.path.exists(args.emscripten_root):
            raise ValueError(
                "WASM build requested, but emscripten-root doesn't exist: " +
                args.emscripten_root)

    if not args.build_type:
        if args.distribute:
            # WASM doesn't need to be built to be small.
            args.build_type = "Release" if args.wasm else "MinSizeRel"
        else:
            args.build_type = "Debug"
    args.hermes_build_dir += build_dir_suffix(args)
    # Guess the ICU directory based on platform.
    if not args.icu_root and platform.system() == "Linux":
        icu_prefs = [
            "/mnt/gvfs/third-party2/icu/4e8f3e00e1c7d7315fd006903a9ff7f073dfc02b/53.1/gcc-5-glibc-2.23/9bc6787",
            "/mnt/gvfs/third-party2/icu/4e8f3e00e1c7d7315fd006903a9ff7f073dfc02b/53.1/gcc-4.8.1-glibc-2.17/c3f970a/",
        ]
        for pref in icu_prefs:
            if os.path.exists(pref):
                args.icu_root = pref
                break
    return args