Beispiel #1
0
def build_libzip():
    global DEPS_PATH
    global MAKE_THREAD_COUNT
    global INSTALL_PATH

    url = "https://github.com/kuba--/zip/archive/v0.1.19.zip"
    src_dir = "zip-0.1.19"
    filename = "zip-0.1.19.zip"
    output = get_lib_filename("zip")

    old_path = os.path.realpath(os.getcwd())
    os.chdir(DEPS_PATH)

    fetch_dep("libzip", url, src_dir, filename)

    if os.path.exists(
            os.path.join(os.path.realpath(INSTALL_PATH), "Lib", output)):
        infoMsg("libzip is already built and installed.")
        successMsg("Building libzip.")
        return

    os.chdir(src_dir)

    try:
        if is_windows():
            # TODO: Build libzip for windows.
            raise NotImplementedError(
                "Building libzip for Windows OS is not implemented yet!")
        else:
            build_dir = os.path.join(DEPS_PATH, src_dir, "build")
            if not os.path.exists(build_dir):
                try:
                    os.mkdir(build_dir)
                except:
                    failMsg(f'Cannot make "{build_dir}" directory.')
                    exit(1)

            os.chdir("build")

            ret = subprocess.call(["cmake", "-DBUILD_SHARED_LIBS=true", ".."])
            if ret != 0:
                failMsg("Building libzip.")
                exit(1)
            ret = subprocess.call(
                "make -j{}".format(MAKE_THREAD_COUNT).split())
            if ret != 0:
                failMsg("Building libzip.")
                exit(1)

            shutil.copy2(
                os.path.join(DEPS_PATH, build_dir, output),
                os.path.join(os.path.realpath(INSTALL_PATH), "Lib", output))
            if ret != 0:
                failMsg("Building libzip.")
                exit(1)
    except (OSError, subprocess.CalledProcessError):
        failMsg("Building libzip.")
        exit(1)
    successMsg("Building libzip.")
    os.chdir(old_path)
Beispiel #2
0
def create_packages_unix():
    global THIS_SYSTEM
    global ALUSUS_ROOT
    global PACKAGES_PATH
    global ARCHITECTURE
    global PACKAGE_NAME
    global PACKAGE_DESCRIPTION
    global PACKAGE_URL
    global PACKAGE_MAINTAINER
    global RELEASE_INSTALL_PATH
    global INSTALL_PATH

    old_path = os.path.realpath(os.getcwd())
    os.chdir(PACKAGES_PATH)

    input_type = "dir"
    version, revision, _, _ = get_version_info()
    after_install_script = os.path.join(ALUSUS_ROOT, "Tools", "BuildSrc",
                                        "Package_Scripts", "post_install.sh")
    after_remove_script = os.path.join(ALUSUS_ROOT, "Tools", "BuildSrc",
                                       "Package_Scripts", "post_remove.sh")

    current_cmd = [
        "fpm", "-s", input_type, "-t",
        "deb" if THIS_SYSTEM == "Linux" else "osxpkg", "-a", ARCHITECTURE,
        "-n", PACKAGE_NAME, "-v", version, "--description",
        PACKAGE_DESCRIPTION, "--url", PACKAGE_URL, "-m", PACKAGE_MAINTAINER,
        "--after-install", after_install_script, "--after-remove",
        after_remove_script, "-f", "--prefix", RELEASE_INSTALL_PATH, "-C",
        INSTALL_PATH
    ]

    if revision != "":
        # Insert just before "--description".
        idx = current_cmd.index("--description")
        current_cmd.insert(idx, revision)
        current_cmd.insert(idx, "--iteration")

    ret = subprocess.call(current_cmd)
    if ret != 0:
        failMsg("Creating {} Package.".format("DEB" if THIS_SYSTEM ==
                                              "Linux" else "OSXPKG"))
        exit(1)

    # Create additional package of type RPM for Linux systems.
    if THIS_SYSTEM == "Linux":
        # Replace "deb" with "rpm".
        current_cmd[current_cmd.index("-t") + 1] = "rpm"

        ret = subprocess.call(current_cmd)
        if ret != 0:
            failMsg("Creating RPM Package.")
            exit(1)

    os.chdir(old_path)
