Exemplo n.º 1
0
def _clone_linux_qemu():
    # grab the linux tarball
    if not os.path.exists(QEMU_REPO_PATH_LINUX):
        TRACER_QEMU_REPO_LINUX = "https://github.com/qemu/qemu.git"
        if subprocess.call([
                'git', 'clone', '--branch', 'v2.3.0', '--depth=1',
                TRACER_QEMU_REPO_LINUX, QEMU_REPO_PATH_LINUX
        ]) != 0:
            raise LibError("Unable to retrieve qemu repository \"%s\"" %
                           TRACER_QEMU_REPO_LINUX)
        if subprocess.call([
                'git', '-C', QEMU_REPO_PATH_LINUX, 'apply',
                QEMU_LINUX_TRACER_PATCH
        ]) != 0:
            raise LibError("Unable to apply tracer patch to qemu")
        if subprocess.call([
                'git', '-C', QEMU_REPO_PATH_LINUX, 'apply',
                QEMU_LINUX_UPDATE_PATCH
        ]) != 0:
            raise LibError("Unable to apply ucontext_t update patch to qemu")
        if subprocess.call([
                'git', '-C', QEMU_REPO_PATH_LINUX, 'apply',
                QEMU_LINUX_COREDUMP_PATCH
        ]) != 0:
            raise LibError(
                "Unable to apply coredump update patch to qemu-linux")
        if subprocess.call([
                'git', '-C', QEMU_REPO_PATH_CGC_BASE, 'apply',
                QEMU_CGC_COREDUMP_PATCH
        ]) != 0:
            raise LibError(
                "Unable to apply coredump update patch to qemu-cgc-base")
Exemplo n.º 2
0
def _setup_cgc():

    if not os.path.exists(AFL_CGC_INSTALL_PATH):
        AFL_CGC_REPO = "https://github.com/shellphish/driller-afl.git"
        if subprocess.call(
            ['git', 'clone', AFL_CGC_REPO, AFL_CGC_INSTALL_PATH]) != 0:
            raise LibError("Unable to retrieve afl-cgc")

        if subprocess.call(['make', '-j'], cwd=AFL_CGC_INSTALL_PATH) != 0:
            raise LibError("Unable to make afl-cgc")

        if subprocess.call(['./build_qemu_support.sh'],
                           cwd=os.path.join(AFL_CGC_INSTALL_PATH,
                                            "qemu_mode")) != 0:
            raise LibError("Unable to build afl-cgc-qemu")

    if not os.path.exists(AFL_MULTI_CGC_INSTALL_PATH):
        AFL_MULTI_CGC_REPO = "https://github.com/mechaphish/multiafl.git"
        if subprocess.call([
                'git', 'clone', AFL_MULTI_CGC_REPO, AFL_MULTI_CGC_INSTALL_PATH
        ]) != 0:
            raise LibError("Unable to retrieve afl-multi-cgc")

        if subprocess.call(['make', '-j'],
                           cwd=AFL_MULTI_CGC_INSTALL_PATH) != 0:
            raise LibError("Unable to make afl-multi-cgc")
Exemplo n.º 3
0
def _setup_other_arch():
    # revisiting the afl mirrorer repo
    if not os.path.exists(AFL_UNIX_INSTALL_PATH):
        AFL_UNIX_REPO = "https://github.com/mirrorer/afl"
        if subprocess.call([
                'git', 'clone', '--depth=1', AFL_UNIX_REPO,
                AFL_UNIX_INSTALL_PATH
        ]) != 0:
            raise LibError("Unable to retrieve afl-unix")

        with open(BUILD_QEMU_PATCH_FILE, "rb") as f:
            if subprocess.check_call(
                ['patch', '-p0'], stdin=f, cwd=AFL_UNIX_INSTALL_PATH) != 0:
                raise LibError("Unable to apply patches to qemu build")

        if subprocess.call(['cp', AFL_UNIX_GEN, AFL_UNIX_INSTALL_PATH]) != 0:
            raise LibError("Build file doesn't exist")

        # patch for qemu to work with ubuntu 18.04 and above
        if subprocess.check_call(['cp', QEMU_PATCH, AFL_QEMU_MODE_PATCH]) != 0:
            raise LibError('Patch to work Qemu with Ubuntu 18 not found')

        if subprocess.check_call(['./build.sh'] + SUPPORTED_ARCHES,
                                 cwd=AFL_UNIX_INSTALL_PATH) != 0:
            raise LibError("Unable to build afl-other-arch")
