2007-10-20 09:03:51 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
#------------------------------------------------------------
|
|
|
|
# IDAPython - Python plugin for Interactive Disassembler Pro
|
|
|
|
#
|
2009-09-16 16:00:31 +02:00
|
|
|
# Copyright (c) 2004-2009 Gergely Erdelyi <dyce@d-dome.net>
|
2007-10-20 09:03:51 +02:00
|
|
|
#
|
|
|
|
# All rights reserved.
|
|
|
|
#
|
|
|
|
# For detailed copyright information see the file COPYING in
|
|
|
|
# the root of the distribution archive.
|
|
|
|
#------------------------------------------------------------
|
|
|
|
# build.py - Custom build script
|
|
|
|
#------------------------------------------------------------
|
2008-08-15 22:59:06 +02:00
|
|
|
import os
|
|
|
|
import platform
|
|
|
|
import shutil
|
|
|
|
import sys
|
|
|
|
import types
|
2008-08-15 22:51:16 +02:00
|
|
|
import zipfile
|
2007-10-20 09:03:51 +02:00
|
|
|
from distutils import sysconfig
|
|
|
|
|
|
|
|
# Start of user configurable options
|
|
|
|
VERBOSE = True
|
|
|
|
IDA_MAJOR_VERSION = 5
|
2010-01-05 19:24:04 +01:00
|
|
|
IDA_MINOR_VERSION = 6
|
2009-10-17 22:54:08 +02:00
|
|
|
if 'IDA' in os.environ:
|
2009-10-16 14:07:18 +02:00
|
|
|
IDA_SDK = os.environ['IDA']
|
|
|
|
else:
|
|
|
|
IDA_SDK = ".." + os.sep + "swigsdk-versions" + os.sep + "%d.%d" % (IDA_MAJOR_VERSION, IDA_MINOR_VERSION)
|
|
|
|
|
2007-10-20 09:03:51 +02:00
|
|
|
# End of user configurable options
|
|
|
|
|
|
|
|
# IDAPython version
|
2008-10-01 17:03:57 +02:00
|
|
|
VERSION_MAJOR = 1
|
2010-01-05 19:24:04 +01:00
|
|
|
VERSION_MINOR = 3
|
2010-03-05 12:45:44 +01:00
|
|
|
VERSION_PATCH = 2
|
2007-10-20 09:03:51 +02:00
|
|
|
|
|
|
|
# Determine Python version
|
|
|
|
PYTHON_MAJOR_VERSION = int(platform.python_version()[0])
|
|
|
|
PYTHON_MINOR_VERSION = int(platform.python_version()[2])
|
|
|
|
|
|
|
|
# Find Python headers
|
|
|
|
PYTHON_INCLUDE_DIRECTORY = sysconfig.get_config_var('INCLUDEPY')
|
|
|
|
|
|
|
|
# Swig command-line parameters
|
2007-12-06 14:56:20 +01:00
|
|
|
SWIG_OPTIONS = '-modern -python -c++ -w451 -shadow -D__GNUC__'
|
2007-10-20 09:03:51 +02:00
|
|
|
|
|
|
|
# Common macros for all compilations
|
|
|
|
COMMON_MACROS = [
|
|
|
|
("VER_MAJOR", "%d" % VERSION_MAJOR),
|
|
|
|
("VER_MINOR", "%d" % VERSION_MINOR),
|
|
|
|
("VER_PATCH", "%d" % VERSION_PATCH),
|
|
|
|
"__IDP__",
|
|
|
|
("MAXSTR", "1024"),
|
|
|
|
"USE_DANGEROUS_FUNCTIONS",
|
|
|
|
"USE_STANDARD_FILE_FUNCTIONS" ]
|
|
|
|
|
|
|
|
# Common includes for all compilations
|
|
|
|
COMMON_INCLUDES = [ ".", "swig" ]
|
|
|
|
|
|
|
|
# List files for the binary distribution
|
|
|
|
BINDIST_MANIFEST = [
|
|
|
|
"README.txt",
|
|
|
|
"COPYING.txt",
|
|
|
|
"CHANGES.txt",
|
|
|
|
"STATUS.txt",
|
|
|
|
"docs/notes.txt",
|
|
|
|
"examples/chooser.py",
|
2008-09-28 10:56:48 +02:00
|
|
|
"examples/colours.py",
|
2008-05-04 11:43:57 +02:00
|
|
|
"examples/debughook.py",
|
2007-10-20 09:03:51 +02:00
|
|
|
"examples/ex1.idc",
|
|
|
|
"examples/ex1_idaapi.py",
|
2008-09-28 10:56:48 +02:00
|
|
|
"examples/ex1_idautils.py",
|
2008-10-01 17:03:57 +02:00
|
|
|
"examples/hotkey.py",
|
2008-09-28 10:56:48 +02:00
|
|
|
"examples/structure.py",
|
2009-09-16 16:00:31 +02:00
|
|
|
"examples/ex_gdl_qflow_chart.py",
|
|
|
|
"examples/ex_strings.py",
|
2009-09-24 16:20:29 +02:00
|
|
|
"examples/ex_func_chooser.py",
|
|
|
|
"examples/ex_choose2.py",
|
2009-10-02 19:40:26 +02:00
|
|
|
"examples/ex_debug_names.py",
|
2009-10-16 14:07:18 +02:00
|
|
|
"examples/ex_graph.py",
|
2010-03-05 12:18:25 +01:00
|
|
|
"examples/ex_dbg.py",
|
|
|
|
"examples/ex_imports.py"
|
2008-08-15 22:59:06 +02:00
|
|
|
]
|
2007-10-20 09:03:51 +02:00
|
|
|
|
|
|
|
# List files for the source distribution (appended to binary list)
|
|
|
|
SRCDIST_MANIFEST = [
|
|
|
|
"BUILDING.txt",
|
|
|
|
"python.cpp",
|
|
|
|
"basetsd.h",
|
|
|
|
"build.py",
|
2008-07-17 20:46:46 +02:00
|
|
|
"swig/allins.i",
|
2009-05-23 16:40:01 +02:00
|
|
|
"swig/area.i",
|
2007-10-20 09:03:51 +02:00
|
|
|
"swig/auto.i",
|
|
|
|
"swig/bytes.i",
|
|
|
|
"swig/dbg.i",
|
|
|
|
"swig/diskio.i",
|
|
|
|
"swig/entry.i",
|
|
|
|
"swig/enum.i",
|
|
|
|
"swig/expr.i",
|
|
|
|
"swig/fixup.i",
|
|
|
|
"swig/frame.i",
|
|
|
|
"swig/funcs.i",
|
2009-05-23 16:40:01 +02:00
|
|
|
"swig/gdl.i",
|
2007-10-20 09:03:51 +02:00
|
|
|
"swig/ida.i",
|
|
|
|
"swig/idaapi.i",
|
2009-05-23 16:40:01 +02:00
|
|
|
"swig/idd.i",
|
2007-10-20 09:03:51 +02:00
|
|
|
"swig/idp.i",
|
|
|
|
"swig/ints.i",
|
|
|
|
"swig/kernwin.i",
|
|
|
|
"swig/lines.i",
|
|
|
|
"swig/loader.i",
|
|
|
|
"swig/moves.i",
|
|
|
|
"swig/nalt.i",
|
|
|
|
"swig/name.i",
|
2008-10-01 17:03:57 +02:00
|
|
|
"swig/netnode.i",
|
2007-10-20 09:03:51 +02:00
|
|
|
"swig/offset.i",
|
|
|
|
"swig/pro.i",
|
|
|
|
"swig/queue.i",
|
|
|
|
"swig/search.i",
|
|
|
|
"swig/segment.i",
|
|
|
|
"swig/srarea.i",
|
|
|
|
"swig/strlist.i",
|
|
|
|
"swig/struct.i",
|
|
|
|
"swig/typeconv.i",
|
|
|
|
"swig/typeinf.i",
|
|
|
|
"swig/ua.i",
|
|
|
|
"swig/xref.i",
|
2009-10-02 19:40:26 +02:00
|
|
|
"swig/graph.i",
|
2009-10-29 12:37:24 +01:00
|
|
|
"swig/fpro.i",
|
2008-06-25 23:03:38 +02:00
|
|
|
"tools/gendocs.py",
|
2007-10-20 09:03:51 +02:00
|
|
|
]
|
|
|
|
|
|
|
|
class BuilderBase:
|
|
|
|
""" Base class for builders """
|
|
|
|
def __init__(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def compile(self, source, objectname=None, includes=[], macros=[]):
|
|
|
|
"""
|
|
|
|
Compile the source file
|
|
|
|
"""
|
|
|
|
allmacros = []
|
|
|
|
allmacros.extend(COMMON_MACROS)
|
|
|
|
allmacros.extend(self.basemacros)
|
|
|
|
allmacros.extend(macros)
|
|
|
|
macrostring = self._build_command_string(allmacros, self.macro_delimiter)
|
|
|
|
|
|
|
|
allincludes = []
|
|
|
|
allincludes.extend(COMMON_INCLUDES)
|
|
|
|
allincludes.extend(includes)
|
|
|
|
includestring = self._build_command_string(allincludes, self.include_delimiter)
|
|
|
|
|
|
|
|
if not objectname:
|
|
|
|
objectname = source + self.object_extension
|
|
|
|
|
|
|
|
cmdstring = "%s %s %s %s %s %s" % (self.compiler,
|
|
|
|
self.compiler_parameters,
|
|
|
|
self.compiler_out_string(objectname),
|
|
|
|
self.compiler_in_string(source + self.source_extension),
|
|
|
|
includestring,
|
|
|
|
macrostring)
|
|
|
|
|
|
|
|
if VERBOSE: print cmdstring
|
|
|
|
return os.system(cmdstring)
|
|
|
|
|
|
|
|
def link(self, objects, outfile, libpaths=[], libraries=[], extra_parameters=None):
|
|
|
|
""" Link the binary from objects and libraries """
|
|
|
|
cmdstring = "%s %s %s" % (self.linker,
|
|
|
|
self.linker_parameters,
|
|
|
|
self.linker_out_string(outfile))
|
|
|
|
|
|
|
|
for objectfile in objects:
|
|
|
|
cmdstring = "%s %s" % (cmdstring, objectfile + self.object_extension)
|
|
|
|
for libpath in libpaths:
|
|
|
|
cmdstring = "%s %s%s" % (cmdstring, self.libpath_delimiter, libpath)
|
|
|
|
for library in libraries:
|
|
|
|
cmdstring = "%s %s" % (cmdstring, library)
|
|
|
|
if extra_parameters:
|
|
|
|
cmdstring = "%s %s" % (cmdstring, extra_parameters)
|
|
|
|
|
|
|
|
if VERBOSE: print cmdstring
|
|
|
|
return os.system(cmdstring)
|
|
|
|
|
|
|
|
def _build_command_string(self, macros, argument_delimiter):
|
|
|
|
macrostring = ""
|
|
|
|
|
|
|
|
for item in macros:
|
|
|
|
if type(item) == types.TupleType:
|
|
|
|
macrostring += '%s%s="%s" ' % (argument_delimiter, item[0], item[1])
|
|
|
|
else:
|
|
|
|
macrostring += '%s%s ' % (argument_delimiter, item)
|
|
|
|
|
|
|
|
return macrostring
|
|
|
|
|
|
|
|
|
|
|
|
class GCCBuilder(BuilderBase):
|
|
|
|
""" Generic GCC compiler class """
|
|
|
|
def __init__(self):
|
|
|
|
self.include_delimiter = "-I"
|
|
|
|
self.macro_delimiter = "-D"
|
|
|
|
self.libpath_delimiter = "-L"
|
2008-02-26 20:53:27 +01:00
|
|
|
self.compiler_parameters = "-fpermissive"
|
2007-10-20 09:03:51 +02:00
|
|
|
self.linker_parameters = "-shared"
|
|
|
|
self.basemacros = [ ]
|
2009-04-21 18:48:47 +02:00
|
|
|
self.compiler = "g++ -m32"
|
|
|
|
self.linker = "g++ -m32"
|
2007-10-20 09:03:51 +02:00
|
|
|
self.source_extension = ".cpp"
|
|
|
|
self.object_extension = ".o"
|
|
|
|
|
|
|
|
def compiler_in_string(self, filename):
|
|
|
|
return "-c %s" % filename
|
|
|
|
|
|
|
|
def compiler_out_string(self, filename):
|
|
|
|
return "-o %s" % filename
|
|
|
|
|
|
|
|
def linker_out_string(self, filename):
|
|
|
|
return "-o %s" % filename
|
|
|
|
|
|
|
|
|
|
|
|
class MSVCBuilder(BuilderBase):
|
2009-05-23 16:40:01 +02:00
|
|
|
""" Generic Visual C compiler class """
|
2007-10-20 09:03:51 +02:00
|
|
|
def __init__(self):
|
|
|
|
self.include_delimiter = "/I"
|
|
|
|
self.macro_delimiter = "/D"
|
|
|
|
self.libpath_delimiter = "/LIBPATH:"
|
|
|
|
self.compiler_parameters = "/nologo /EHsc"
|
|
|
|
self.linker_parameters = "/nologo /dll /export:PLUGIN"
|
|
|
|
self.basemacros = [ "WIN32",
|
|
|
|
"_USRDLL",
|
|
|
|
"__NT__" ]
|
|
|
|
self.compiler = "cl"
|
|
|
|
self.linker = "link"
|
|
|
|
self.source_extension = ".cpp"
|
|
|
|
self.object_extension = ".obj"
|
2009-09-16 16:00:31 +02:00
|
|
|
|
2007-10-20 09:03:51 +02:00
|
|
|
def compiler_in_string(self, filename):
|
|
|
|
return "/c %s" % filename
|
2009-09-16 16:00:31 +02:00
|
|
|
|
2007-10-20 09:03:51 +02:00
|
|
|
def compiler_out_string(self, filename):
|
|
|
|
return "/Fo%s" % filename
|
|
|
|
|
|
|
|
def linker_out_string(self, filename):
|
|
|
|
return "/out:%s" % filename
|
|
|
|
|
|
|
|
|
2009-05-23 16:40:01 +02:00
|
|
|
def build_distribution(manifest, distrootdir, ea64, nukeold):
|
|
|
|
""" Create a distibution to a directory and a ZIP file """
|
|
|
|
# (Re)create the output directory
|
2007-10-20 09:03:51 +02:00
|
|
|
if os.path.exists(distrootdir):
|
2009-05-23 16:40:01 +02:00
|
|
|
if nukeold:
|
|
|
|
shutil.rmtree(distrootdir)
|
|
|
|
os.makedirs(distrootdir)
|
|
|
|
else:
|
|
|
|
os.makedirs(distrootdir)
|
2008-08-15 22:51:16 +02:00
|
|
|
|
|
|
|
# Also make a ZIP archive of the build
|
|
|
|
zippath = distrootdir + ".zip"
|
2009-05-23 16:40:01 +02:00
|
|
|
zip = zipfile.ZipFile(zippath, nukeold and "w" or "a", zipfile.ZIP_DEFLATED)
|
2009-09-16 16:00:31 +02:00
|
|
|
|
2007-10-20 09:03:51 +02:00
|
|
|
# Copy files, one by one
|
|
|
|
for f in manifest:
|
|
|
|
if type(f) == types.TupleType:
|
|
|
|
srcfilepath = f[0]
|
|
|
|
srcfilename = os.path.basename(srcfilepath)
|
|
|
|
dstdir = distrootdir + os.sep + f[1]
|
|
|
|
dstfilepath = dstdir + os.sep + srcfilename
|
|
|
|
else:
|
|
|
|
srcfilepath = f
|
|
|
|
srcfilename = os.path.basename(f)
|
|
|
|
srcdir = os.path.dirname(f)
|
|
|
|
if srcdir == "":
|
|
|
|
dstdir = distrootdir
|
|
|
|
else:
|
2009-09-16 16:00:31 +02:00
|
|
|
dstdir = distrootdir + os.sep + srcdir
|
2009-05-23 16:41:26 +02:00
|
|
|
|
2007-10-20 09:03:51 +02:00
|
|
|
if not os.path.exists(dstdir):
|
|
|
|
os.makedirs(dstdir)
|
2009-09-16 16:00:31 +02:00
|
|
|
|
2007-10-20 09:03:51 +02:00
|
|
|
dstfilepath = dstdir + os.sep + srcfilename
|
|
|
|
shutil.copyfile(srcfilepath, dstfilepath)
|
2008-08-15 22:51:16 +02:00
|
|
|
zip.write(dstfilepath)
|
2007-10-20 09:03:51 +02:00
|
|
|
|
2008-08-15 22:51:16 +02:00
|
|
|
zip.close()
|
2007-10-20 09:03:51 +02:00
|
|
|
|
|
|
|
|
2009-05-23 16:40:01 +02:00
|
|
|
def build_plugin(platform, idasdkdir, plugin_name, ea64):
|
2009-10-02 19:40:26 +02:00
|
|
|
global SWIG_OPTIONS
|
2009-05-23 16:40:01 +02:00
|
|
|
""" Build the plugin from the SWIG wrapper and plugin main source """
|
|
|
|
# Path to the IDA SDK headers
|
2007-10-20 09:03:51 +02:00
|
|
|
ida_include_directory = idasdkdir + os.sep + "include"
|
|
|
|
|
2009-05-23 16:40:01 +02:00
|
|
|
builder = None
|
2007-10-20 09:03:51 +02:00
|
|
|
# Platform-specific settings for the Linux build
|
2009-05-23 16:40:01 +02:00
|
|
|
if platform == "linux":
|
2007-10-20 09:03:51 +02:00
|
|
|
builder = GCCBuilder()
|
|
|
|
platform_macros = [ "__LINUX__" ]
|
|
|
|
python_libpath = sysconfig.EXEC_PREFIX + os.sep + "lib"
|
|
|
|
python_library = "-lpython%d.%d" % (PYTHON_MAJOR_VERSION, PYTHON_MINOR_VERSION)
|
2010-01-05 19:24:04 +01:00
|
|
|
ida_libpath = os.path.join(idasdkdir, "lib", ea64 and "gcc64.lnx" or "gcc32.lnx")
|
2007-10-20 09:03:51 +02:00
|
|
|
ida_lib = ""
|
2009-05-21 21:32:16 +02:00
|
|
|
extra_link_parameters = ""
|
2007-10-20 09:03:51 +02:00
|
|
|
# Platform-specific settings for the Windows build
|
2009-10-02 19:40:26 +02:00
|
|
|
elif platform == "win32":
|
2007-10-20 09:03:51 +02:00
|
|
|
builder = MSVCBuilder()
|
|
|
|
platform_macros = [ "__NT__" ]
|
|
|
|
python_libpath = sysconfig.EXEC_PREFIX + os.sep + "libs"
|
|
|
|
python_library = "python%d%d.lib" % (PYTHON_MAJOR_VERSION, PYTHON_MINOR_VERSION)
|
2010-01-05 19:24:04 +01:00
|
|
|
ida_libpath = os.path.join(idasdkdir, "lib", ea64 and "vc.w64" or "vc.w32")
|
2007-10-20 09:03:51 +02:00
|
|
|
ida_lib = "ida.lib"
|
2009-10-02 19:40:26 +02:00
|
|
|
SWIG_OPTIONS += " -D__NT__ "
|
2009-05-21 21:32:16 +02:00
|
|
|
extra_link_parameters = ""
|
2009-05-23 16:40:01 +02:00
|
|
|
# Platform-specific settings for the Mac OS X build
|
2009-10-02 19:40:26 +02:00
|
|
|
elif platform == "macosx":
|
2007-10-20 09:03:51 +02:00
|
|
|
builder = GCCBuilder()
|
|
|
|
builder.linker_parameters = "-dynamiclib"
|
|
|
|
platform_macros = [ "__MAC__" ]
|
|
|
|
python_libpath = "."
|
|
|
|
python_library = "-framework Python"
|
2010-01-05 19:24:04 +01:00
|
|
|
ida_libpath = os.path.join(idasdkdir, "lib", ea64 and "gcc64.mac64" or "gcc32.mac")
|
2009-05-23 16:40:01 +02:00
|
|
|
ida_lib = ea64 and "-lida64" or "-lida"
|
2007-10-20 09:03:51 +02:00
|
|
|
extra_link_parameters = ""
|
|
|
|
|
2009-05-23 16:40:01 +02:00
|
|
|
assert builder, "Unknown platform! No idea how to build here..."
|
|
|
|
|
|
|
|
# Enable EA64 for the compiler if necessary
|
|
|
|
if ea64:
|
|
|
|
platform_macros.append("__EA64__")
|
2007-10-20 09:03:51 +02:00
|
|
|
|
2010-01-05 19:24:04 +01:00
|
|
|
if not '--no-early-load' in sys.argv:
|
2009-10-29 12:37:24 +01:00
|
|
|
platform_macros.append("PLUGINFIX")
|
|
|
|
|
2007-10-20 09:03:51 +02:00
|
|
|
# Build the wrapper from the interface files
|
2009-05-23 16:40:01 +02:00
|
|
|
ea64flag = ea64 and "-D__EA64__" or ""
|
|
|
|
swigcmd = "swig %s -Iswig -o idaapi.cpp %s -I%s idaapi.i" % (SWIG_OPTIONS, ea64flag, ida_include_directory)
|
2007-10-20 09:03:51 +02:00
|
|
|
if VERBOSE: print swigcmd
|
|
|
|
res = os.system(swigcmd)
|
2009-05-23 16:40:01 +02:00
|
|
|
assert res == 0, "Failed to build the wrapper with SWIG"
|
2007-10-20 09:03:51 +02:00
|
|
|
|
|
|
|
# Compile the wrapper
|
|
|
|
res = builder.compile("idaapi",
|
|
|
|
includes=[ PYTHON_INCLUDE_DIRECTORY, ida_include_directory ],
|
|
|
|
macros=platform_macros)
|
2009-05-23 16:40:01 +02:00
|
|
|
assert res == 0, "Failed to build the wrapper module"
|
2007-10-20 09:03:51 +02:00
|
|
|
|
|
|
|
# Compile the main plugin source
|
|
|
|
res = builder.compile("python",
|
|
|
|
includes=[ PYTHON_INCLUDE_DIRECTORY, ida_include_directory ],
|
|
|
|
macros=platform_macros)
|
2009-05-23 16:40:01 +02:00
|
|
|
assert res == 0, "Failed to build the main plugin object"
|
2007-10-20 09:03:51 +02:00
|
|
|
|
|
|
|
# Link the final binary
|
|
|
|
res = builder.link( ["idaapi", "python"],
|
|
|
|
plugin_name,
|
|
|
|
[ python_libpath, ida_libpath ],
|
|
|
|
[ python_library, ida_lib ],
|
|
|
|
extra_link_parameters)
|
2009-05-23 16:40:01 +02:00
|
|
|
assert res == 0, "Failed to link the plugin binary"
|
2007-10-20 09:03:51 +02:00
|
|
|
|
2009-10-19 09:21:22 +02:00
|
|
|
def detect_platform(ea64):
|
2007-10-20 09:03:51 +02:00
|
|
|
# Detect the platform
|
|
|
|
system = platform.system()
|
|
|
|
|
2007-12-06 14:56:20 +01:00
|
|
|
if system == "Windows" or system == "Microsoft":
|
2009-04-26 20:36:35 +02:00
|
|
|
system = "Windows"
|
2007-10-20 09:03:51 +02:00
|
|
|
platform_string = "win32"
|
2009-05-23 16:40:01 +02:00
|
|
|
plugin_name = ea64 and "python.p64" or "python.plw"
|
2009-09-16 16:00:31 +02:00
|
|
|
|
2009-10-19 09:21:22 +02:00
|
|
|
elif system == "Linux":
|
2007-10-20 09:03:51 +02:00
|
|
|
platform_string = "linux"
|
2009-05-23 16:40:01 +02:00
|
|
|
plugin_name = ea64 and "python.plx64" or "python.plx"
|
2007-10-20 09:03:51 +02:00
|
|
|
|
2009-10-19 09:21:22 +02:00
|
|
|
elif system == "Darwin":
|
2007-10-20 09:03:51 +02:00
|
|
|
platform_string = "macosx"
|
2009-05-23 16:40:01 +02:00
|
|
|
plugin_name = ea64 and "python.pmc64" or "python.pmc"
|
2009-10-19 09:21:22 +02:00
|
|
|
else:
|
|
|
|
print "Unknown platform!"
|
|
|
|
sys.exit(-1)
|
2009-05-23 16:40:01 +02:00
|
|
|
|
2009-10-19 09:21:22 +02:00
|
|
|
return (system, platform_string, plugin_name)
|
|
|
|
|
|
|
|
def build_binary_package(ea64, nukeold):
|
|
|
|
system, platform_string, plugin_name = detect_platform(ea64)
|
2009-09-16 16:00:31 +02:00
|
|
|
BINDISTDIR = "idapython-%d.%d.%d_ida%d.%d_py%d.%d_%s" % (VERSION_MAJOR,
|
|
|
|
VERSION_MINOR,
|
|
|
|
VERSION_PATCH,
|
|
|
|
IDA_MAJOR_VERSION,
|
2008-08-15 22:59:06 +02:00
|
|
|
IDA_MINOR_VERSION,
|
|
|
|
PYTHON_MAJOR_VERSION,
|
|
|
|
PYTHON_MINOR_VERSION,
|
|
|
|
platform_string)
|
2007-10-20 09:03:51 +02:00
|
|
|
# Build the plugin
|
2009-05-23 16:40:01 +02:00
|
|
|
build_plugin(platform_string, IDA_SDK, plugin_name, ea64)
|
2007-10-20 09:03:51 +02:00
|
|
|
# Build the binary distribution
|
|
|
|
binmanifest = []
|
2009-05-23 16:40:01 +02:00
|
|
|
if nukeold:
|
|
|
|
binmanifest.extend(BINDIST_MANIFEST)
|
2010-01-05 19:24:04 +01:00
|
|
|
binmanifest.extend([(x, "python") for x in "python/init.py", "python/idc.py", "python/idautils.py", "idaapi.py"])
|
2007-10-20 09:03:51 +02:00
|
|
|
binmanifest.append((plugin_name, "plugins"))
|
2009-05-23 16:40:01 +02:00
|
|
|
build_distribution(binmanifest, BINDISTDIR, ea64, nukeold)
|
2007-10-20 09:03:51 +02:00
|
|
|
|
2009-05-23 16:40:01 +02:00
|
|
|
|
|
|
|
def build_source_package():
|
|
|
|
""" Build a directory and a ZIP file with all the sources """
|
2009-09-16 16:00:31 +02:00
|
|
|
SRCDISTDIR = "idapython-%d.%d.%d" % (VERSION_MAJOR,
|
|
|
|
VERSION_MINOR,
|
|
|
|
VERSION_PATCH)
|
2009-05-23 16:40:01 +02:00
|
|
|
# Build the source distribution
|
2007-10-20 09:03:51 +02:00
|
|
|
srcmanifest = []
|
|
|
|
srcmanifest.extend(BINDIST_MANIFEST)
|
|
|
|
srcmanifest.extend(SRCDIST_MANIFEST)
|
2009-05-23 16:40:01 +02:00
|
|
|
srcmanifest.extend([(x, "python") for x in "python/init.py", "python/idc.py", "python/idautils.py"])
|
|
|
|
build_distribution(srcmanifest, SRCDISTDIR, ea64=False, nukeold=True)
|
2007-10-20 09:03:51 +02:00
|
|
|
|
2009-10-19 09:21:22 +02:00
|
|
|
def main():
|
2009-05-23 16:40:01 +02:00
|
|
|
# Do 64-bit build?
|
2009-09-16 16:00:31 +02:00
|
|
|
ea64 = '--ea64' in sys.argv
|
2009-05-23 16:40:01 +02:00
|
|
|
build_binary_package(ea64=False, nukeold=True)
|
2009-05-23 18:55:49 +02:00
|
|
|
if ea64:
|
|
|
|
build_binary_package(ea64=True, nukeold=False)
|
2009-05-23 16:40:01 +02:00
|
|
|
build_source_package()
|
2009-10-19 09:21:22 +02:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|