Skip to content

Commit bb1ef07

Browse files
committed
Fix sdist build and add CI job for testing it.
1 parent d7ef910 commit bb1ef07

File tree

5 files changed

+31
-5
lines changed

5 files changed

+31
-5
lines changed

.github/workflows/build-wheels-publish.yml

+8
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,14 @@ jobs:
264264
name: sdist-archive
265265
path: bindings/python/dist/*.tar.gz
266266

267+
- name: Test build with sdist
268+
run: |
269+
TMP_DIR=$(mktemp -d)
270+
tar -xf bindings/python/dist/*.tar.gz -C $TMP_DIR/
271+
cd $TMP_DIR/capstone-*/src
272+
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DCAPSTONE_BUILD_CSTEST=OFF -DCAPSTONE_BUILD_CSTOOL=OFF -B build
273+
cmake --build build
274+
267275
publish:
268276
needs: [ build_wheels_always, build_wheels_all, make_sdist ]
269277
environment: pypi

BUILDING.md

+1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ Capstone allows some more customization via the following options:
8282
- `CAPSTONE_BUILD_STATIC_LIBS`: Build static libraries (`ON` by default).
8383
- `CAPSTONE_BUILD_STATIC_MSVC_RUNTIME`: (Windows only) - Build with static MSVC runtime. Always set if `CAPSTONE_BUILD_SHARED_LIBS=ON`.
8484
- `CAPSTONE_BUILD_CSTOOL`: Enable/disable build of `cstool`. Default is enabled if build runs from the repository root.
85+
- `CAPSTONE_BUILD_FUZZER`: Build the fuzzer in `suite/fuzz`.
8586
- `CAPSTONE_USE_SYS_DYN_MEM`: change this to OFF to use your own dynamic memory management.
8687
- `CAPSTONE_BUILD_MACOS_THIN`: MacOS only. Disables universal2 build. So you only get the binary for you processor architecture.
8788
- `CAPSTONE_BUILD_DIET`: change this to ON to make the binaries more compact.

CMakeLists.txt

+8-3
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ option(CAPSTONE_BUILD_DIET "Build diet library" OFF)
7575
option(CAPSTONE_BUILD_LEGACY_TESTS "Build legacy tests" ${PROJECT_IS_TOP_LEVEL})
7676
option(CAPSTONE_BUILD_CSTOOL "Build cstool" ${PROJECT_IS_TOP_LEVEL})
7777
option(CAPSTONE_BUILD_CSTEST "Build cstest" OFF)
78+
option(CAPSTONE_BUILD_FUZZER "Build the fuzzer" OFF)
7879
option(CAPSTONE_USE_DEFAULT_ALLOC "Use default memory allocation functions" ON)
7980
option(CAPSTONE_USE_ARCH_REGISTRATION "Use explicit architecture registration" OFF)
8081
option(CAPSTONE_ARCHITECTURE_DEFAULT "Whether architectures are enabled by default" ON)
@@ -832,8 +833,12 @@ endif()
832833
# Simply because it builds the fuzzer there again with hard-coded paths.
833834
# See: https://github.com/google/oss-fuzz/blob/master/projects/capstone/build.sh
834835
# and: https://github.com/capstone-engine/capstone/issues/2454
835-
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)
836-
target_link_libraries(fuzz_disasm PRIVATE capstone)
836+
#
837+
# CAPSTONE_BUILD_TESTS check for v5 compatibility.
838+
if (CAPSTONE_BUILD_TESTS OR CAPSTONE_BUILD_FUZZER)
839+
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)
840+
target_link_libraries(fuzz_disasm PRIVATE capstone)
841+
endif()
837842

838843
source_group("Source\\Engine" FILES ${SOURCES_ENGINE})
839844
source_group("Source\\ARM" FILES ${SOURCES_ARM})
@@ -989,4 +994,4 @@ endif()
989994

990995
# Include CPack
991996
set(CPACK_PROJECT_CONFIG_FILE "${CMAKE_SOURCE_DIR}/CPackConfig.cmake")
992-
include(CPackConfig.txt)
997+
include(CPackConfig.txt)

LICENSES/MIT.txt

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
MIT License
2+
3+
Copyright (c) <year> <copyright holders>
4+
5+
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:
6+
7+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8+
9+
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.

bindings/python/setup.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,17 @@ def copy_sources():
8282

8383
shutil.copytree(os.path.join(BUILD_DIR, "arch"), os.path.join(SRC_DIR, "arch"))
8484
shutil.copytree(os.path.join(BUILD_DIR, "include"), os.path.join(SRC_DIR, "include"))
85+
shutil.copytree(os.path.join(BUILD_DIR, "LICENSES"), os.path.join(SRC_DIR, "LICENSES"))
8586

8687
src.extend(glob.glob(os.path.join(BUILD_DIR, "*.[ch]")))
8788
src.extend(glob.glob(os.path.join(BUILD_DIR, "*.m[dk]")))
8889
src.extend(glob.glob(os.path.join(BUILD_DIR, "*.in")))
89-
src.extend(glob.glob(os.path.join(BUILD_DIR, "LICENSES/*")))
90-
src.extend(glob.glob(os.path.join(BUILD_DIR, "*.TXT")))
90+
src.extend(glob.glob(os.path.join(BUILD_DIR, "SPONSORS.TXT")))
91+
src.extend(glob.glob(os.path.join(BUILD_DIR, "CREDITS.TXT")))
9192
src.extend(glob.glob(os.path.join(BUILD_DIR, "ChangeLog")))
9293
src.extend(glob.glob(os.path.join(BUILD_DIR, "CMakeLists.txt")))
94+
src.extend(glob.glob(os.path.join(BUILD_DIR, "CPackConfig.txt")))
95+
src.extend(glob.glob(os.path.join(BUILD_DIR, "CPackConfig.cmake")))
9396

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

0 commit comments

Comments
 (0)