Exemplo n.º 4
0
def _clone_cgc_qemu():
    # grab the CGC repo
    if not os.path.exists(QEMU_REPO_PATH_CGC_BASE) \
            or not os.path.exists(QEMU_REPO_PATH_CGC_BASE):
        TRACER_QEMU_REPO_CGC = "https://github.com/mechaphish/qemu-cgc"
        # since we're cloning from gitlab we'll need to try a couple times, since gitlab
        # has a cap on the number of ssh workers
        retrieved = False

        for _ in range(10):
            if subprocess.call([
                    'git', 'clone', '--branch', 'base_cgc', '--depth=1',
                    TRACER_QEMU_REPO_CGC, QEMU_REPO_PATH_CGC_BASE
            ]) == 0:
                retrieved = True
                break
            else:
                time.sleep(random.randint(0, 10))

        if not retrieved:
            raise LibError("Unable to retrieve tracer qemu")

    # update tracer qemu for cgc
    if subprocess.call(['git', 'pull'], cwd=QEMU_REPO_PATH_CGC_BASE) != 0:
        raise LibError("Unable to retrieve cgc base qemu")
Exemplo n.º 5
0
Arquivo: setup.py Projeto: leonW7/angr
def _build_native():
    try:
        import unicorn
        import pyvex
    except ImportError:
        raise LibError("You must install unicorn and pyvex before building angr")

    env = os.environ.copy()
    env_data = (('UNICORN_INCLUDE_PATH', 'unicorn', 'include'),
                ('UNICORN_LIB_PATH', 'unicorn', 'lib'),
                ('UNICORN_LIB_FILE', 'unicorn', 'lib\\unicorn.lib'),
                ('PYVEX_INCLUDE_PATH', 'pyvex', 'include'),
                ('PYVEX_LIB_PATH', 'pyvex', 'lib'),
                ('PYVEX_LIB_FILE', 'pyvex', 'lib\\pyvex.lib'))
    for var, pkg, fnm in env_data:
        try:
            env[var] = pkg_resources.resource_filename(pkg, fnm)
        except KeyError:
            pass

    cmd1 = ['nmake', '/f', 'Makefile-win']
    cmd2 = ['make']
    for cmd in (cmd1, cmd2):
        try:
            if subprocess.call(cmd, cwd='native', env=env) != 0:
                raise LibError('Unable to build angr_native')
            break
        except OSError:
            continue
    else:
        raise LibError('Unable to build angr_native')

    shutil.rmtree('angr/lib', ignore_errors=True)
    os.mkdir('angr/lib')
    shutil.copy(os.path.join('native', library_file), 'angr/lib')
Exemplo n.º 6
0
def _build_z3():
    if sys.platform == 'win32':
        if subprocess.call(['nmake'], env=build_env,
                           cwd=BUILD_DIR) != 0:
            raise LibError("Unable to build Z3.")
    else:   # linux and macOS
        if subprocess.call(['make', '-j', str(multiprocessing.cpu_count())],
                    env=build_env, cwd=BUILD_DIR) != 0:
            raise LibError("Unable to build Z3.")
