-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
executable file
·156 lines (148 loc) · 5.56 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#! /usr/bin/env python
from distutils.core import setup, Extension
from distutils.util import get_platform
import shutil
import os, sys
def buil_all():
packages=['miasm2',
'miasm2/arch',
'miasm2/arch/x86',
'miasm2/arch/arm',
'miasm2/arch/msp430',
'miasm2/arch/sh4',
'miasm2/arch/mips32',
'miasm2/core',
'miasm2/expression',
'miasm2/ir',
'miasm2/analysis',
'miasm2/os_dep',
'miasm2/jitter',
'miasm2/jitter/arch',
]
ext_modules_no_tcc = [
Extension("miasm2.jitter.arch.JitCore_x86",
["miasm2/jitter/vm_mngr.c",
"miasm2/jitter/vm_mngr_py.c",
"miasm2/jitter/arch/JitCore.c",
"miasm2/jitter/arch/JitCore_x86.c"]),
Extension("miasm2.jitter.arch.JitCore_arm",
["miasm2/jitter/vm_mngr.c",
"miasm2/jitter/vm_mngr_py.c",
"miasm2/jitter/arch/JitCore.c",
"miasm2/jitter/arch/JitCore_arm.c"]),
Extension("miasm2.jitter.arch.JitCore_msp430",
["miasm2/jitter/vm_mngr.c",
"miasm2/jitter/vm_mngr_py.c",
"miasm2/jitter/arch/JitCore.c",
"miasm2/jitter/arch/JitCore_msp430.c"]),
Extension("miasm2.jitter.arch.JitCore_mips32",
["miasm2/jitter/vm_mngr.c",
"miasm2/jitter/vm_mngr_py.c",
"miasm2/jitter/arch/JitCore.c",
"miasm2/jitter/arch/JitCore_mips32.c"]),
Extension("miasm2.jitter.Jitllvm",
["miasm2/jitter/Jitllvm.c"]),
]
ext_modules_all = [
Extension("miasm2.jitter.arch.JitCore_x86",
["miasm2/jitter/vm_mngr.c",
"miasm2/jitter/vm_mngr_py.c",
"miasm2/jitter/arch/JitCore.c",
"miasm2/jitter/arch/JitCore_x86.c"]),
Extension("miasm2.jitter.arch.JitCore_arm",
["miasm2/jitter/vm_mngr.c",
"miasm2/jitter/vm_mngr_py.c",
"miasm2/jitter/arch/JitCore.c",
"miasm2/jitter/arch/JitCore_arm.c"]),
Extension("miasm2.jitter.arch.JitCore_msp430",
["miasm2/jitter/vm_mngr.c",
"miasm2/jitter/vm_mngr_py.c",
"miasm2/jitter/arch/JitCore.c",
"miasm2/jitter/arch/JitCore_msp430.c"]),
Extension("miasm2.jitter.arch.JitCore_mips32",
["miasm2/jitter/vm_mngr.c",
"miasm2/jitter/vm_mngr_py.c",
"miasm2/jitter/arch/JitCore.c",
"miasm2/jitter/arch/JitCore_mips32.c"]),
Extension("miasm2.jitter.Jitllvm",
["miasm2/jitter/Jitllvm.c"]),
Extension("miasm2.jitter.Jittcc",
["miasm2/jitter/Jittcc.c"],
libraries=["tcc"])
]
print 'building'
build_ok = False
for name, ext_modules in [('all', ext_modules_all),
('notcc', ext_modules_no_tcc)]:
print 'build with', repr(name)
try:
s = setup(
name = 'Miasm',
version = '2.0',
packages = packages,
package_data = {'miasm2':['jitter/*.h',
'jitter/arch/*.h',]},
ext_modules = ext_modules,
# Metadata
author = 'Fabrice Desclaux',
author_email = '[email protected]',
description = 'Machine code manipulation library',
license = 'GPLv2',
# keywords = '',
# url = '',
)
except SystemExit, e:
print repr(e)
continue
build_ok = True
break
if not build_ok:
raise ValueError('Unable to build Miasm!')
print 'build', name
if name == 'notcc':
print
print "*"*80
print "Warning: TCC is not properly installed,"
print "Miasm will be installed without TCC Jitter"
print "Etheir install TCC or use LLVM jitter"
print "*"*80
print
# 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
def buil_no_tcc():
setup(
name = 'Miasm',
version = '2.0',
packages=['miasm2', 'miasm2/tools',
'miasm2/expression', 'miasm2/graph', 'miasm2/arch',
'miasm2/core', 'miasm2/tools/emul_lib' ],
package_data = {'miasm2':['tools/emul_lib/*.h']},
# data_files = [('toto', ['miasm2/tools/emul_lib/queue.h'])],
# Metadata
author = 'Fabrice Desclaux',
author_email = '[email protected]',
description = 'Machine code manipulation library',
license = 'GPLv2',
# keywords = '',
# url = '',
)
def try_build():
buil_all()
"""
try:
buil_all()
return
except:
print "WARNING cannot build with libtcc!, trying without it"
print "Miasm will not be able to emulate code"
buil_no_tcc()
"""
try_build()