setup.py 文件源码

python
阅读 17 收藏 0 点赞 0 评论 0

项目:larissa 作者: bannsec 项目源码 文件源码
def _install_triton():
    # Locate the needed libraries
    capstone_include = re.match("(.*)/capstone$", find_file("capstone.h")).group(1)
    capstone_lib = os.path.join(find_file("libcapstone.so"),"libcapstone.so")
    cpath = [find_file("z3++.h")]
    cpath.append(find_file("z3.h"))
    cpath.append(find_file("z3_ast_containers.h"))

    # Using triton version included in larissa due to triton not being in pypi
    os.chdir(os.path.join(here,"lib","triton"))
    os.mkdir("build")
    os.chdir("build")

    cmake_options = [
            '-DCMAKE_INSTALL_PREFIX={0}'.format(sys.prefix),
            '-DCAPSTONE_INCLUDE_DIR={0}'.format(capstone_include),
            '-DCAPSTONE_LIBRARY={0}'.format(capstone_lib)
            ]

    # Custom boost install dir
    if _get_boost_path() != "/usr/include":
        cmake_options.append("-DBoost_INCLUDE_DIR={0}".format(os.path.join(_get_boost_path(),"include")))
        cmake_options.append("-DBoost_LIBRARY_DIR={0}".format(os.path.join(_get_boost_path(),"lib")))

        cpath = ["/usr/include"] + cpath
        cpath.append(os.path.join(_get_boost_path(),"include"))

    try:
        print("cmake {0} ..".format(' '.join(cmake_options)))
        subprocess.check_output("cmake {0} ..".format(' '.join(cmake_options)),shell=True)
    except Exception as e:
        raise Exception(e.output)

    try:
        print("CPATH={1} make -j{0} install".format(multiprocessing.cpu_count(), ':'.join(cpath)))
        subprocess.check_output("CPATH={1} make -j{0} install".format(multiprocessing.cpu_count(), ':'.join(cpath)),shell=True)
    except Exception as e:
        raise Exception(e.output)

    os.chdir(here)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号