Skip to content

Commit 847c465

Browse files
committed
Make pybind rely on main proj
1 parent d1d8820 commit 847c465

10 files changed

Lines changed: 306 additions & 592 deletions

File tree

.github/workflows/python.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,18 @@ jobs:
2121
pip install --upgrade pip
2222
pip install -r requirements.txt
2323
pip install pytest
24+
pip install pybind11
25+
pip install scikit-build
2426
2527
- name: Build libCacheSim-python
2628
run: |
29+
cmake -B ${{github.workspace}}/build \
30+
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \
31+
-DCMAKE_C_FLAGS="-fPIC" \
32+
-DCMAKE_CXX_FLAGS="-fPIC"
33+
cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
2734
cd libCacheSim-python
28-
pip install -e .
35+
pip install -e . --no-build-isolation
2936
3037
- name: Run tests
3138
run: |

CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ option(SUPPORT_TTL "whether support TTL" OFF)
2525
option(OPT_SUPPORT_ZSTD_TRACE "whether support zstd trace" ON)
2626
option(ENABLE_LRB "enable LRB" OFF)
2727
option(ENABLE_3L_CACHE "enable 3LCache" OFF)
28+
# For python binding
29+
option(BUILD_PYTHON_BINDING "Build Python binding" OFF)
30+
option(ENABLE_PIC "Build all targets with -fPIC (for shared libs/Python bindings)" OFF)
2831
set(LOG_LEVEL "default" CACHE STRING "change the logging level")
2932
set_property(CACHE LOG_LEVEL PROPERTY STRINGS ERROR WARN INFO DEBUG VERBOSE DEFAULT)
3033

@@ -41,6 +44,11 @@ else()
4144
message(FATAL_ERROR "unsupported operating system ${CMAKE_SYSTEM_NAME}")
4245
endif()
4346

47+
if(ENABLE_PIC)
48+
message(STATUS "enabling position independent code")
49+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
50+
endif()
51+
4452
configure_file(libCacheSim/include/config.h.in libCacheSim/include/config.h)
4553

4654
if(SUPPORT_TTL)
@@ -295,3 +303,10 @@ install(EXPORT ${PROJECT_NAME}Targets
295303
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
296304
)
297305

306+
# Python binding subdir
307+
if(BUILD_PYTHON_BINDING)
308+
message(STATUS "Building Python binding")
309+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/libCacheSim-python)
310+
else()
311+
message(STATUS "Skipping Python binding (use -DBUILD_PYTHON_BINDING=ON to enable)")
312+
endif()

0 commit comments

Comments
 (0)