Exemplo n.º 7
0
def _build_standard_qemu():
    if not os.path.exists(BIN_PATH):
        try:
            os.makedirs(BIN_PATH)
        except OSError:
            raise LibError("Unable to create bin directory")

    print("Folder created")
    print("Configuring Linux qemu...")
    if subprocess.call(['./tracer-config'], cwd=QEMU_REPO_PATH_LINUX) != 0:
        raise LibError("Unable to configure shellphish-qemu-linux")
    print("Building Linux qemu...")
    if subprocess.call(['make', '-j4'], cwd=QEMU_REPO_PATH_LINUX) != 0:
        raise LibError("Unable to build shellphish-qemu-linux")

    shutil.copyfile(
        os.path.join(QEMU_REPO_PATH_LINUX, "i386-linux-user", "qemu-i386"),
        QEMU_PATH_LINUX_I386)
    shutil.copyfile(
        os.path.join(QEMU_REPO_PATH_LINUX, "x86_64-linux-user", "qemu-x86_64"),
        QEMU_PATH_LINUX_X86_64)

    shutil.copyfile(
        os.path.join(QEMU_REPO_PATH_LINUX, "mipsel-linux-user", "qemu-mipsel"),
        QEMU_PATH_LINUX_MIPSEL)
    shutil.copyfile(
        os.path.join(QEMU_REPO_PATH_LINUX, "mips-linux-user", "qemu-mips"),
        QEMU_PATH_LINUX_MIPS)
    shutil.copyfile(
        os.path.join(QEMU_REPO_PATH_LINUX, "mips64-linux-user", "qemu-mips64"),
        QEMU_PATH_LINUX_MIPS64)

    shutil.copyfile(
        os.path.join(QEMU_REPO_PATH_LINUX, "ppc-linux-user", "qemu-ppc"),
        QEMU_PATH_LINUX_PPC)
    shutil.copyfile(
        os.path.join(QEMU_REPO_PATH_LINUX, "ppc64-linux-user", "qemu-ppc64"),
        QEMU_PATH_LINUX_PPC64)

    shutil.copyfile(
        os.path.join(QEMU_REPO_PATH_LINUX, "arm-linux-user", "qemu-arm"),
        QEMU_PATH_LINUX_ARM)
    shutil.copyfile(
        os.path.join(QEMU_REPO_PATH_LINUX, "aarch64-linux-user",
                     "qemu-aarch64"), QEMU_PATH_LINUX_AARCH64)

    os.chmod(QEMU_PATH_LINUX_I386, 0o755)
    os.chmod(QEMU_PATH_LINUX_X86_64, 0o755)
    os.chmod(QEMU_PATH_LINUX_MIPSEL, 0o755)
    os.chmod(QEMU_PATH_LINUX_MIPS, 0o755)
    os.chmod(QEMU_PATH_LINUX_MIPS64, 0o755)
    os.chmod(QEMU_PATH_LINUX_PPC, 0o755)
    os.chmod(QEMU_PATH_LINUX_PPC64, 0o755)
    os.chmod(QEMU_PATH_LINUX_ARM, 0o755)
    os.chmod(QEMU_PATH_LINUX_AARCH64, 0o755)
Exemplo n.º 8
0
def _setup_other_arch():
    # grab the afl-other-arch repo
    if not os.path.exists(AFL_UNIX_INSTALL_PATH):
        AFL_UNIX_REPO = "https://github.com/shellphish/afl-other-arch"
        if subprocess.call(['git', 'clone', AFL_UNIX_REPO, AFL_UNIX_INSTALL_PATH]) != 0:
            raise LibError("Unable to retrieve afl-unix")

        # apply the afl arm patch
        with open(AFL_UNIX_PATCH_FILE, "rb") as f:
            if subprocess.call(['patch', '-p0'], stdin=f, cwd=AFL_UNIX_INSTALL_PATH) != 0:
                raise LibError("Unable to apply AFL patch")

        if subprocess.call(['./build.sh'] + SUPPORTED_ARCHES, cwd=AFL_UNIX_INSTALL_PATH) != 0:
            raise LibError("Unable to build afl-other-arch")
Exemplo n.º 9
0
    def create_static_lib(self, objects, output_libname,
                          output_dir=None, debug=0, target_lang=None):
        objects, output_dir = self._fix_object_args(objects, output_dir)

        output_filename = \
            self.library_filename(output_libname, output_dir=output_dir)

        if self._need_link(objects, output_filename):
            self.mkpath(os.path.dirname(output_filename))
            self.spawn(self.archiver +
                       [output_filename] +
                       objects + self.objects)

            # Not many Unices required ranlib anymore -- SunOS 4.x is, I
            # think the only major Unix that does.  Maybe we need some
            # platform intelligence here to skip ranlib if it's not
            # needed -- or maybe Python's configure script took care of
            # it for us, hence the check for leading colon.
            if self.ranlib:
                try:
                    # iOS: since clang is not available, we send a nicer error message:
                    if (sys.platform == 'darwin' and os.uname().machine.startswith('iP')):
                        raise DistutilsExecError("There are no static linkers available on iOS, sorry.")
                    #
                    self.spawn(self.ranlib + [output_filename])
                except DistutilsExecError as msg:
                    raise LibError(msg)
        else:
            log.debug("skipping %s (up-to-date)", output_filename)
