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
()
| 109 | shutil.copy(filename, outpath) |
| 110 | |
| 111 | def build_libraries(): |
| 112 | """ |
| 113 | Prepare the capstone directory for a binary distribution or installation. |
| 114 | Builds shared libraries and copies header files. |
| 115 | |
| 116 | Will use a src/ dir if one exists in the current directory, otherwise assumes it's in the repo |
| 117 | """ |
| 118 | cwd = os.getcwd() |
| 119 | clean_bins() |
| 120 | os.mkdir(HEADERS_DIR) |
| 121 | os.mkdir(LIBS_DIR) |
| 122 | |
| 123 | # copy public headers |
| 124 | shutil.copytree(os.path.join(BUILD_DIR, 'include', 'capstone'), os.path.join(HEADERS_DIR, 'capstone')) |
| 125 | |
| 126 | # if prebuilt libraries are available, use those and cancel build |
| 127 | if os.path.exists(os.path.join(ROOT_DIR, 'prebuilt', LIBRARY_FILE)): |
| 128 | logger.info('Using prebuilt libraries') |
| 129 | shutil.copy(os.path.join(ROOT_DIR, 'prebuilt', LIBRARY_FILE), LIBS_DIR) |
| 130 | return |
| 131 | |
| 132 | os.chdir(BUILD_DIR) |
| 133 | |
| 134 | # platform description refers at https://docs.python.org/3/library/sys.html#sys.platform |
| 135 | # Use cmake for both Darwin and Windows since it can generate fat binaries |
| 136 | if SYSTEM == "win32" or SYSTEM == 'darwin': |
| 137 | # Windows build: this process requires few things: |
| 138 | # - CMake + MSVC installed |
| 139 | # - Run this command in an environment setup for MSVC |
| 140 | if not os.path.exists("build"): |
| 141 | os.mkdir("build") |
| 142 | os.chdir("build") |
| 143 | print("Build Directory: {}\n".format(os.getcwd())) |
| 144 | # Only build capstone.dll / libcapstone.dylib |
| 145 | if SYSTEM in ('win32', 'cygwin'): |
| 146 | os.system('cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=OFF -DCAPSTONE_BUILD_TESTS=OFF -DCAPSTONE_BUILD_CSTOOL=OFF -G "NMake Makefiles" ..') |
| 147 | else: |
| 148 | os.system('cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DCAPSTONE_BUILD_TESTS=OFF -DCAPSTONE_BUILD_CSTOOL=OFF -G "Unix Makefiles" ..') |
| 149 | os.system("cmake --build .") |
| 150 | else: # Unix incl. cygwin |
| 151 | os.system("CAPSTONE_BUILD_CORE_ONLY=yes bash ./make.sh") |
| 152 | |
| 153 | shutil.copy(VERSIONED_LIBRARY_FILE, os.path.join(LIBS_DIR, LIBRARY_FILE)) |
| 154 | os.chdir(cwd) |
| 155 | |
| 156 | |
| 157 | class custom_sdist(sdist): |
no test coverage detected
searching dependent graphs…