From 7b40e5d9f0e87a6cd907793fb0e0066e531a0062 Mon Sep 17 00:00:00 2001 From: Rot127 Date: Thu, 15 Aug 2024 06:27:52 -0500 Subject: [PATCH] Revert "Remove Make build from setup.py" This reverts commit 03641abe3fdeb874cbd13d39ac01e6397c0d0b42. --- bindings/python/pyproject.toml | 2 +- bindings/python/setup.py | 32 +++++++++++++++++++------------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/bindings/python/pyproject.toml b/bindings/python/pyproject.toml index 739e7ad3f5..fed528d4a7 100644 --- a/bindings/python/pyproject.toml +++ b/bindings/python/pyproject.toml @@ -1,3 +1,3 @@ [build-system] -requires = ["setuptools", "cmake"] +requires = ["setuptools"] build-backend = "setuptools.build_meta" diff --git a/bindings/python/setup.py b/bindings/python/setup.py index 2297c40f1c..cf23d71ffb 100755 --- a/bindings/python/setup.py +++ b/bindings/python/setup.py @@ -92,11 +92,14 @@ def copy_sources(): shutil.copytree(os.path.join(BUILD_DIR, "include"), os.path.join(SRC_DIR, "include")) src.extend(glob.glob(os.path.join(BUILD_DIR, "*.[ch]"))) + src.extend(glob.glob(os.path.join(BUILD_DIR, "*.mk"))) + src.extend(glob.glob(os.path.join(BUILD_DIR, "Makefile"))) src.extend(glob.glob(os.path.join(BUILD_DIR, "LICENSE*"))) src.extend(glob.glob(os.path.join(BUILD_DIR, "README"))) src.extend(glob.glob(os.path.join(BUILD_DIR, "*.TXT"))) src.extend(glob.glob(os.path.join(BUILD_DIR, "RELEASE_NOTES"))) + src.extend(glob.glob(os.path.join(BUILD_DIR, "make.sh"))) src.extend(glob.glob(os.path.join(BUILD_DIR, "CMakeLists.txt"))) src.extend(glob.glob(os.path.join(BUILD_DIR, "pkgconfig.mk"))) @@ -131,19 +134,22 @@ def build_libraries(): os.chdir(BUILD_DIR) - # platform description refers at https://docs.python.org/2/library/sys.html#sys.platform - # Use cmake for both Darwin and Windows since it can generate fat binaries - # Windows build: this process requires few things: - # - MSVC installed - # - Run this command in an environment setup for MSVC - if not os.path.exists("build"): os.mkdir("build") - os.chdir("build") - print("Build Directory: {}\n".format(os.getcwd())) - if SYSTEM == "win32": - os.system('cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DCAPSTONE_BUILD_TESTS=OFF -DCAPSTONE_BUILD_CSTOOL=OFF -G "NMake Makefiles" ..') - else: - os.system('cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DCAPSTONE_BUILD_TESTS=OFF -DCAPSTONE_BUILD_CSTOOL=OFF -G "Unix Makefiles" ..') - os.system("cmake --build .") + # platform description refers at https://docs.python.org/3/library/sys.html#sys.platform + if SYSTEM == "win32" or SYSTEM == 'darwin': + # Windows build: this process requires few things: + # - CMake + MSVC installed + # - Run this command in an environment setup for MSVC + if not os.path.exists("build"): os.mkdir("build") + os.chdir("build") + print("Build Directory: {}\n".format(os.getcwd())) + # Only build capstone.dll / libcapstone.dylib + if SYSTEM == "win32": + os.system('cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DCAPSTONE_BUILD_TESTS=OFF -DCAPSTONE_BUILD_CSTOOL=OFF -G "NMake Makefiles" ..') + else: + os.system('cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DCAPSTONE_BUILD_TESTS=OFF -DCAPSTONE_BUILD_CSTOOL=OFF -G "Unix Makefiles" ..') + os.system("cmake --build .") + else: # Unix incl. cygwin + os.system("CAPSTONE_BUILD_CORE_ONLY=yes bash ./make.sh") shutil.copy(VERSIONED_LIBRARY_FILE, os.path.join(LIBS_DIR, LIBRARY_FILE))