Exemplo n.º 10
0
def _build_vex():
    cmd = ['nmake', '/f', 'Makefile-win', 'all'
           ] if sys.platform == 'win32' else [
               'make', '-j', str(multiprocessing.cpu_count())
           ]
    if subprocess.call(cmd, cwd=VEX_PATH) != 0:
        raise LibError("Unable to build libVEX.")
Exemplo n.º 11
0
    def create_static_lib(self, objects, output_libname,
                          output_dir=None, debug=0, target_lang=None):
        objects, output_dir = self._fix_object_args(objects, output_dir)

        output_filename = \
            self.library_filename(output_libname, output_dir=output_dir)

        if self._need_link(objects, output_filename):
            self.mkpath(os.path.dirname(output_filename))
            self.spawn(self.archiver +
                       [output_filename] +
                       objects + self.objects)

            # Not many Unices required ranlib anymore -- SunOS 4.x is, I
            # think the only major Unix that does.  Maybe we need some
            # platform intelligence here to skip ranlib if it's not
            # needed -- or maybe Python's configure script took care of
            # it for us, hence the check for leading colon.
            if self.ranlib:
                try:
                    self.spawn(self.ranlib + [output_filename])
                except DistutilsExecError as msg:
                    raise LibError(msg)
        else:
            log.debug("skipping %s (up-to-date)", output_filename)
Exemplo n.º 12
0
def _clone_linux_qemu():
    # grab the linux tarball
    if not os.path.exists(QEMU_REPO_PATH_LINUX):
        TRACER_QEMU_REPO_LINUX = "https://github.com/qemu/qemu.git"
        if subprocess.call([
                'git', 'clone', '--branch', 'v2.3.0', '--depth=1',
                TRACER_QEMU_REPO_LINUX, QEMU_REPO_PATH_LINUX
        ]) != 0:
            raise LibError("Unable to retrieve qemu repository \"%s\"" %
                           TRACER_QEMU_REPO_LINUX)
        #if subprocess.call(['git', '-C', QEMU_REPO_PATH_LINUX, 'checkout', 'tags/v2.3.0']) != 0:
        #   raise LibError("Unable to checkout version 2.3.0 of qemu")
        if subprocess.call([
                'git', '-C', QEMU_REPO_PATH_LINUX, 'apply',
                QEMU_LINUX_TRACER_PATCH
        ]) != 0:
            raise LibError("Unable to apply tracer patch to qemu")
Exemplo n.º 13
0
def _build_vex():
    cmd1 = ['nmake', '/f', 'Makefile-win', 'all']
    cmd2 = ['make', '-j', str(multiprocessing.cpu_count()), 'all']
    for cmd in (cmd1, cmd2):
        try:
            if subprocess.call(cmd, cwd=VEX_PATH) == 0:
                break
        except OSError:
            continue
    else:
        raise LibError("Unable to build libVEX.")
Exemplo n.º 14
0
    def precompile_api_library(self, fem_api_ext):
        """
        Precompile the external FEM API library.
        """

        log.info("Pre-compiling FEM API library")

        # If BOOST_ROOT set in environment, set up so we can pass into Makefile
        if 'BOOST_ROOT' in os.environ:
            self.boost_root = os.environ['BOOST_ROOT']
        else:
            log.warn(
                "BOOST_ROOT is not set in environment - library compilation may be affected"
            )
            self.boost_root = None

        # Set and create object compile path
        self.build_temp_obj_path = os.path.abspath(
            os.path.join(self.build_temp, 'fem_api', 'obj'))
        self.makedir(self.build_temp_obj_path)

        # Set and create the library output path
        self.build_temp_lib_path = os.path.abspath(
            os.path.join(self.build_temp, 'fem_api', 'lib'))
        self.makedir(self.build_temp_lib_path)

        # Build a make query command and run it
        make_query_cmd = self.build_make_cmd('-q')
        make_needed = subprocess.call(shlex.split(make_query_cmd),
                                      cwd=fem_api_path)

        # Build the make command
        make_cmd = self.build_make_cmd()

        # Run the make command
        make_rc = subprocess.call(shlex.split(make_cmd), cwd=fem_api_path)
        if make_rc != 0:
            raise LibError("Pre-compilation of API library failed")

        # Inject the appropriate paths and libraries into the Extension configuration
        fem_api_ext.library_dirs.append(self.build_temp_lib_path)

        if self.boost_root:
            fem_api_ext.library_dirs.append(
                os.path.join(self.boost_root, 'lib'))
            fem_api_ext.runtime_library_dirs.append(
                os.path.join(self.boost_root, 'lib'))

        fem_api_ext.libraries.extend(
            ['fem_api', 'boost_thread', 'boost_system'])

        api_library_precompiled = (make_needed > 0) and (make_rc == 0)

        return api_library_precompiled