Beispiel #3
0
def build_libcurl():
    global DEPS_PATH
    global MAKE_THREAD_COUNT
    global INSTALL_PATH
    url = "https://github.com/curl/curl/releases/download/curl-7_70_0/curl-7.70.0.tar.xz"
    src_dir = "curl-7.70.0"
    filename = "curl-7.70.0.tar.xz"
    output = get_lib_filename("curl")

    old_path = os.path.realpath(os.getcwd())
    os.chdir(DEPS_PATH)

    fetch_dep("libcurl", url, src_dir, filename)

    if os.path.exists(
            os.path.join(os.path.realpath(INSTALL_PATH), "Lib", output)):
        infoMsg("libcurl is already built and installed.")
        successMsg("Building libcurl.")
        return

    os.chdir(src_dir)

    try:
        if is_windows():
            # TODO: Build libcurl for windows.
            raise NotImplementedError(
                "Building libcurl for Windows OS is not implemented yet!")
        else:
            if is_macos():
                ret = subprocess.call(["./configure", "--with-darwinssl"])
            else:
                ret = subprocess.call("./configure")
            if ret != 0:
                failMsg("Building libcurl (./configure).")
                exit(1)
            ret = subprocess.call(
                "make -j{}".format(MAKE_THREAD_COUNT).split())
            if ret != 0:
                failMsg("Building libcurl (make).")
                exit(1)

            shutil.copy2(
                os.path.join(DEPS_PATH, src_dir, "lib", ".libs", output),
                os.path.join(os.path.realpath(INSTALL_PATH), "Lib", output))
            if ret != 0:
                failMsg(f"Building libcurl. Couldn't copy {output}.")
                exit(1)

    except (OSError, subprocess.CalledProcessError) as e:
        failMsg(f"Building libcurl. Exception: {e}")
        exit(1)
    successMsg("Building libcurl.")
    os.chdir(old_path)
Beispiel #4
0
def create_zip():
    global ALUSUS_ROOT
    global PACKAGES_PATH
    global ARCHITECTURE
    global PACKAGE_NAME
    global PACKAGE_DESCRIPTION
    global PACKAGE_URL
    global PACKAGE_MAINTAINER
    global RELEASE_INSTALL_PATH
    global INSTALL_PATH

    old_path = os.path.realpath(os.getcwd())
    os.chdir(BUILDS_PATH)

    subprocess.call(["rm", "-rf", "Alusus"])
    shutil.copytree(INSTALL_PATH, "Alusus", True)

    if is_linux():
        postfix = "linux"
    else:
        postfix = "macos"

    version, revision, _, _ = get_version_info()

    if revision != "":
        filename = "alusus_" + version + "-" + revision + "_x86_64_" + postfix + ".zip"
    else:
        filename = "alusus_" + version + "_x86_64_" + postfix + ".zip"

    current_cmd = [
        "zip", "--symlinks", "-r",
        os.path.join(PACKAGES_PATH, filename), "Alusus/"
    ]
    ret = subprocess.call(current_cmd)
    if ret != 0:
        failMsg("Creating Zip Package.")
        exit(1)

    os.chdir(old_path)
