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

Classes

class  custom_sdist
 
class  custom_build
 
class  custom_bdist_egg
 
class  custom_develop
 

Functions

def clean_bins ()
 
def copy_sources ()
 
def build_libraries ()
 
def dummy_src ()
 

Variables

 SYSTEM = sys.platform
 
int IS_64BITS = sys.maxsize > 2**32
 
 ROOT_DIR = os.path.dirname(os.path.realpath(__file__))
 
 LIBS_DIR = os.path.join(ROOT_DIR, 'capstone', 'lib')
 
 HEADERS_DIR = os.path.join(ROOT_DIR, 'capstone', '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, '../..')
 
dictionary VERSION_DATA = {}
 
 lines = fp.readlines()
 
 line = line.strip()
 
 k = k.strip()
 
 v = v.strip()
 
string VERSION = '{PKG_MAJOR}.{PKG_MINOR}.{PKG_EXTRA}.{PKG_TAG}'.format(**VERSION_DATA)
 
string VERSIONED_LIBRARY_FILE = "libcapstone.{PKG_MAJOR}.dylib".format(**VERSION_DATA)
 
string LIBRARY_FILE = "libcapstone.dylib"
 
string STATIC_LIBRARY_FILE = 'libcapstone.a'
 
dictionary cmdclass = {}
 
int idx = sys.argv.index('bdist_wheel') + 1
 
 name = get_platform()
 
string long_desc
 
 provides
 
 packages
 
 version
 
 author
 
 author_email
 
 description
 
 long_description
 
 long_description_content_type
 
 url
 
 python_requires
 
 classifiers
 
 requires
 
 zip_safe
 
 include_package_data
 
 is_pure
 
 package_data
 

Function Documentation

◆ build_libraries()

def setup.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 108 of file setup.py.

108 def build_libraries():
109  """
110  Prepare the capstone directory for a binary distribution or installation.
111  Builds shared libraries and copies header files.
112 
113  Will use a src/ dir if one exists in the current directory, otherwise assumes it's in the repo
114  """
115  cwd = os.getcwd()
116  clean_bins()
117  os.mkdir(HEADERS_DIR)
118  os.mkdir(LIBS_DIR)
119 
120  # copy public headers
121  shutil.copytree(os.path.join(BUILD_DIR, 'include', 'capstone'), os.path.join(HEADERS_DIR, 'capstone'))
122 
123  # if prebuilt libraries are available, use those and cancel build
124  if os.path.exists(os.path.join(ROOT_DIR, 'prebuilt', LIBRARY_FILE)) and \
125  (not STATIC_LIBRARY_FILE or os.path.exists(os.path.join(ROOT_DIR, 'prebuilt', STATIC_LIBRARY_FILE))):
126  shutil.copy(os.path.join(ROOT_DIR, 'prebuilt', LIBRARY_FILE), LIBS_DIR)
127  if STATIC_LIBRARY_FILE is not None:
128  shutil.copy(os.path.join(ROOT_DIR, 'prebuilt', STATIC_LIBRARY_FILE), LIBS_DIR)
129  return
130 
131  os.chdir(BUILD_DIR)
132 
133  # platform description refers at https://docs.python.org/2/library/sys.html#sys.platform
134  if SYSTEM == "win32":
135  # Windows build: this process requires few things:
136  # - CMake + MSVC installed
137  # - Run this command in an environment setup for MSVC
138  if not os.path.exists("build"): os.mkdir("build")
139  os.chdir("build")
140  # Do not build tests & static library
141  os.system('cmake -DCMAKE_BUILD_TYPE=RELEASE -DCAPSTONE_BUILD_TESTS=0 -DCAPSTONE_BUILD_STATIC=0 -G "NMake Makefiles" ..')
142  os.system("nmake")
143  else: # Unix incl. cygwin
144  os.system("CAPSTONE_BUILD_CORE_ONLY=yes bash ./make.sh")
145 
146  shutil.copy(VERSIONED_LIBRARY_FILE, os.path.join(LIBS_DIR, LIBRARY_FILE))
147 
148  # only copy static library if it exists (it's a build option)
149  if STATIC_LIBRARY_FILE and os.path.exists(STATIC_LIBRARY_FILE):
150  shutil.copy(STATIC_LIBRARY_FILE, LIBS_DIR)
151  os.chdir(cwd)
152 
153 
def build_libraries()
Definition: setup.py:108
def clean_bins()
Definition: setup.py:72

References clean_bins().

Referenced by setup.custom_build.run(), and setup.custom_develop.run().

◆ clean_bins()

def setup.clean_bins ( )

Definition at line 72 of file setup.py.

72 def clean_bins():
73  shutil.rmtree(LIBS_DIR, ignore_errors=True)
74  shutil.rmtree(HEADERS_DIR, ignore_errors=True)
75 

Referenced by build_libraries(), and setup.custom_sdist.run().

◆ copy_sources()

def setup.copy_sources ( )
Copy the C sources into the source directory.
This rearranges the source files under the python distribution
directory.

Definition at line 76 of file setup.py.

76 def copy_sources():
77  """Copy the C sources into the source directory.
78  This rearranges the source files under the python distribution
79  directory.
80  """
81  src = []
82 
83  try:
84  shutil.rmtree("src/")
85  except (IOError, OSError):
86  pass
87 
88  shutil.copytree(os.path.join(BUILD_DIR, "arch"), os.path.join(SRC_DIR, "arch"))
89  shutil.copytree(os.path.join(BUILD_DIR, "include"), os.path.join(SRC_DIR, "include"))
90 
91  src.extend(glob.glob(os.path.join(BUILD_DIR, "*.[ch]")))
92  src.extend(glob.glob(os.path.join(BUILD_DIR, "*.mk")))
93 
94  src.extend(glob.glob(os.path.join(BUILD_DIR, "Makefile")))
95  src.extend(glob.glob(os.path.join(BUILD_DIR, "LICENSE*")))
96  src.extend(glob.glob(os.path.join(BUILD_DIR, "README")))
97  src.extend(glob.glob(os.path.join(BUILD_DIR, "*.TXT")))
98  src.extend(glob.glob(os.path.join(BUILD_DIR, "RELEASE_NOTES")))
99  src.extend(glob.glob(os.path.join(BUILD_DIR, "make.sh")))
100  src.extend(glob.glob(os.path.join(BUILD_DIR, "CMakeLists.txt")))
101  src.extend(glob.glob(os.path.join(BUILD_DIR, "pkgconfig.mk")))
102 
103  for filename in src:
104  outpath = os.path.join(SRC_DIR, os.path.basename(filename))
105  log.info("%s -> %s" % (filename, outpath))
106  shutil.copy(filename, outpath)
107 
def copy_sources()
Definition: setup.py:76

Referenced by setup.custom_sdist.run().

◆ dummy_src()

def setup.dummy_src ( )

Definition at line 176 of file setup.py.

176 def dummy_src():
177  return []
178 
def dummy_src()
Definition: setup.py:176

Variable Documentation

◆ author

setup.author

Definition at line 257 of file setup.py.

◆ author_email

setup.author_email

Definition at line 258 of file setup.py.

◆ BUILD_DIR

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

Definition at line 27 of file setup.py.

◆ classifiers

setup.classifiers

Definition at line 264 of file setup.py.

◆ cmdclass

setup.cmdclass = {}

Definition at line 179 of file setup.py.

◆ description

setup.description

Definition at line 259 of file setup.py.

Referenced by rz_core_cmd_init(), usage(), and zip_error_strerror().

◆ HEADERS_DIR

setup.HEADERS_DIR = os.path.join(ROOT_DIR, 'capstone', 'include')

Definition at line 25 of file setup.py.

◆ idx

int setup.idx = sys.argv.index('bdist_wheel') + 1

Definition at line 197 of file setup.py.

Referenced by __analysis_fcn_check_bp_use(), __getname(), __getoffset(), __handle_mouse_on_panel(), __handle_mouse_on_X(), __parse_string_on_cursor(), __set_curnode(), __update_help_contents(), __update_panel_contents(), _fill_bin_import(), _fill_bin_symbol(), _zip_add_entry(), _zip_file_extra_field_prepare_for_change(), _zip_file_get_offset(), _zip_file_replace(), _zip_get_dirent(), _zip_get_name(), _zip_open(), _zip_read_local_ef(), _zip_set_name(), _zip_unchange(), aarch64_get_expected_qualifier(), aarch64_print_operand(), add_from_zip(), add_mem_change(), add_refline(), add_reg_change(), Aindexof(), analysis_fill_ai_rg(), analysis_mask(), bfvm_peek(), bfvm_poke(), bin_elf_versioninfo_verneed(), bin_trycatch(), buffer_write(), can_replace(), cat(), check_buffer(), check_pe32_buf(), check_pe64_buf(), cmd_prc(), compute_size(), construct_rop_gadget(), core_analysis_bytes_desc(), core_analysis_bytes_esil(), core_analysis_bytes_size(), core_analysis_graph_label(), count_extra(), count_extra_by_id(), decode_add(), decode_cmp(), decode_cmpi(), decode_known(), decode_mov_args(), decode_movi(), decode_movin(), decode_movn(), decode_movrel(), decode_movsn_args(), decode_not(), decode_pcp_insn(), decode_push_pop(), decode_sizeq(), decode_tricore_insn(), delete(), delete_extra(), delete_extra_by_id(), do_special_decoding(), do_syscall_search(), ds_print_meta_infos(), ds_show_functions(), ef_read(), emit_get_ar(), emit_get_var(), emit_regs(), extract(), extract_binobj(), find_autocmplt_type_at_stmt(), find_core_reg(), get_addr(), get_AR_regs_class2(), get_cmp_op(), get_extra(), get_extra_by_id(), get_file_comment(), get_imports(), get_operand_possible_qualifiers(), get_reg_name_1(), get_reg_name_2(), get_reg_name_3(), get_reg_name_4(), get_reg_pair(), getpcfromstack(), init_hash_tables(), internal_ht_grow(), is_seekable(), is_simple_type(), ldm(), like_cb(), LZ4_putIndexOnHash(), LZ4HC_Insert(), LZ4IO_displayCompressedFilesInfo(), magiccheck(), main(), merge_zip(), name_locate(), next_idx(), node_cmp(), oneshot_buffer(), operand_general_constraint_met_p(), optional_operand_p(), parse_array_type(), parse_atomic_type(), parse_comp_unit_lang(), parse_enum_type(), parse_enumerator(), parse_function(), parse_function_args_and_vars(), parse_import_ptr(), parse_import_stub(), parse_namemap(), parse_signature(), parse_simple_type(), parse_struct_member(), parse_structure_type(), parse_symbol_table(), parse_type_entry(), parse_typedef(), parseCodeDirectory(), print_byte(), print_instruction_ops(), print_instruction_trace(), printHistBlock(), rabin_extract(), rc2_crypt(), rc2_dcrypt(), rcc_element(), read_arm64_ins(), read_reg(), replace(), replace_file_contents(), resolve_mig_subsystem(), restore_register(), run_basic_block_analysis(), rz_analysis_diff_fingerprint_bb(), rz_analysis_esil_get_instruction_trace(), rz_analysis_esil_trace_list(), rz_analysis_esil_trace_restore(), rz_analysis_esil_trace_show(), rz_analysis_function_cost(), rz_analysis_mask(), rz_arm_it_apply_cond(), rz_asm_get_offset(), rz_asm_massemble(), rz_asm_mdisassemble(), rz_bin_fatmach0_extract(), rz_bin_pdb_calling_convention_as_string(), rz_bin_pe_get_sections(), rz_bin_wasm_get_function_name(), rz_bp_del_index(), rz_bp_get_index(), rz_bv_set_from_bytes_be(), rz_bv_set_from_bytes_le(), rz_cmd_add(), rz_cmd_debug_trace_esil_handler(), rz_cmd_del(), rz_cmd_macro_list(), rz_cmd_print(), rz_cons_rainbow_get(), rz_core_asm_bwdisassemble(), rz_core_asm_strsearch(), rz_core_disasm_pdi_with_buf(), rz_core_esil_continue_back(), rz_core_print_disasm(), rz_core_seek_peek(), rz_core_visual_xrefs(), rz_debug_drx_set(), rz_debug_drx_unset(), rz_egg_mkvar(), rz_graph_get_node(), rz_graph_node_iter(), rz_heap_bin_content(), rz_heap_chunks_list(), rz_hex_bin2str(), rz_hex_bin2strdup(), rz_il_validate_global_context_add_mem(), rz_io_zip_get_by_file_idx(), rz_json_item(), rz_main_rz_asm(), rz_print_byte(), rz_reg_get_type(), rz_reg_index_get(), rz_reg_set_value(), rz_regs_columns_handler(), rz_str_bits(), rz_str_firstbut(), rz_str_lastbut(), rz_str_word_get0(), rz_str_word_get0set(), rz_strpool_slice(), rz_type_format_data_internal(), rz_type_format_struct_size(), rz_utf_block_name(), sdb_array_delete(), sdb_array_get(), sdb_array_get_num(), sdb_array_insert(), sdb_array_insert_num(), sdb_array_remove(), sdb_array_remove_num(), sdb_array_set(), sdb_array_set_num(), sdb_array_unset(), sdb_aslice(), sdb_fmt_tobin(), sdb_querys(), seek(), select_operand_for_fptype_field_coding(), select_operand_for_sf_field_coding(), sep64_xtr_ctx_get_slice(), set_elem_idx_out_of_range_error(), set_error(), set_extra(), set_file_comment(), set_file_compression(), set_file_dostime(), set_file_encryption(), set_file_mtime(), set_file_mtime_all(), set_imm_out_of_range_error(), set_multiplier_out_of_range_error(), set_offset_out_of_range_error(), set_other_error(), set_out_of_range_error(), set_reg_list_error(), set_regno_out_of_range_error(), set_sft_amount_out_of_range_error(), set_syntax_error(), set_unaligned_error(), show_analysis_classes(), show_class(), skip_hp(), stm(), strbuf_rev_append_char(), strbuf_rev_prepend_char(), test_file(), type_match(), unchange_one(), uv_cpu_info(), var_functions_show(), var_variables_show(), version2double(), write_reg(), xreg(), z80_op_size(), zin_close(), zip_delete(), zip_dir_add(), zip_file_extra_field_delete(), zip_file_extra_field_delete_by_id(), zip_file_extra_field_get(), zip_file_extra_field_get_by_id(), zip_file_extra_field_set(), zip_file_extra_fields_count(), zip_file_extra_fields_count_by_id(), zip_file_get_comment(), zip_file_get_external_attributes(), zip_file_rename(), zip_file_replace(), zip_file_set_comment(), zip_file_set_dostime(), zip_file_set_encryption(), zip_file_set_external_attributes(), zip_file_set_mtime(), zip_fopen(), zip_fopen_encrypted(), zip_get_file_comment(), zip_get_name(), zip_rename(), zip_replace(), zip_set_file_comment(), zip_set_file_compression(), zip_stat(), zip_unchange(), zrename(), and zstat().

◆ include_package_data

setup.include_package_data

Definition at line 276 of file setup.py.

◆ IS_64BITS

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

Definition at line 20 of file setup.py.

◆ is_pure

setup.is_pure

Definition at line 277 of file setup.py.

◆ k

setup.k = k.strip()

Definition at line 42 of file setup.py.

◆ LIBRARY_FILE

string setup.LIBRARY_FILE = "libcapstone.dylib"

Definition at line 61 of file setup.py.

◆ LIBS_DIR

setup.LIBS_DIR = os.path.join(ROOT_DIR, 'capstone', 'lib')

Definition at line 24 of file setup.py.

◆ line

setup.line = line.strip()

Definition at line 34 of file setup.py.

Referenced by __file_history_down(), __file_history_up(), __sdb_prompt(), _handle_call(), bgets(), check_label(), clean_line(), clusterLoadConfig(), confirm_replace(), core_analysis_graph_label(), dcpu16_assemble(), diff_hexdump_line(), diff_hexdump_partial(), disasm_strings(), disassemble(), do_rd_expr(), ds_print_dwarf(), ds_print_ref_lines(), ds_update_ref_lines(), fill_colored_args(), fill_hist_offset(), fill_wrapped_comment(), flirt_pat_parse_line(), foreach_list_cb(), get_dispatchmessage_offset(), get_ibmi_physical_address(), get_lines(), get_utf8_char(), insn_to_str(), load_1(), load_b(), main(), main_help(), pager_color_line(), pager_printpage(), parse(), parse_list(), parse_mime(), parse_reg_profile_str(), print_line(), print_rop(), print_totals_basic(), prompt(), rd_character(), rd_expr_and(), rd_expr_equal(), rd_expr_or(), rd_expr_shift(), rd_expr_unequal(), rd_expr_xor(), rd_factor(), rd_label(), rd_number(), rd_otherbasenumber(), rd_term(), rd_value(), read_string_val(), replace_asm_test(), replace_lines(), rz_bin_addr2line(), rz_bin_source_line_info_builder_push_sample(), rz_cmd_kuery(), rz_cons_get_column(), rz_cons_hud(), rz_core_cmd_subst_i(), rz_core_debug_esil(), rz_core_fortune_get_random(), rz_core_fortune_print_random(), rz_core_prompt(), rz_core_serve(), rz_core_visual_bit_editor(), rz_core_visual_trackflags(), rz_core_visual_view_rop(), rz_coresym_cache_element_line_info_fini(), rz_diff_draw_tui(), rz_file_slurp_line(), rz_file_slurp_lines(), rz_file_slurp_lines_from_bottom(), rz_file_slurp_random_line_count(), rz_lang_prompt(), rz_line_hist_add(), rz_line_hist_cmd_down(), rz_line_hist_cmd_up(), rz_line_hist_offset_down(), rz_line_hist_offset_up(), rz_line_hist_sdb_down(), rz_line_hist_sdb_up(), rz_line_set_hist_callback(), rz_main_rz_run(), RZ_PACKED(), rz_sign_flirt_parse_string_pattern_from_buffer(), rz_str_scale(), rz_str_widget_list(), rz_test_load_asm_test_file(), rz_test_load_cmd_test_file(), rz_test_load_json_test_file(), rz_write_unified_patch_handler(), setup_hist_match(), show_help(), srecord_parse(), step_line(), TAG_CALLBACK(), and tokenize_lines().

◆ lines

setup.lines = fp.readlines()

Definition at line 32 of file setup.py.

◆ long_desc

string setup.long_desc

Definition at line 210 of file setup.py.

◆ long_description

setup.long_description

Definition at line 260 of file setup.py.

◆ long_description_content_type

setup.long_description_content_type

Definition at line 261 of file setup.py.

◆ name

setup.name = get_platform()

Definition at line 199 of file setup.py.

◆ package_data

setup.package_data

Definition at line 278 of file setup.py.

◆ packages

setup.packages

Definition at line 254 of file setup.py.

◆ provides

setup.provides

Definition at line 253 of file setup.py.

Referenced by anop32().

◆ python_requires

setup.python_requires

Definition at line 263 of file setup.py.

◆ requires

setup.requires

Definition at line 273 of file setup.py.

◆ ROOT_DIR

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

Definition at line 23 of file setup.py.

◆ SRC_DIR

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

Definition at line 26 of file setup.py.

◆ STATIC_LIBRARY_FILE

string setup.STATIC_LIBRARY_FILE = 'libcapstone.a'

Definition at line 62 of file setup.py.

◆ SYSTEM

setup.SYSTEM = sys.platform

Definition at line 16 of file setup.py.

◆ url

◆ v

setup.v = v.strip()

Definition at line 42 of file setup.py.

◆ VERSION

string setup.VERSION = '{PKG_MAJOR}.{PKG_MINOR}.{PKG_EXTRA}.{PKG_TAG}'.format(**VERSION_DATA)

Definition at line 55 of file setup.py.

◆ version

setup.version

Definition at line 256 of file setup.py.

◆ VERSION_DATA

dictionary setup.VERSION_DATA = {}

Definition at line 30 of file setup.py.

◆ VERSIONED_LIBRARY_FILE

string setup.VERSIONED_LIBRARY_FILE = "libcapstone.{PKG_MAJOR}.dylib".format(**VERSION_DATA)

Definition at line 60 of file setup.py.

◆ zip_safe

setup.zip_safe

Definition at line 275 of file setup.py.