Exemplo n.º 15
0
def _configure_z3():
    # bail out early if we don't need to do this - it forces a rebuild every time otherwise
    if os.path.exists(BUILD_DIR):
        return
    args = [sys.executable, os.path.join(SRC_DIR, 'scripts', 'mk_make.py')]

    if sys.platform == 'win32' and platform.architecture()[0] == '64bit':
        args += ['-x']

    if subprocess.call(args, env=build_env, cwd=SRC_DIR) != 0:
        raise LibError("Unable to configure Z3.")
Exemplo n.º 16
0
def _clone_linux_qemu():
    # grab the linux tarball
    if not os.path.exists(QEMU_REPO_PATH_LINUX):
        if subprocess.call([
                'git', 'clone', '--branch', 'v2.3.0', '--depth=1',
                TRACER_QEMU_REPO_LINUX, QEMU_REPO_PATH_LINUX
        ]) != 0:
            raise LibError("Unable to retrieve qemu repository \"%s\"" %
                           TRACER_QEMU_REPO_LINUX)
        if subprocess.call([
                'git', '-C', QEMU_REPO_PATH_LINUX, 'apply',
                QEMU_LINUX_TRACER_PATCH
        ]) != 0:
            raise LibError("Unable to apply tracer patch to qemu")
        if subprocess.call([
                'git', '-C', QEMU_REPO_PATH_LINUX, 'apply',
                QEMU_LINUX_UPDATE_PATCH
        ]) != 0:
            raise LibError("Unable to apply ucontext_t update patch to qemu")
        _build_standard_qemu()
Exemplo n.º 17
0
def _build_pyvex():
    e = os.environ.copy()
    e['VEX_PATH'] = os.path.join('..', VEX_PATH)
    cmd = [
        'cl', '-LD', '-O2', '-I' +
        os.path.join('..', VEX_PATH, 'pub'), 'pyvex.c', 'logging.c',
        os.path.join('..', VEX_PATH, 'libvex.lib'), '/link', '/DEF:pyvex.def'
    ] if sys.platform == 'win32' else [
        'make', '-j', str(multiprocessing.cpu_count())
    ]
    if subprocess.call(cmd, cwd='pyvex_c', env=e) != 0:
        raise LibError("Unable to build libpyvex.")
Exemplo n.º 18
0
def _build_sim_unicorn():
    try:
        import unicorn
        import pyvex
    except ImportError:
        raise LibError(
            "You must install unicorn and pyvex before building simuvex")

    env = os.environ.copy()
    env['UNICORN_LIB_PATH'] = pkg_resources.resource_filename('unicorn', 'lib')
    env['UNICORN_INCLUDE_PATH'] = pkg_resources.resource_filename(
        'unicorn', 'include')
    env['PYVEX_LIB_PATH'] = pkg_resources.resource_filename('pyvex', 'lib')
    env['PYVEX_INCLUDE_PATH'] = pkg_resources.resource_filename(
        'pyvex', 'include')
    if subprocess.call(['make'], cwd='simuvex_c', env=env) != 0:
        raise LibError('Unable to build sim_unicorn')

    shutil.rmtree('simuvex/lib', ignore_errors=True)
    os.mkdir('simuvex/lib')
    shutil.copy(os.path.join('simuvex_c', library_file), 'simuvex/lib')
Exemplo n.º 19
0
def _setup():
    # revisiting the afl mirrorer repo
    if not os.path.exists(AFL_UNIX_INSTALL_PATH):
        AFL_UNIX_REPO = "https://github.com/AFLplusplus/AFLplusplus.git"
        if subprocess.call([
                'git', 'clone', '--branch', '2.64c', AFL_UNIX_REPO,
                AFL_UNIX_INSTALL_PATH
        ]) != 0:
            raise LibError("Unable to retrieve afl-unix")

        with open(QEMU_BUILD_SUPPORT_PATCH_FILE, "rb") as f:
            if subprocess.check_call(
                ['git', 'apply'], stdin=f, cwd=AFL_UNIX_INSTALL_PATH) != 0:
                raise LibError("Unable to apply qemu build multiarch patch")

        with open(QEMU_EXIT_DOUBLE_READ_PATCH_FILE, "rb") as f:
            if subprocess.check_call(
                ['git', 'apply'], stdin=f, cwd=AFL_UNIX_INSTALL_PATH) != 0:
                raise LibError("Unable to apply qemu exit double read patch")

        with open(AFL_UPDATE_INTERVAL_PATCH_FILE, "rb") as f:
            if subprocess.check_call(
                ['git', 'apply'], stdin=f, cwd=AFL_UNIX_INSTALL_PATH) != 0:
                raise LibError("Unable to apply afl update interval patch")

        if subprocess.call(['cp', AFL_UNIX_GEN, AFL_UNIX_INSTALL_PATH]) != 0:
            raise LibError("Build file doesn't exist")

        if subprocess.check_call(['./build.sh'],
                                 cwd=AFL_UNIX_INSTALL_PATH) != 0:
            raise LibError("Unable to build afl-other-arch")
Exemplo n.º 20
0
def _build_dreal():
    if sys.version_info.major == 2:
        FORCE_PYTHON = 'py2'
    else:
        FORCE_PYTHON = 'py3'
    if subprocess.call([
            'bazel',
            'build',
            '//...',
            '--python_path={}'.format(sys.executable),
            '--force_python={}'.format(FORCE_PYTHON),
    ]) != 0:
        raise LibError("Unable to build dReal.")
Exemplo n.º 21
0
def _build_vex():
    e = os.environ.copy()
    e['MULTIARCH'] = '1'
    e['DEBUG'] = '1'

    cmd1 = ['./build.sh']
    for cmd in (cmd1):
        try:
            if subprocess.call(cmd, cwd=VEX_PATH, env=e) == 0:
                break
        except OSError:
            continue
    else:
        raise LibError("Unable to build libtcg.")
Exemplo n.º 22
0
def _build_dreal():
    new_env = os.environ.copy()
    new_env["PYTHON_BIN_PATH"] = sys.executable
    if subprocess.call([
            'bazel',
            'build',
            '//dreal:_dreal_py.so',
            '--cxxopt=-DDREAL_CHECK_INTERRUPT',
            '--python_path={}'.format(sys.executable),
    ],
                       env=new_env) != 0:
        raise LibError("Unable to build dReal.\n" +
                       "Please visit https://pypi.org/project/dreal and " +
                       "follow the instructions to install the prerequisites.")
Exemplo n.º 23
0
    def create_static_lib(self, objects, output_libname, output_dir=None, debug=0, target_lang=None):
        if not self.initialized:
            self.initialize()
        objects, output_dir = self._fix_object_args(objects, output_dir)
        output_filename = self.library_filename(output_libname, output_dir=output_dir)
        if self._need_link(objects, output_filename):
            lib_args = objects + ['/OUT:' + output_filename]
            if debug:
                pass
            try:
                self.spawn([self.lib] + lib_args)
            except DistutilsExecError as msg:
                raise LibError(msg)

        else:
            log.debug('skipping %s (up-to-date)', output_filename)
Exemplo n.º 24
0
def _copy_bins():
    shutil.copy(os.path.join(SRC_DIR, 'bazel-bin', 'dreal', '_dreal_py.so'),
                os.path.join(ROOT_DIR, 'dreal'))
    os.chmod(os.path.join(ROOT_DIR, 'dreal', '_dreal_py.so'), 436)
    shutil.copy(os.path.join(SRC_DIR, 'bazel-bin', 'libdreal.so'),
                os.path.join(ROOT_DIR, 'dreal'))
    os.chmod(os.path.join(ROOT_DIR, 'dreal', 'libdreal.so'), 436)
    if sys.platform == 'darwin':
        if subprocess.call([
                '/usr/bin/install_name_tool',
                '-change',
                '@rpath/libdreal.so',
                '@loader_path/libdreal.so',
                os.path.join(ROOT_DIR, 'dreal', '_dreal_py.so'),
        ]) != 0:
            raise LibError("Unable to use install_name_tool.")