Beispiel #5
0
def build_alusus(llvm_path):
    global BUILD_PATH
    global ALUSUS_ROOT
    global BUILD_TYPE
    global INSTALL_PATH
    global DEPS_PATH
    global MAKE_THREAD_COUNT
    global CREATE_PACKAGES
    global DLFCN_WIN32_NAME

    infoMsg("Building Alusus...")
    old_path = os.path.realpath(os.getcwd())
    os.chdir(BUILD_PATH)

    try:
        # Determine fpic flag based on architecture type. For arm64 we'll use -fPIC to avoid the `too many GOT entries`
        # error. For everything else we'll use -fpic to maintain higher performance.
        arch = subprocess.check_output(['uname', '-m']).decode('utf-8').strip()
        fpic = '-fPIC' if arch == 'arm64' or arch == 'aarch64' else '-fpic'

        cmake_cmd = [
            "cmake",
            os.path.join(ALUSUS_ROOT, "Sources"),
            f"-DCMAKE_BUILD_TYPE={BUILD_TYPE}".format(),
            f"-DCMAKE_INSTALL_PREFIX={INSTALL_PATH}".format(),
            f"-DLLVM_PATH={llvm_path}".format(), f"-DFPIC={fpic}".format()
        ]

        ret = subprocess.call(cmake_cmd)
        if ret != 0:
            failMsg("Building Alusus.")
            exit(1)
        if is_windows():
            ret = subprocess.call("msbuild INSTALL.vcxproj /m".split())
            if ret != 0:
                failMsg("Building Alusus.")
                exit(1)
        else:
            ret = subprocess.call(
                "make install -j{}".format(MAKE_THREAD_COUNT).split())
            if ret != 0:
                failMsg("Building Alusus.")
                exit(1)

    except (OSError, subprocess.CalledProcessError):
        failMsg("Building Alusus.")
        exit(1)
    os.chdir(old_path)
    successMsg("Building Alusus.")
Beispiel #6
0
def build_alusus():
    global BUILD_PATH
    global ALUSUS_ROOT
    global BUILD_TYPE
    global INSTALL_PATH
    global DEPS_PATH
    global LLVM_NAME
    global MAKE_THREAD_COUNT
    global CREATE_PACKAGES
    global DLFCN_WIN32_NAME
    global THIS_SYSTEM

    infoMsg("Building Alusus...")
    if not os.path.isdir(BUILD_PATH):
        os.makedirs(BUILD_PATH)
    old_path = os.path.realpath(os.getcwd())
    os.chdir(BUILD_PATH)

    try:
        cmake_cmd = [
            "cmake", "{}".format(os.path.join(ALUSUS_ROOT, "Sources")),
            "-DCMAKE_BUILD_TYPE={}".format(BUILD_TYPE),
            "-DCMAKE_INSTALL_PREFIX={}".format(INSTALL_PATH),
            "-DLLVM_PATH={}".format(
                os.path.join(DEPS_PATH, LLVM_NAME + ".install"))
        ]

        ret = subprocess.call(cmake_cmd)
        if ret != 0:
            failMsg("Building Alusus.")
            exit(1)
        if THIS_SYSTEM == "Windows":
            ret = subprocess.call("msbuild INSTALL.vcxproj /m".split())
            if ret != 0:
                failMsg("Building Alusus.")
                exit(1)
        else:
            ret = subprocess.call(
                "make install -j{}".format(MAKE_THREAD_COUNT).split())
            if ret != 0:
                failMsg("Building Alusus.")
                exit(1)

    except (OSError, subprocess.CalledProcessError):
        failMsg("Building Alusus.")
        exit(1)
    os.chdir(old_path)
    successMsg("Building Alusus.")
Beispiel #7
0
def build_alusus(llvm_path):
    global BUILD_PATH
    global ALUSUS_ROOT
    global BUILD_TYPE
    global INSTALL_PATH
    global DEPS_PATH
    global MAKE_THREAD_COUNT
    global CREATE_PACKAGES
    global DLFCN_WIN32_NAME

    infoMsg("Building Alusus...")
    old_path = os.path.realpath(os.getcwd())
    os.chdir(BUILD_PATH)

    try:
        cmake_cmd = [
            "cmake",
            os.path.join(ALUSUS_ROOT, "Sources"),
            f"-DCMAKE_BUILD_TYPE={BUILD_TYPE}".format(),
            f"-DCMAKE_INSTALL_PREFIX={INSTALL_PATH}".format(),
            f"-DLLVM_PATH={llvm_path}".format()
        ]

        ret = subprocess.call(cmake_cmd)
        if ret != 0:
            failMsg("Building Alusus.")
            exit(1)
        if is_windows():
            ret = subprocess.call("msbuild INSTALL.vcxproj /m".split())
            if ret != 0:
                failMsg("Building Alusus.")
                exit(1)
        else:
            ret = subprocess.call(
                "make install -j{}".format(MAKE_THREAD_COUNT).split())
            if ret != 0:
                failMsg("Building Alusus.")
                exit(1)

    except (OSError, subprocess.CalledProcessError):
        failMsg("Building Alusus.")
        exit(1)
    os.chdir(old_path)
    successMsg("Building Alusus.")
