Skip to content

Commit

Permalink
rust: disable single file header
Browse files Browse the repository at this point in the history
Rust doesn't need the single file header. In the interest of keeping the
crate size small, I've simply added a flag that disables generation of
the single file header. The single file header still builds by default.
  • Loading branch information
Riolku committed Dec 5, 2023
1 parent 86b82d4 commit d222de3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ option(BUILD_JAVA "Build Java API." FALSE)
option(BUILD_NODEJS "Build NodeJS API." FALSE)
option(BUILD_PYTHON "Build Python API." FALSE)
option(BUILD_SHELL "Build Interactive Shell" TRUE)
option(BUILD_SINGLE_FILE_HEADER "Build single file header." TRUE)
option(BUILD_TESTS "Build C++ tests." FALSE)

option(BUILD_LCOV "Build coverage report." FALSE)
Expand Down
24 changes: 13 additions & 11 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,18 @@ endif()

install(TARGETS kuzu kuzu_shared)

# Create a command to generate kuzu.hpp, and then create a target that is
# always built that depends on it. This allows our generator to detect when
# exactly to build kuzu.hpp, while still building the target by default.
find_package(Python3 3.9...4 REQUIRED)
add_custom_command(
OUTPUT kuzu.hpp
COMMAND
${Python3_EXECUTABLE} ${PROJECT_SOURCE_DIR}/scripts/collect-single-file-header.py
DEPENDS
${PROJECT_SOURCE_DIR}/scripts/collect-single-file-header.py kuzu_shared)
add_custom_target(single_file_header ALL DEPENDS kuzu.hpp)
if(${BUILD_SINGLE_FILE_HEADER})
# Create a command to generate kuzu.hpp, and then create a target that is
# always built that depends on it. This allows our generator to detect when
# exactly to build kuzu.hpp, while still building the target by default.
find_package(Python3 3.9...4 REQUIRED)
add_custom_command(
OUTPUT kuzu.hpp
COMMAND
${Python3_EXECUTABLE} ${PROJECT_SOURCE_DIR}/scripts/collect-single-file-header.py
DEPENDS
${PROJECT_SOURCE_DIR}/scripts/collect-single-file-header.py kuzu_shared)
add_custom_target(single_file_header ALL DEPENDS kuzu.hpp)
endif()

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/kuzu.hpp ${CMAKE_CURRENT_SOURCE_DIR}/include/c_api/kuzu.h TYPE INCLUDE)
5 changes: 4 additions & 1 deletion tools/rust_api/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@ fn build_bundled_cmake() -> Result<Vec<PathBuf>, Box<dyn std::error::Error>> {
};

let mut build = cmake::Config::new(&kuzu_root);
build.no_build_target(true).define("BUILD_SHELL", "OFF");
build
.no_build_target(true)
.define("BUILD_SHELL", "OFF")
.define("BUILD_SINGLE_FILE_HEADER", "OFF");
if cfg!(windows) {
build.generator("Ninja");
build.cxxflag("/EHsc");
Expand Down

0 comments on commit d222de3

Please sign in to comment.