Rizin
unix-like reverse engineering framework and cli tools
setup_cython Namespace Reference

Classes

class  custom_build
 

Functions

def clean_bins ()
 
def copy_pysources ()
 
def build_libraries ()
 

Variables

 SYSTEM = sys.platform
 
string VERSION = '4.0.0'
 
int IS_64BITS = sys.maxsize > 2**32
 
 ROOT_DIR = os.path.dirname(os.path.realpath(__file__))
 
 LIBS_DIR = os.path.join(ROOT_DIR, 'pyx', 'lib')
 
 HEADERS_DIR = os.path.join(ROOT_DIR, 'pyx', 'include')
 
 SRC_DIR = os.path.join(ROOT_DIR, 'src')
 
 BUILD_DIR = SRC_DIR if os.path.exists(SRC_DIR) else os.path.join(ROOT_DIR, '../..')
 
 PYPACKAGE_DIR = os.path.join(ROOT_DIR, 'capstone')
 
 CYPACKAGE_DIR = os.path.join(ROOT_DIR, 'pyx')
 
string VERSIONED_LIBRARY_FILE = "libcapstone.4.dylib"
 
string LIBRARY_FILE = "libcapstone.dylib"
 
string STATIC_LIBRARY_FILE = 'libcapstone.a'
 
list compile_args = ['-O3', '-fomit-frame-pointer', '-I' + HEADERS_DIR]
 
list link_args = ['-L' + LIBS_DIR]
 
list ext_module_names = ['arm', 'arm_const', 'arm64', 'arm64_const', 'm68k', 'm68k_const', 'm680x', 'm680x_const', 'mips', 'mips_const', 'ppc', 'ppc_const', 'x86', 'x86_const', 'sparc', 'sparc_const', 'systemz', 'sysz_const', 'xcore', 'xcore_const', 'tms320c64x', 'tms320c64x_const', 'evm', 'evm_const' ]
 
list ext_modules
 
 extra_compile_args
 
 extra_link_args
 

Function Documentation

◆ build_libraries()

def setup_cython.build_libraries ( )
Prepare the capstone directory for a binary distribution or installation.
Builds shared libraries and copies header files.

Will use a src/ dir if one exists in the current directory, otherwise assumes it's in the repo

Definition at line 70 of file setup_cython.py.

70 def build_libraries():
71  """
72  Prepare the capstone directory for a binary distribution or installation.
73  Builds shared libraries and copies header files.
74 
75  Will use a src/ dir if one exists in the current directory, otherwise assumes it's in the repo
76  """
77  cwd = os.getcwd()
78  clean_bins()
79  os.mkdir(HEADERS_DIR)
80  os.mkdir(LIBS_DIR)
81 
82  # copy public headers
83  shutil.copytree(os.path.join(BUILD_DIR, 'include', 'capstone'), os.path.join(HEADERS_DIR, 'capstone'))
84 
85  os.chdir(BUILD_DIR)
86 
87  # platform description refers at https://docs.python.org/2/library/sys.html#sys.platform
88  if SYSTEM == "win32":
89  # Windows build: this process requires few things:
90  # - CMake + MSVC installed
91  # - Run this command in an environment setup for MSVC
92  if not os.path.exists("build"): os.mkdir("build")
93  os.chdir("build")
94  # Do not build tests & static library
95  os.system('cmake -DCMAKE_BUILD_TYPE=RELEASE -DCAPSTONE_BUILD_TESTS=0 -DCAPSTONE_BUILD_STATIC=0 -G "NMake Makefiles" ..')
96  os.system("nmake")
97  else: # Unix incl. cygwin
98  os.system("CAPSTONE_BUILD_CORE_ONLY=yes bash ./make.sh")
99 
100  shutil.copy(VERSIONED_LIBRARY_FILE, os.path.join(LIBS_DIR, LIBRARY_FILE))
101  if STATIC_LIBRARY_FILE: shutil.copy(STATIC_LIBRARY_FILE, LIBS_DIR)
102  os.chdir(cwd)
103 
104 
def build_libraries()
Definition: setup_cython.py:70
def clean_bins()
Definition: setup_cython.py:56

References clean_bins().

Referenced by setup_cython.custom_build.run().

◆ clean_bins()

def setup_cython.clean_bins ( )

Definition at line 56 of file setup_cython.py.

56 def clean_bins():
57  shutil.rmtree(LIBS_DIR, ignore_errors=True)
58  shutil.rmtree(HEADERS_DIR, ignore_errors=True)
59 

