diff options
Diffstat (limited to 'setup.py')
| -rwxr-xr-x | setup.py | 122 |
1 files changed, 77 insertions, 45 deletions
diff --git a/setup.py b/setup.py index 7cff1b34..f85dd350 100755 --- a/setup.py +++ b/setup.py @@ -2,30 +2,33 @@ from distutils.core import setup, Extension from distutils.util import get_platform -import shutil +from shutil import copy2 +import platform import os, sys +is_win = platform.system() == "Windows" + def buil_all(): - packages=['miasm2', - 'miasm2/arch', - 'miasm2/arch/x86', - 'miasm2/arch/arm', - 'miasm2/arch/aarch64', - 'miasm2/arch/msp430', - 'miasm2/arch/mep', - 'miasm2/arch/sh4', - 'miasm2/arch/mips32', - 'miasm2/arch/ppc', - 'miasm2/core', - 'miasm2/expression', - 'miasm2/ir', - 'miasm2/ir/translators', - 'miasm2/analysis', - 'miasm2/os_dep', - 'miasm2/os_dep/linux', - 'miasm2/jitter', - 'miasm2/jitter/arch', - 'miasm2/jitter/loader', + packages=["miasm2", + "miasm2/arch", + "miasm2/arch/x86", + "miasm2/arch/arm", + "miasm2/arch/aarch64", + "miasm2/arch/msp430", + "miasm2/arch/mep", + "miasm2/arch/sh4", + "miasm2/arch/mips32", + "miasm2/arch/ppc", + "miasm2/core", + "miasm2/expression", + "miasm2/ir", + "miasm2/ir/translators", + "miasm2/analysis", + "miasm2/os_dep", + "miasm2/os_dep/linux", + "miasm2/jitter", + "miasm2/jitter/arch", + "miasm2/jitter/loader", ] ext_modules_all = [ Extension("miasm2.jitter.VmMngr", @@ -88,26 +91,31 @@ def buil_all(): ]), ] - print 'building' + if is_win: + # Force setuptools to use whatever msvc version installed + os.environ['MSSdk'] = '1' + os.environ['DISTUTILS_USE_SDK'] = '1' + + print "building" build_ok = False - for name, ext_modules in [('all', ext_modules_all), + for name, ext_modules in [("all", ext_modules_all), ]: - print 'build with', repr(name) + print "build with", repr(name) try: s = setup( - name = 'Miasm', - version = '2.0', + name = "Miasm", + version = "2.0", packages = packages, - package_data = {'miasm2':['jitter/*.h', - 'jitter/arch/*.h',]}, + package_data = {"miasm2":["jitter/*.h", + "jitter/arch/*.h",]}, ext_modules = ext_modules, # Metadata - author = 'Fabrice Desclaux', - author_email = 'serpilliere@droid-corp.org', - description = 'Machine code manipulation library', - license = 'GPLv2', - # keywords = '', - # url = '', + author = "Fabrice Desclaux", + author_email = "serpilliere@droid-corp.org", + description = "Machine code manipulation library", + license = "GPLv2", + # keywords = "", + # url = "", ) except SystemExit, e: print repr(e) @@ -115,17 +123,41 @@ def buil_all(): build_ok = True break if not build_ok: - raise ValueError('Unable to build Miasm!') - print 'build', name + raise ValueError("Unable to build Miasm!") + print "build", name # we copy libraries from build dir to current miasm directory - build_base = None - if 'build' in s.command_options: - if 'build_base' in s.command_options['build']: - build_base = s.command_options['build']['build_base'] - if build_base is None: - build_base = "build" - plat_specifier = ".%s-%s" % (get_platform(), sys.version[0:3]) - build_base = os.path.join('build','lib' + plat_specifier) - print build_base + build_base = "build" + if "build" in s.command_options: + if "build_base" in s.command_options["build"]: + build_base = s.command_options["build"]["build_base"] + + print build_base + if is_win: + libs = [] + for root, _, files in os.walk(build_base): + for filename in files: + if not filename.endswith(".lib"): + continue + f_path = os.path.join(root, filename) + libs.append(f_path) + + lib_dirname = None + for dirname in os.listdir(build_base): + if not dirname.startswith("lib"): + continue + lib_dirname = dirname + break + + jitters = [] + for lib in libs: + filename = os.path.basename(lib) + dst = os.path.join(build_base, lib_dirname, "miasm2", "jitter") + if filename not in ["VmMngr.lib", "Jitgcc.lib", "Jitllvm.lib"]: + dst = os.path.join(dst, "arch") + dst = os.path.join(dst, filename) + if not os.path.isfile(dst): + print "Copying", lib, "to", dst + copy2(lib, dst) buil_all() + |