Skip to content

Commit

Permalink
Update ygg_options.cmake
Browse files Browse the repository at this point in the history
Add this branch to those the workflow runs for
Move command line options and configuration in setup.py to CMakeLists.txt
  • Loading branch information
langmm committed Jan 13, 2024
1 parent aefbca8 commit 03a5f7f
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 89 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ name: Build, test and upload to PyPI

on:
push:
branches: [ yggdrasil ]
branches: [ yggdrasil, scikit_build_core ]
pull_request:
branches: [ yggdrasil ]

Expand Down
47 changes: 47 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,19 @@ if (NOT RAPIDJSON_INCLUDE_DIRS)
cmake_path(APPEND CMAKE_CURRENT_SOURCE_DIR rapidjson include
OUTPUT_VARIABLE RAPIDJSON_INCLUDE_DIRS)
endif()
message(STATUS "RAPIDJSON_INCLUDE_DIRS = ${RAPIDJSON_INCLUDE_DIRS}")
if (NOT EXISTS ${RAPIDJSON_INCLUDE_DIRS})
message(FATAL_ERROR "RapidJSON sources not found: if you cloned "
" the git repository, you should initialize"
" the rapidjson submodule as explained in the"
" README.rst; in all other cases you may"
" want to report the issue.")
endif()

find_package(Python3 COMPONENTS Interpreter Development.Module NumPy REQUIRED)
if (Python3_VERSION VERSION_LESS "3.6.0")
message(FATAL_ERROR "Only Python 3.6+ is supported.")
endif()

Python3_add_library(
rapidjson MODULE rapidjson.cpp)
Expand All @@ -23,13 +34,49 @@ target_compile_options(
-DRAPIDJSON_HAS_STDSTRING
-DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION
-D_USE_MATH_DEFINES)
if (RAPIDJSON_EXACT_VERSION)
target_compile_options(
rapidjson PUBLIC
"-DRAPIDJSON_EXACT_VERSION=${RAPIDJSON_EXACT_VERSION}")
endif()
if (ASAN_COMPILE_FLAGS)
target_compile_options(rapidjson PUBLIC ${ASAN_COMPILE_FLAGS})
endif()
if (ASAN_LINK_FLAGS)
target_link_options(rapidjson PUBLIC ${ASAN_LINK_FLAGS})
endif()

if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# Avoid warning about invalid flag for C++
string(REPLACE "-Wstrict-prototypes" ""
CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string(REPLACE "-Wstrict-prototypes" ""
CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")

# Add -pedantic, so we get a warning when using non-standard features, and
# -Wno-long-long to pacify old gcc (or Apple's hybrids) that treat
# "long long" as an error under C++ (see issue #69). C++11 is required
# since commit
# https://github.com/Tencent/rapidjson/commit/9965ab37f6cfae3d58a0a6e34c76112866ace0b1
list(APPEND CMAKE_CXX_FLAGS -pedantic -Wno-long-long) # -std=c++11
# Up to Python 3.7, some structures use "char*" instead of "const char*",
# and ISO C++ forbids assigning string literal constants
if (Python3_VERSION VERSION_LESS "3.7.0")
list(APPEND CMAKE_CXX_FLAGS -Wno-write-strings)
endif()
endif()

# Exact version file
cmake_path(APPEND ${CMAKE_CURRENT_SOURCE_DIR} rapidjson_exact_version.txt
OUTPUT_VARIABLE RAPIDJSON_EXACT_VERSION_FILE)
if (EXISTS RAPIDJSON_EXACT_VERSION_FILE)
file(READ ${RAPIDJSON_EXACT_VERSION_FILE} RAPIDJSON_EXACT_VERSION)
string(STRIP ${RAPIDJSON_EXACT_VERSION} RAPIDJSON_EXACT_VERSION)
target_compile_options(
rapidjson PUBLIC
"-DRAPIDJSON_EXACT_VERSION=${RAPIDJSON_EXACT_VERSION}")
endif()

if (NOT Python_INSTALL_DIR)
set(Python_INSTALL_DIR ".")
endif()
Expand Down
4 changes: 3 additions & 1 deletion cmake/ygg_options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ endif()
if (SKBUILD)
message(STATUS "SKBUILD_PROJECT_NAME = ${SKBUILD_PROJECT_NAME}")
message(STATUS "SKBUILD_PROJECT_VERSION = ${SKBUILD_PROJECT_VERSION}")
PROJECT(${SKBUILD_PROJECT_NAME} VERSION "${SKBUILD_PROJECT_VERSION}")
if (NOT PROJECT_NAME)
PROJECT(${SKBUILD_PROJECT_NAME} VERSION "${SKBUILD_PROJECT_VERSION}")
endif()
if (WIN32)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
endif()
Expand Down
17 changes: 9 additions & 8 deletions run_script.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
set -e
# export ASAN_OPTIONS=symbolize=1
# export ASAN_SYMBOLIZER_PATH=$(which llvm-symbolizer)
## python setup.py develop --rj-include-dir=../rapidjson/include/ --with-asan
pip install -v -e .
# pip install --rj-include-dir=../rapidjson/include/ -e . # --with-asan -e .
## export DYLD_INSERT_LIBRARIES=/Users/langmm/mambaforge/envs/pyrj/lib/clang/14.0.6/lib/darwin/libclang_rt.asan_osx_dynamic.dylib
# export DYLD_INSERT_LIBRARIES=$(clang -print-file-name=libclang_rt.asan_osx_dynamic.dylib)
export ASAN_OPTIONS=symbolize=1
export ASAN_SYMBOLIZER_PATH=$(which llvm-symbolizer)
pip install --config-settings=cmake.define.RAPIDJSON_INCLUDE_DIRS=../rapidjson/include/ \
--config-settings=cmake.define.YGG_BUILD_ASAN:BOOL=ON \
--config-settings=cmake.define.YGG_BUILD_UBSAN:BOOL=ON \
-v -e .
# export DYLD_INSERT_LIBRARIES=/Users/langmm/mambaforge/envs/pyrj/lib/clang/14.0.6/lib/darwin/libclang_rt.asan_osx_dynamic.dylib
export DYLD_INSERT_LIBRARIES=$(clang -print-file-name=libclang_rt.asan_osx_dynamic.dylib)
python -m pytest -svx tests/
# make -C docs doctest -e PYTHON=$(which python3) -e DYLD_INSERT_LIBRARIES=$(clang -print-file-name=libclang_rt.asan_osx_dynamic.dylib)
make -C docs doctest -e PYTHON=$(which python3) -e DYLD_INSERT_LIBRARIES=$(clang -print-file-name=libclang_rt.asan_osx_dynamic.dylib)
79 changes: 0 additions & 79 deletions setup.py

This file was deleted.

0 comments on commit 03a5f7f

Please sign in to comment.