Skip to content

Commit

Permalink
Fix sdist build and add CI job for testing it.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rot127 committed Feb 6, 2025
1 parent d7ef910 commit 8a88a38
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 5 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/build-wheels-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,15 @@ jobs:
name: sdist-archive
path: bindings/python/dist/*.tar.gz

- name: Test build with sdist
run: |
TMP_DIR=$(mktemp -d)
mkdir $TMP_DIR/
tar -xf bindings/python/dist/*.tar.gz -C $TMP_DIR/
cd $TMP_DIR/capstone-*/src
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DCAPSTONE_BUILD_CSTEST=OFF -DCAPSTONE_BUILD_CSTOOL=OFF -B build
cmake --build build
publish:
needs: [ build_wheels_always, build_wheels_all, make_sdist ]
environment: pypi
Expand Down
1 change: 1 addition & 0 deletions BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ Capstone allows some more customization via the following options:
- `CAPSTONE_BUILD_STATIC_LIBS`: Build static libraries (`ON` by default).
- `CAPSTONE_BUILD_STATIC_MSVC_RUNTIME`: (Windows only) - Build with static MSVC runtime. Always set if `CAPSTONE_BUILD_SHARED_LIBS=ON`.
- `CAPSTONE_BUILD_CSTOOL`: Enable/disable build of `cstool`. Default is enabled if build runs from the repository root.
- `CAPSTONE_BUILD_FUZZER`: Build the fuzzer in `suite/fuzz`.
- `CAPSTONE_USE_SYS_DYN_MEM`: change this to OFF to use your own dynamic memory management.
- `CAPSTONE_BUILD_MACOS_THIN`: MacOS only. Disables universal2 build. So you only get the binary for you processor architecture.
- `CAPSTONE_BUILD_DIET`: change this to ON to make the binaries more compact.
Expand Down
11 changes: 8 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ option(CAPSTONE_BUILD_DIET "Build diet library" OFF)
option(CAPSTONE_BUILD_LEGACY_TESTS "Build legacy tests" ${PROJECT_IS_TOP_LEVEL})
option(CAPSTONE_BUILD_CSTOOL "Build cstool" ${PROJECT_IS_TOP_LEVEL})
option(CAPSTONE_BUILD_CSTEST "Build cstest" OFF)
option(CAPSTONE_BUILD_FUZZER "Build the fuzzer" OFF)
option(CAPSTONE_USE_DEFAULT_ALLOC "Use default memory allocation functions" ON)
option(CAPSTONE_USE_ARCH_REGISTRATION "Use explicit architecture registration" OFF)
option(CAPSTONE_ARCHITECTURE_DEFAULT "Whether architectures are enabled by default" ON)
Expand Down Expand Up @@ -832,8 +833,12 @@ endif()
# Simply because it builds the fuzzer there again with hard-coded paths.
# See: https://github.com/google/oss-fuzz/blob/master/projects/capstone/build.sh
# and: https://github.com/capstone-engine/capstone/issues/2454
add_executable(fuzz_disasm ${PROJECT_SOURCE_DIR}/suite/fuzz/onefile.c ${PROJECT_SOURCE_DIR}/suite/fuzz/fuzz_disasm.c ${PROJECT_SOURCE_DIR}/suite/fuzz/platform.c)
target_link_libraries(fuzz_disasm PRIVATE capstone)
#
# CAPSTONE_BUILD_TESTS check for v5 compatibility.
if (CAPSTONE_BUILD_TESTS OR CAPSTONE_BUILD_FUZZER)
add_executable(fuzz_disasm ${PROJECT_SOURCE_DIR}/suite/fuzz/onefile.c ${PROJECT_SOURCE_DIR}/suite/fuzz/fuzz_disasm.c ${PROJECT_SOURCE_DIR}/suite/fuzz/platform.c)
target_link_libraries(fuzz_disasm PRIVATE capstone)
endif()

source_group("Source\\Engine" FILES ${SOURCES_ENGINE})
source_group("Source\\ARM" FILES ${SOURCES_ARM})
Expand Down Expand Up @@ -989,4 +994,4 @@ endif()

# Include CPack
set(CPACK_PROJECT_CONFIG_FILE "${CMAKE_SOURCE_DIR}/CPackConfig.cmake")
include(CPackConfig.txt)
include(CPackConfig.txt)
9 changes: 9 additions & 0 deletions LICENSES/MIT.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
MIT License

Copyright (c) <year> <copyright holders>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
7 changes: 5 additions & 2 deletions bindings/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,17 @@ def copy_sources():

shutil.copytree(os.path.join(BUILD_DIR, "arch"), os.path.join(SRC_DIR, "arch"))
shutil.copytree(os.path.join(BUILD_DIR, "include"), os.path.join(SRC_DIR, "include"))
shutil.copytree(os.path.join(BUILD_DIR, "LICENSES"), os.path.join(SRC_DIR, "LICENSES"))

src.extend(glob.glob(os.path.join(BUILD_DIR, "*.[ch]")))
src.extend(glob.glob(os.path.join(BUILD_DIR, "*.m[dk]")))
src.extend(glob.glob(os.path.join(BUILD_DIR, "*.in")))
src.extend(glob.glob(os.path.join(BUILD_DIR, "LICENSES/*")))
src.extend(glob.glob(os.path.join(BUILD_DIR, "*.TXT")))
src.extend(glob.glob(os.path.join(BUILD_DIR, "SPONSORS.TXT")))
src.extend(glob.glob(os.path.join(BUILD_DIR, "CREDITS.TXT")))
src.extend(glob.glob(os.path.join(BUILD_DIR, "ChangeLog")))
src.extend(glob.glob(os.path.join(BUILD_DIR, "CMakeLists.txt")))
src.extend(glob.glob(os.path.join(BUILD_DIR, "CPackConfig.txt")))
src.extend(glob.glob(os.path.join(BUILD_DIR, "CPackConfig.cmake")))

for filename in src:
outpath = os.path.join(SRC_DIR, os.path.basename(filename))
Expand Down

0 comments on commit 8a88a38

Please sign in to comment.