Beispiel #8
0
def build_llvm():
    global DEPS_PATH
    global MAKE_THREAD_COUNT
    url = "https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.0/llvm-10.0.0.src.tar.xz"
    filename = "llvm-10.0.0.src.tar.xz"
    src_dir, build_dir, install_dir = "llvm-10.0.0.src", "llvm-10.0.0.build", "llvm-10.0.0.install"

    old_path = os.path.realpath(os.getcwd())
    os.chdir(DEPS_PATH)

    fetch_dep("LLVM", url, src_dir, filename)

    if os.path.exists(os.path.join(install_dir, "INSTALLED")):
        infoMsg("LLVM is already built and installed.")
        successMsg("Building LLVM.")
        return os.path.realpath(install_dir)
    try:
        os.makedirs(install_dir)
    except OSError:
        pass
    if not os.path.exists(build_dir):
        try:
            os.makedirs(build_dir)
        except OSError:
            pass
    os.chdir(build_dir)

    try:
        ret = subprocess.call([
            "cmake",
            os.path.join("..", src_dir),
            f"-DCMAKE_INSTALL_PREFIX={os.path.join(DEPS_PATH, install_dir)}",
            "-DCMAKE_BUILD_TYPE=Release",
            "-DLLVM_TARGETS_TO_BUILD=X86;WebAssembly"
        ])
        if ret != 0:
            failMsg("Building LLVM.")
            exit(1)

        if is_windows():
            ret = subprocess.call(
                "msbuild INSTALL.vcxproj /p:Configuration=Release /m".split())
            if ret != 0:
                failMsg("Building LLVM.")
                exit(1)
        else:
            ret = subprocess.call(
                "make install -j{}".format(MAKE_THREAD_COUNT).split())
            if ret != 0:
                failMsg("Building LLVM.")
                exit(1)

        os.chdir(DEPS_PATH)
        with open(os.path.join(install_dir, "INSTALLED"), "w") as fd:
            fd.write("LLVM INSTALLED CHECKER")

    except (OSError, subprocess.CalledProcessError):
        failMsg("Building LLVM.")
        exit(1)
    successMsg("Building LLVM.")
    os.chdir(DEPS_PATH)
    return os.path.realpath(install_dir)