Referenced by build_libraries().

◆ copy_pysources()

def setup_cython.copy_pysources ( )

Definition at line 60 of file setup_cython.py.

60 def copy_pysources():
61  for fname in os.listdir(PYPACKAGE_DIR):
62  if not fname.endswith('.py'):
63  continue
64 
65  if fname == '__init__.py':
66  shutil.copy(os.path.join(PYPACKAGE_DIR, fname), os.path.join(CYPACKAGE_DIR, fname))
67  else:
68  shutil.copy(os.path.join(PYPACKAGE_DIR, fname), os.path.join(CYPACKAGE_DIR, fname + 'x'))
69 
def copy_pysources()
Definition: setup_cython.py:60

Referenced by setup_cython.custom_build.run().

Variable Documentation

◆ BUILD_DIR

setup_cython.BUILD_DIR = SRC_DIR if os.path.exists(SRC_DIR) else os.path.join(ROOT_DIR, '../..')

Definition at line 23 of file setup_cython.py.

◆ compile_args

list setup_cython.compile_args = ['-O3', '-fomit-frame-pointer', '-I' + HEADERS_DIR]

Definition at line 40 of file setup_cython.py.

◆ CYPACKAGE_DIR

setup_cython.CYPACKAGE_DIR = os.path.join(ROOT_DIR, 'pyx')

Definition at line 25 of file setup_cython.py.

◆ ext_module_names

list setup_cython.ext_module_names = ['arm', 'arm_const', 'arm64', 'arm64_const', 'm68k', 'm68k_const', 'm680x', 'm680x_const', 'mips', 'mips_const', 'ppc', 'ppc_const', 'x86', 'x86_const', 'sparc', 'sparc_const', 'systemz', 'sysz_const', 'xcore', 'xcore_const', 'tms320c64x', 'tms320c64x_const', 'evm', 'evm_const' ]

Definition at line 43 of file setup_cython.py.

◆ ext_modules

list setup_cython.ext_modules
Initial value:
1 = [Extension("capstone.ccapstone",
2  ["pyx/ccapstone.pyx"],
3  libraries=["capstone"],
4  extra_compile_args=compile_args,
5  extra_link_args=link_args)]

Definition at line 45 of file setup_cython.py.

◆ extra_compile_args

setup_cython.extra_compile_args

Definition at line 52 of file setup_cython.py.

◆ extra_link_args

setup_cython.extra_link_args

Definition at line 53 of file setup_cython.py.

◆ HEADERS_DIR

setup_cython.HEADERS_DIR = os.path.join(ROOT_DIR, 'pyx', 'include')

Definition at line 21 of file setup_cython.py.

◆ IS_64BITS

int setup_cython.IS_64BITS = sys.maxsize > 2**32

Definition at line 16 of file setup_cython.py.

◆ LIBRARY_FILE

string setup_cython.LIBRARY_FILE = "libcapstone.dylib"

Definition at line 29 of file setup_cython.py.

◆ LIBS_DIR

setup_cython.LIBS_DIR = os.path.join(ROOT_DIR, 'pyx', 'lib')

Definition at line 20 of file setup_cython.py.

◆ link_args

list setup_cython.link_args = ['-L' + LIBS_DIR]

Definition at line 41 of file setup_cython.py.

◆ PYPACKAGE_DIR

setup_cython.PYPACKAGE_DIR = os.path.join(ROOT_DIR, 'capstone')

Definition at line 24 of file setup_cython.py.

◆ ROOT_DIR

setup_cython.ROOT_DIR = os.path.dirname(os.path.realpath(__file__))

Definition at line 19 of file setup_cython.py.

◆ SRC_DIR

setup_cython.SRC_DIR = os.path.join(ROOT_DIR, 'src')

Definition at line 22 of file setup_cython.py.

◆ STATIC_LIBRARY_FILE

string setup_cython.STATIC_LIBRARY_FILE = 'libcapstone.a'

Definition at line 30 of file setup_cython.py.

◆ SYSTEM

setup_cython.SYSTEM = sys.platform

Definition at line 11 of file setup_cython.py.

◆ VERSION

string setup_cython.VERSION = '4.0.0'

Definition at line 12 of file setup_cython.py.

◆ VERSIONED_LIBRARY_FILE

string setup_cython.VERSIONED_LIBRARY_FILE = "libcapstone.4.dylib"

Definition at line 28 of file setup_cython.py.