Skip to content

Commit 0b96483

Browse files
authored
Fast rebuilds of C/C++ code when needed. (#106)
* Fast rebuilds of C/C++ code when needed. Configures * `CMake` to use `ccache` for faster C/C++ compilation. * Modifies `pyproject.toml` to enable `editable.rebuild` and specify `build-dir` for `scikit-build-core`, ensuring fast, incremental rebuilds when C/C++ sources or project metadata change.
1 parent 8b58f79 commit 0b96483

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,18 @@ endif()
1212
string(REGEX MATCH "^[0-9]+(\\.[0-9]+)*" CMAKE_NLE_VERSION "${NLE_VERSION}")
1313
project(nle VERSION ${CMAKE_NLE_VERSION})
1414

15+
# Only enable ccache if this is the main project, not a sub-dependency.
16+
if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
17+
find_program(CCACHE_EXECUTABLE ccache)
18+
if(CCACHE_EXECUTABLE)
19+
message(STATUS "ccache found, enabling for C and C++")
20+
set(CMAKE_C_COMPILER_LAUNCHER "${CCACHE_EXECUTABLE}")
21+
set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_EXECUTABLE}")
22+
else()
23+
message(STATUS "ccache not found, proceeding without it")
24+
endif()
25+
endif()
26+
1527
if(CMAKE_BUILD_TYPE MATCHES Debug)
1628
message("Debug build.")
1729
# Unclear if this is even necessary. `dsymutil rlmain -o rlmain.dSYM` seems to

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ cmake.build-type = "Release"
3838
cmake.args = ["-DHACKDIR=nle/nethackdir", "-DPYTHON_PACKAGE_NAME=nle"]
3939
minimum-version = "build-system.requires"
4040
metadata.version.provider = "scikit_build_core.metadata.setuptools_scm"
41+
build-dir = "build/{wheel_tag}"
42+
editable.rebuild = true
4143
generate = [
4244
{ path = "nle/version.py", template = '__version__ = "${version}"' },
4345
]

0 commit comments

Comments
 (0)