Beispiel #9
0
def build_libzip():
    global BUILD_PATH
    global DEPS_PATH
    global LIBZIP_NAME
    global LIBZIP_SRC_URL
    global MAKE_THREAD_COUNT
    global INSTALL_PATH

    try:
        os.makedirs(BUILD_PATH)
    except OSError:
        pass

    try:
        os.makedirs(DEPS_PATH)
    except OSError:
        pass

    old_path = os.path.realpath(os.getcwd())
    os.chdir(DEPS_PATH)

    if not os.path.exists(os.path.join(LIBZIP_NAME, "EXTRACTED")):
        if not os.path.exists(LIBZIP_NAME + ".zip"):
            wget.download(LIBZIP_SRC_URL)
        with ZipFile(file=LIBZIP_NAME + ".zip", mode="r") as zip:
            infoMsg("Extracting libzip sources...")
            zip.extractall()
        os.remove(LIBZIP_NAME + ".zip")
        with open(os.path.join(LIBZIP_NAME, "EXTRACTED"), "w") as fd:
            fd.write("LIBZIP EXTRACTED CHECKER")
        infoMsg("Finished extracting libzip sources.")
    else:
        infoMsg("libzip sources are already available.")

    if os.path.exists(
            os.path.join(os.path.realpath(INSTALL_PATH), "Lib", "libzip.so")):
        infoMsg("libzip is already built and installed.")
        successMsg("Building libzip.")
        return

    os.chdir(LIBZIP_NAME)

    try:
        if THIS_SYSTEM == "Windows":
            # TODO: Build libzip for windows.
            raise NotImplementedError(
                "Building libzip for Windows OS is not implemented yet!")
        else:
            if not os.path.exists(os.path.join(DEPS_PATH, LIBZIP_NAME,
                                               "build")):
                try:
                    os.mkdir(os.path.join(DEPS_PATH, LIBZIP_NAME, "build"))
                except:
                    failMsg("Cannot make \"" +
                            os.path.join(DEPS_PATH, LIBZIP_NAME, "build") +
                            "\" directory.")
                    exit(1)

            os.chdir("build")

            ret = subprocess.call(["cmake", "-DBUILD_SHARED_LIBS=true", ".."])
            if ret != 0:
                failMsg("Building libzip.")
                exit(1)
            ret = subprocess.call(
                "make -j{}".format(MAKE_THREAD_COUNT).split())
            if ret != 0:
                failMsg("Building libzip.")
                exit(1)

            if not os.path.exists(
                    os.path.join(os.path.realpath(INSTALL_PATH), "Lib")):
                try:
                    os.mkdir(
                        os.path.join(os.path.realpath(INSTALL_PATH), "Lib"))
                except:
                    failMsg(
                        "Cannot make \"" +
                        os.path.join(os.path.realpath(INSTALL_PATH), "Lib") +
                        "\" directory.")
                    exit(1)

            shutil.copy2(
                os.path.join(DEPS_PATH, LIBZIP_NAME, "build", "libzip.so"),
                os.path.join(os.path.realpath(INSTALL_PATH), "Lib",
                             "libzip.so"))
            if ret != 0:
                failMsg("Building libzip.")
                exit(1)
    except (OSError, subprocess.CalledProcessError):
        failMsg("Building libzip.")
        exit(1)
    successMsg("Building libzip.")
    os.chdir(old_path)
Beispiel #10
0
def build_libcurl():
    global BUILD_PATH
    global DEPS_PATH
    global LIBCURL_NAME
    global LIBCURL_SRC_URL
    global MAKE_THREAD_COUNT
    global INSTALL_PATH

    try:
        os.makedirs(BUILD_PATH)
    except OSError:
        pass

    try:
        os.makedirs(DEPS_PATH)
    except OSError:
        pass

    old_path = os.path.realpath(os.getcwd())
    os.chdir(DEPS_PATH)

    if not os.path.exists(os.path.join(LIBCURL_NAME, "EXTRACTED")):
        if not os.path.exists(LIBCURL_NAME + ".tar.xz"):
            wget.download(LIBCURL_SRC_URL)
        with lzma.open(LIBCURL_NAME + ".tar.xz") as fd:
            with tarfile.open(fileobj=fd) as tar:
                infoMsg("Extracting libcurl sources...")
                tar.extractall()
        os.remove(LIBCURL_NAME + ".tar.xz")
        with open(os.path.join(LIBCURL_NAME, "EXTRACTED"), "w") as fd:
            fd.write("LIBCURL EXTRACTED CHECKER")
        infoMsg("Finished extracting libcurl sources.")
    else:
        infoMsg("libcurl sources are already available.")

    if os.path.exists(
            os.path.join(os.path.realpath(INSTALL_PATH), "Lib", "libcurl.so")):
        infoMsg("libcurl is already built and installed.")
        successMsg("Building libcurl.")
        return

    os.chdir(LIBCURL_NAME)

    try:
        if THIS_SYSTEM == "Windows":
            # TODO: Build libcurl for windows.
            raise NotImplementedError(
                "Building libcurl for Windows OS is not implemented yet!")
        else:
            ret = subprocess.call("./configure")
            if ret != 0:
                failMsg("Building libcurl.")
                exit(1)
            ret = subprocess.call(
                "make -j{}".format(MAKE_THREAD_COUNT).split())
            if ret != 0:
                failMsg("Building libcurl.")
                exit(1)

            if not os.path.exists(
                    os.path.join(os.path.realpath(INSTALL_PATH), "Lib")):
                try:
                    os.mkdir(
                        os.path.join(os.path.realpath(INSTALL_PATH), "Lib"))
                except:
                    failMsg(
                        "Cannot make \"" +
                        os.path.join(os.path.realpath(INSTALL_PATH), "Lib") +
                        "\" directory.")

            shutil.copy2(
                os.path.join(DEPS_PATH, LIBCURL_NAME, "lib", ".libs",
                             "libcurl.so"),
                os.path.join(os.path.realpath(INSTALL_PATH), "Lib",
                             "libcurl.so"))
            if ret != 0:
                failMsg("Building libcurl.")
                exit(1)

    except (OSError, subprocess.CalledProcessError):
        failMsg("Building libcurl.")
        exit(1)
    successMsg("Building libcurl.")
    os.chdir(old_path)
