This commit is contained in:
Nguyen Anh Quynh 2014-09-30 07:45:37 +08:00
commit 39eb84a9b1
5 changed files with 15 additions and 10 deletions

View File

@ -24,7 +24,6 @@ install_cython:
cp setup_cython.py $(OBJDIR) cp setup_cython.py $(OBJDIR)
cp pyx/ccapstone* $(OBJDIR)/pyx/ cp pyx/ccapstone* $(OBJDIR)/pyx/
cp capstone/__init__.py $(OBJDIR)/pyx/__init__.py cp capstone/__init__.py $(OBJDIR)/pyx/__init__.py
cp capstone/capstone.py $(OBJDIR)/pyx/capstone.pyx
cp capstone/arm.py $(OBJDIR)/pyx/arm.pyx cp capstone/arm.py $(OBJDIR)/pyx/arm.pyx
cp capstone/arm_const.py $(OBJDIR)/pyx/arm_const.pyx cp capstone/arm_const.py $(OBJDIR)/pyx/arm_const.pyx
cp capstone/arm64.py $(OBJDIR)/pyx/arm64.pyx cp capstone/arm64.py $(OBJDIR)/pyx/arm64.pyx
@ -41,7 +40,10 @@ install_cython:
cp capstone/x86_const.py $(OBJDIR)/pyx/x86_const.pyx cp capstone/x86_const.py $(OBJDIR)/pyx/x86_const.pyx
cp capstone/xcore.py $(OBJDIR)/pyx/xcore.pyx cp capstone/xcore.py $(OBJDIR)/pyx/xcore.pyx
cp capstone/xcore_const.py $(OBJDIR)/pyx/xcore_const.pyx cp capstone/xcore_const.py $(OBJDIR)/pyx/xcore_const.pyx
cd $(OBJDIR) && python setup_cython.py build -b ./tmp install --home=$(OBJDIR)
mv $(OBJDIR)/build/lib/python/capstone/* capstone
cd $(OBJDIR) && python setup_cython.py build -b ./tmp install cd $(OBJDIR) && python setup_cython.py build -b ./tmp install
clean: clean:
rm -rf $(OBJDIR) rm -rf $(OBJDIR)
rm -f capstone/*.so

View File

@ -3,7 +3,7 @@ import sys
_python2 = sys.version_info.major < 3 _python2 = sys.version_info.major < 3
if _python2: if _python2:
range = xrange range = xrange
from capstone import arm, arm64, mips, ppc, sparc, systemz, x86, xcore from . import arm, arm64, mips, ppc, sparc, systemz, x86, xcore
__all__ = [ __all__ = [
'Cs', 'Cs',
@ -648,7 +648,7 @@ class Cs(object):
self._detail = False # by default, do not produce instruction details self._detail = False # by default, do not produce instruction details
self._diet = cs_support(CS_SUPPORT_DIET) self._diet = cs_support(CS_SUPPORT_DIET)
self._x86reduce = cs_support(CS_SUPPORT_X86_REDUCE) self._x86reduce = cs_support(CS_SUPPORT_X86_REDUCE)
# default mnemonic for SKIPDATA # default mnemonic for SKIPDATA
self._skipdata_mnem = ".byte" self._skipdata_mnem = ".byte"
self._skipdata = False self._skipdata = False
@ -816,7 +816,7 @@ class Cs(object):
def debug(): def debug():
# is Cython there? # is Cython there?
try: try:
import ccapstone from . import ccapstone
return ccapstone.debug() return ccapstone.debug()
except: except:
# no Cython, fallback to Python code below # no Cython, fallback to Python code below

View File

@ -2,7 +2,7 @@
cimport pyx.ccapstone as cc cimport pyx.ccapstone as cc
import capstone, ctypes import capstone, ctypes
from capstone import arm, x86, mips, ppc, arm64, sparc, systemz, xcore, CsError from . import arm, x86, mips, ppc, arm64, sparc, systemz, xcore, CsError
_diet = cc.cs_support(capstone.CS_SUPPORT_DIET) _diet = cc.cs_support(capstone.CS_SUPPORT_DIET)

View File

@ -7,7 +7,7 @@ VERSION = '3.0'
compile_args = ['-O3', '-fomit-frame-pointer'] compile_args = ['-O3', '-fomit-frame-pointer']
ext_modules = [ Extension("capstone.capstone", ["pyx/capstone.pyx"], extra_compile_args=compile_args), ext_modules = [
Extension("capstone.ccapstone", ["pyx/ccapstone.pyx"], libraries=["capstone"], extra_compile_args=compile_args), Extension("capstone.ccapstone", ["pyx/ccapstone.pyx"], libraries=["capstone"], extra_compile_args=compile_args),
Extension("capstone.arm", ["pyx/arm.pyx"], extra_compile_args=compile_args), Extension("capstone.arm", ["pyx/arm.pyx"], extra_compile_args=compile_args),
Extension("capstone.arm_const", ["pyx/arm_const.pyx"], extra_compile_args=compile_args), Extension("capstone.arm_const", ["pyx/arm_const.pyx"], extra_compile_args=compile_args),
@ -18,7 +18,11 @@ ext_modules = [ Extension("capstone.capstone", ["pyx/capstone.pyx"], extra_compi
Extension("capstone.ppc", ["pyx/ppc.pyx"], extra_compile_args=compile_args), Extension("capstone.ppc", ["pyx/ppc.pyx"], extra_compile_args=compile_args),
Extension("capstone.ppc_const", ["pyx/ppc_const.pyx"], extra_compile_args=compile_args), Extension("capstone.ppc_const", ["pyx/ppc_const.pyx"], extra_compile_args=compile_args),
Extension("capstone.x86", ["pyx/x86.pyx"], extra_compile_args=compile_args), Extension("capstone.x86", ["pyx/x86.pyx"], extra_compile_args=compile_args),
Extension("capstone.x86_const", ["pyx/x86_const.pyx"], extra_compile_args=compile_args) Extension("capstone.x86_const", ["pyx/x86_const.pyx"], extra_compile_args=compile_args),
Extension("capstone.sparc", ["pyx/sparc.pyx"], extra_compile_args=compile_args),
Extension("capstone.sparc_const", ["pyx/sparc_const.pyx"], extra_compile_args=compile_args),
Extension("capstone.systemz", ["pyx/systemz.pyx"], extra_compile_args=compile_args),
Extension("capstone.sysz_const", ["pyx/sysz_const.pyx"], extra_compile_args=compile_args),
Extension("capstone.xcore", ["pyx/xcore.pyx"], extra_compile_args=compile_args), Extension("capstone.xcore", ["pyx/xcore.pyx"], extra_compile_args=compile_args),
Extension("capstone.xcore_const", ["pyx/xcore_const.pyx"], extra_compile_args=compile_args) Extension("capstone.xcore_const", ["pyx/xcore_const.pyx"], extra_compile_args=compile_args)
] ]
@ -40,8 +44,8 @@ setup(
packages = ['capstone'], packages = ['capstone'],
name = 'capstone', name = 'capstone',
version = VERSION, version = VERSION,
cmdclass = {'build_ext': build_ext}, cmdclass = {'build_ext': build_ext},
ext_modules = ext_modules, ext_modules = ext_modules,
author = 'Nguyen Anh Quynh', author = 'Nguyen Anh Quynh',
author_email = 'aquynh@gmail.com', author_email = 'aquynh@gmail.com',
description = 'Capstone disassembly engine', description = 'Capstone disassembly engine',

View File

@ -47,7 +47,6 @@ all_tests = (
(CS_ARCH_XCORE, 0, XCORE_CODE, "XCore", 0), (CS_ARCH_XCORE, 0, XCORE_CODE, "XCore", 0),
) )
# ## Test cs_disasm_quick() # ## Test cs_disasm_quick()
def test_cs_disasm_quick(): def test_cs_disasm_quick():
for arch, mode, code, comment, syntax in all_tests: for arch, mode, code, comment, syntax in all_tests: