forked from idapython/src
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.py
More file actions
executable file
·89 lines (79 loc) · 3.69 KB
/
Copy pathbuild.py
File metadata and controls
executable file
·89 lines (79 loc) · 3.69 KB
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
#!/usr/bin/env python
#---------------------------------------------------------------------
# IDAPython - Python plugin for Interactive Disassembler
#
# (c) The IDAPython Team <idapython@googlegroups.com>
#
# All rights reserved.
#
# For detailed copyright information see the file COPYING in
# the root of the distribution archive.
#---------------------------------------------------------------------
# build.py - Makefile wrapper script
#---------------------------------------------------------------------
import os, argparse
parser = argparse.ArgumentParser(epilog="""
A very specific version of SWiG is expected in order to produce reliable
bindings. If your platform doesn't provide that version by default and you
had to build/install it yourself, you will have to specify '--swig-bin' and
'--swig-inc' arguments.
For example, this is how to build against IDA 6.9 on linux, with a SWiG 2.0.12
installation located in /opt/my-swig/:
python build.py \\
--swig-bin /opt/my-swig/bin/swig \\
--swig-inc /opt/my-swig/share/swig/2.0.12/python/:/opt/my-swig/share/swig/2.0.12
Notes:
* '--swig-inc' here has 2 path components, separated by the platform's
path separator; i.e., ':' in this case (if you were building on Windows,
you would have to use ';'.)
* SWiG can be tricky to deal with when specifying input paths. The path
to the '.../2.0.12/python/' subdirectory should be placed before the
more global '.../2.0.12/' directory.
""",
formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument("--swig-bin", type=str, help="Path to the SWIG binary", default=None)
parser.add_argument("--swig-inc", type=str, help="Path(s) to the SWIG includes directory(ies)", default=None)
parser.add_argument("--with-hexrays", help="Build Hex-Rays decompiler bindings (requires the 'hexrays.hpp' header to be present in the SDK's include/ directory)", default=False, action="store_true")
parser.add_argument("--debug", help="Build debug version of the plugin", default=False, action="store_true")
parser.add_argument("--python-home", help="Python home, where the 'include' directory can be found", default=None)
parser.add_argument("-j", "--parallel", action="store_true", help="Build in parallel", default=False)
parser.add_argument("-v", "--verbose", help="Verbose mode", default=False, action="store_true")
args = parser.parse_args()
_probe = os.path.join("..", "..", "include", "pro.h")
assert os.path.exists(_probe), "Could not find IDA SDK include path (looked for: \"%s\")" % _probe
def run(proc_argv, env=None):
import subprocess
if args.verbose:
print "Running subprocess with argv: %s (env=%s)" % (proc_argv, env)
subprocess.check_call(proc_argv, env=env)
return 0
# -----------------------------------------------------------------------
def main():
argv = ["make"]
if args.parallel:
argv.append("-j")
env = os.environ.copy()
env["OUT_OF_TREE_BUILD"] = "1"
if args.swig_bin:
env["SWIG"] = args.swig_bin
if args.swig_inc:
env["SWIGINCLUDES"] = " ".join(map(lambda p: "-I%s" % p, args.swig_inc.split(os.pathsep)))
if args.with_hexrays:
env["HAS_HEXRAYS"] = "1"
if not args.debug:
env["NDEBUG"] = "1"
if args.python_home:
env["IDAPYTHON_PYTHONHOME"] = args.python_home
if args.verbose:
argv.append("-d")
for ea64 in [False, True]:
if ea64:
env["__EA64__"] = "1"
else:
if "__EA64__" in env:
del env["__EA64__"]
print "\n### Building EAsize=%d(bit) version of the plugin" % (64 if ea64 else 32)
run(argv, env=env)
# -----------------------------------------------------------------------
if __name__ == "__main__":
main()