def download_llvm_sources(): tar = get_cmd_or_die("tar") # make sure we have the gpg public key installed first install_sig(c.LLVM_PUBKEY) with pb.local.cwd(c.BUILD_DIR): # download archives and signatures for (aurl, asig, afile, _) in zip(c.LLVM_ARCHIVE_URLS, c.LLVM_SIGNATURE_URLS, c.LLVM_ARCHIVE_FILES, c.LLVM_ARCHIVE_DIRS): # download archive + signature download_archive(aurl, afile, asig) # first extract llvm archive if not os.path.isdir(c.LLVM_SRC): logging.info("extracting %s", c.LLVM_ARCHIVE_FILES[0]) tar("xf", c.LLVM_ARCHIVE_FILES[0]) os.rename(c.LLVM_ARCHIVE_DIRS[0], c.LLVM_SRC) # then clang front end with pb.local.cwd(os.path.join(c.LLVM_SRC, "tools")): if not os.path.isdir("clang"): logging.info("extracting %s", c.LLVM_ARCHIVE_FILES[1]) tar("xf", os.path.join(c.ROOT_DIR, c.LLVM_ARCHIVE_FILES[1])) os.rename(c.LLVM_ARCHIVE_DIRS[1], "clang") with pb.local.cwd("clang/tools"): if not os.path.isdir("extra"): logging.info("extracting %s", c.LLVM_ARCHIVE_FILES[2]) tar("xf", os.path.join(c.ROOT_DIR, c.LLVM_ARCHIVE_FILES[2])) os.rename(c.LLVM_ARCHIVE_DIRS[2], "extra")
def test_lua(args: argparse.Namespace) -> bool: """ download lua, compile lua with bear to create a compiler command database, and use it to drive the transpiler. """ if not os.path.isfile(os.path.join(c.DEPS_DIR, LUA_ARCHIVE)): with pb.local.cwd(c.DEPS_DIR): download_archive(LUA_URL, LUA_ARCHIVE) if not os.path.isdir(LUA_SRC): with pb.local.cwd(c.DEPS_DIR): invoke_quietly(TAR, "xf", LUA_ARCHIVE) # unconditionally compile lua since we don't know if # cc_db was generated from the environment we're in. build_dir = os.path.join(LUA_SRC, "build") rmtree(build_dir, ignore_errors=True) os.mkdir(build_dir) with pb.local.cwd(build_dir), pb.local.env(CC="clang"): invoke(CMAKE['-DCMAKE_EXPORT_COMPILE_COMMANDS=1', LUA_SRC]) invoke(MAKE[JOBS]) cc_db_file = os.path.join(LUA_SRC, "build", c.CC_DB_JSON) if not os.path.isfile(cc_db_file): die("missing " + cc_db_file, errno.ENOENT) with open(cc_db_file) as cc_db: return transpile_files(cc_db, args.jobs, None, False, args.verbose)
def test_json_c(args: argparse.Namespace) -> bool: if not os.path.isfile(os.path.join(c.DEPS_DIR, JSON_C_ARCHIVE)): with pb.local.cwd(c.DEPS_DIR): download_archive(JSON_C_URL, JSON_C_ARCHIVE) invoke_quietly(TAR, "xf", JSON_C_ARCHIVE) cc_db_file = os.path.join(JSON_C_SRC, c.CC_DB_JSON) # unconditionally compile json-c since we don't know if # cc_db was generated from the environment we're in. with pb.local.cwd(JSON_C_SRC), pb.local.env(CC="clang"): if os.path.isfile('Makefile'): invoke(MAKE['clean']) configure = pb.local.get("./configure") invoke(configure) invoke(BEAR[MAKE[JOBS]]) if not os.path.isfile(cc_db_file): die("missing " + cc_db_file, errno.ENOENT) return transpile(cc_db_file)
def download_llvm_sources(): tar = get_cmd_or_die("tar") if not c.LLVM_SKIP_SIGNATURE_CHECKS: # make sure we have the gpg public key installed first install_sig(c.LLVM_PUBKEY) with pb.local.cwd(c.BUILD_DIR): # download archives and signatures for (aurl, asig, afile, _) in zip( c.LLVM_ARCHIVE_URLS, c.LLVM_SIGNATURE_URLS, c.LLVM_ARCHIVE_FILES, c.LLVM_ARCHIVE_DIRS): if c.LLVM_SKIP_SIGNATURE_CHECKS: asig = None # download archive and (by default) its signature download_archive(aurl, afile, asig) # first extract llvm archive, if not os.path.isdir(c.LLVM_SRC): logging.info("extracting %s", c.LLVM_ARCHIVE_FILES[0]) tar("xf", c.LLVM_ARCHIVE_FILES[0]) os.rename(c.LLVM_ARCHIVE_DIRS[0], c.LLVM_SRC) # then compiler-rt, with pb.local.cwd(os.path.join(c.LLVM_SRC, "projects")): if not os.path.isdir("compiler-rt"): logging.info("extracting %s", c.LLVM_ARCHIVE_FILES[2]) tar("xf", os.path.join(c.ROOT_DIR, c.LLVM_ARCHIVE_FILES[2])) os.rename(c.LLVM_ARCHIVE_DIRS[2], "compiler-rt") # finally clang, and clang-tools-extra. with pb.local.cwd(os.path.join(c.LLVM_SRC, "tools")): if not os.path.isdir("clang"): logging.info("extracting %s", c.LLVM_ARCHIVE_FILES[1]) tar("xf", os.path.join(c.ROOT_DIR, c.LLVM_ARCHIVE_FILES[1])) os.rename(c.LLVM_ARCHIVE_DIRS[1], "clang")
def test_ruby(args: argparse.Namespace) -> bool: if on_mac(): die("transpiling ruby on mac is not supported.") if not os.path.isfile(os.path.join(c.DEPS_DIR, RUBY_ARCHIVE)): with pb.local.cwd(c.DEPS_DIR): download_archive(RUBY_URL, RUBY_ARCHIVE) invoke_quietly(TAR, "xf", RUBY_ARCHIVE) cc_db_file = os.path.join(RUBY_SRC, c.CC_DB_JSON) # unconditionally compile ruby since we don't know if # cc_db was generated from the environment we're in. with pb.local.cwd(RUBY_SRC), pb.local.env(CC="clang", cflags="-w"): configure = pb.local.get("./configure") invoke(configure) invoke(BEAR[MAKE[JOBS]]) if not os.path.isfile(cc_db_file): die("missing " + cc_db_file, errno.ENOENT) with open(cc_db_file) as cc_db: return transpile_files(cc_db, args.jobs, None, False, args.verbose)