Exemplo n.º 25
0
def _build_vex():
    e = os.environ.copy()
    e['MULTIARCH'] = '1'
    e['DEBUG'] = '1'

    cmd1 = ['nmake', '/f', 'Makefile-msvc', 'all']
    cmd2 = ['make', '-f', 'Makefile-gcc', '-j', str(multiprocessing.cpu_count()), 'all']
    cmd3 = ['gmake', '-f', 'Makefile-gcc', '-j', str(multiprocessing.cpu_count()), 'all']
    for cmd in (cmd1, cmd2, cmd3):
        try:
            if subprocess.call(cmd, cwd=VEX_PATH, env=e) == 0:
                break
        except OSError:
            continue
    else:
        raise LibError("Unable to build libVEX.")
Exemplo n.º 26
0
Arquivo: setup.py Projeto: Qwaz/pyvex
def _build_pyvex():
    e = os.environ.copy()
    e['VEX_LIB_PATH'] = os.path.join('..', VEX_PATH)
    e['VEX_INCLUDE_PATH'] = os.path.join('..', VEX_PATH, 'pub')
    e['VEX_LIB_FILE'] = os.path.join('..', VEX_PATH, 'libvex.lib')

    cmd1 = ['nmake', '/f', 'Makefile-msvc']
    cmd2 = ['make', '-j', str(multiprocessing.cpu_count())]
    for cmd in (cmd1, cmd2):
        try:
            if subprocess.call(cmd, cwd='pyvex_c', env=e) == 0:
                break
        except OSError as err:
            continue
    else:
        raise LibError("Unable to build libpyvex.")
Exemplo n.º 27
0
    def create_static_lib(
        self, objects, output_libname, output_dir=None, debug=0, target_lang=None
    ):

        (objects, output_dir) = self._fix_object_args(objects, output_dir)
        output_filename = self.library_filename(output_libname, output_dir=output_dir)

        if self._need_link(objects, output_filename):
            lib_args = [output_filename, '/u'] + objects
            if debug:
                pass  # XXX what goes here?
            try:
                self.spawn([self.lib] + lib_args)
            except DistutilsExecError as msg:
                raise LibError(msg)
        else:
            log.debug("skipping %s (up-to-date)", output_filename)
Exemplo n.º 28
0
def _build_dreal():
    if sys.version_info.major == 2:
        PYTHON_VERSION = 'PY2'
    else:
        PYTHON_VERSION = 'PY3'
    new_env = os.environ.copy()
    new_env["PYTHON_BIN_PATH"] = sys.executable
    if subprocess.call([
            'bazel', 'build', '//:libdreal.so', '//dreal:_dreal_py.so',
            '--cxxopt=-DDREAL_CHECK_INTERRUPT', '--python_path={}'.format(
                sys.executable), '--python_version={}'.format(PYTHON_VERSION),
            '--incompatible_allow_python_version_transitions=false',
            '--incompatible_py3_is_default=false'
    ],
                       env=new_env) != 0:
        raise LibError("Unable to build dReal.\n" +
                       "Please visit https://pypi.org/project/dreal and " +
                       "follow the instructions to install the prerequsites.")
Exemplo n.º 29
0
    def create_static_lib(
        self, objects, output_libname, output_dir=None, debug=0, target_lang=None
    ):

        if not self.initialized:
            self.initialize()
        objects, output_dir = self._fix_object_args(objects, output_dir)
        output_filename = self.library_filename(output_libname, output_dir=output_dir)

        if self._need_link(objects, output_filename):
            lib_args = objects + ["/OUT:" + output_filename]
            if debug:
                pass  # XXX what goes here?
            try:
                log.debug('Executing "%s" %s', self.lib, " ".join(lib_args))
                self.spawn([self.lib] + lib_args)
            except DistutilsExecError as msg:
                raise LibError(msg)
        else:
            log.debug("skipping %s (up-to-date)", output_filename)
Exemplo n.º 30
0
 def create_static_lib(self,
                       objects,
                       output_libname,
                       output_dir=None,
                       debug=0,
                       target_lang=None):
     objects, output_dir = self._fix_object_args(objects, output_dir)
     output_filename = self.library_filename(output_libname,
                                             output_dir=output_dir)
     if self._need_link(objects, output_filename):
         self.mkpath(os.path.dirname(output_filename))
         self.spawn(self.archiver + [output_filename] + objects +
                    self.objects)
         if self.ranlib:
             try:
                 self.spawn(self.ranlib + [output_filename])
             except DistutilsExecError as msg:
                 raise LibError(msg)
     else:
         log.debug('skipping %s (up-to-date)', output_filename)