Beispiel #11
0
def build_llvm():
    global BUILD_PATH
    global DEPS_PATH
    global LLVM_NAME
    global LLVM_SRC_URL
    global MAKE_THREAD_COUNT

    try:
        os.makedirs(BUILD_PATH)
    except OSError:
        pass

    try:
        os.makedirs(DEPS_PATH)
    except OSError:
        pass

    old_path = os.path.realpath(os.getcwd())
    os.chdir(DEPS_PATH)

    if not os.path.exists(os.path.join(LLVM_NAME + ".src", "EXTRACTED")):
        if not os.path.exists(LLVM_NAME + ".src.tar.xz"):
            wget.download(LLVM_SRC_URL)
        with lzma.open(LLVM_NAME + ".src.tar.xz") as fd:
            with tarfile.open(fileobj=fd) as tar:
                infoMsg("Extracting LLVM sources...")
                tar.extractall()
        os.remove(LLVM_NAME + ".src.tar.xz")
        with open(os.path.join(LLVM_NAME + ".src", "EXTRACTED"), "w") as fd:
            fd.write("LLVM EXTRACTED CHECKER")
        infoMsg("Finished extracting LLVM sources.")
    else:
        infoMsg("LLVM sources are already available.")

    if os.path.exists(os.path.join(LLVM_NAME + ".install", "INSTALLED")):
        infoMsg("LLVM is already built and installed.")
        successMsg("Building LLVM.")
        return
    try:
        os.makedirs(LLVM_NAME + ".install")
    except OSError:
        pass
    if not os.path.exists(LLVM_NAME + ".build"):
        try:
            os.makedirs(LLVM_NAME + ".build")
        except OSError:
            pass
    os.chdir(LLVM_NAME + ".build")

    try:
        cmake_cmd = [
            "cmake",
            os.path.join("..", LLVM_NAME + ".src"),
            "-DCMAKE_INSTALL_PREFIX={}".format(
                os.path.join(DEPS_PATH, LLVM_NAME + ".install")),
            "-DCMAKE_BUILD_TYPE=MinSizeRel"
        ]

        ret = subprocess.call(cmake_cmd)
        if ret != 0:
            failMsg("Building LLVM.")
            exit(1)

        if THIS_SYSTEM == "Windows":
            ret = subprocess.call(
                "msbuild INSTALL.vcxproj /p:Configuration=MinSizeRel /m".split(
                ))
            if ret != 0:
                failMsg("Building LLVM.")
                exit(1)
        else:
            ret = subprocess.call(
                "make install -j{}".format(MAKE_THREAD_COUNT).split())
            if ret != 0:
                failMsg("Building LLVM.")
                exit(1)

        os.chdir(DEPS_PATH)
        with open(os.path.join(LLVM_NAME + ".install", "INSTALLED"),
                  "w") as fd:
            fd.write("LLVM INSTALLED CHECKER")

    except (OSError, subprocess.CalledProcessError):
        failMsg("Building LLVM.")
        exit(1)
    successMsg("Building LLVM.")
    os.chdir(old_path)