Skip to content

Commit

Permalink
rust: disable scripts
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.

Additionally, Rust shouldn't use the automatic grammar generation. I've
also disabled that in the crate build.
  • Loading branch information
Riolku committed Dec 5, 2023
1 parent 86b82d4 commit f1dd6b6
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 23 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,14 @@ if(${ENABLE_LTO})
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()

option(AUTO_UPDATE_GRAMMAR "Automatically regenerate C++ grammar files on change." TRUE)
option(BUILD_BENCHMARK "Build benchmarks." FALSE)
option(BUILD_EXAMPLES "Build examples." FALSE)
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. Requires Python >= 3.9." 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)
24 changes: 13 additions & 11 deletions third_party/antlr4_cypher/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
add_custom_command(
OUTPUT
${CMAKE_CURRENT_SOURCE_DIR}/cypher_lexer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/cypher_parser.cpp
${CMAKE_CURRENT_SOURCE_DIR}/include/cypher_lexer.h
${CMAKE_CURRENT_SOURCE_DIR}/include/cypher_parser.h
COMMAND cmake -D ROOT_DIR=${PROJECT_SOURCE_DIR} -P generate_grammar.cmake
DEPENDS
${PROJECT_SOURCE_DIR}/src/antlr4/Cypher.g4
${PROJECT_SOURCE_DIR}/scripts/antlr4/generate_grammar.cmake
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/scripts/antlr4)
if(${AUTO_UPDATE_GRAMMAR})
add_custom_command(
OUTPUT
${CMAKE_CURRENT_SOURCE_DIR}/cypher_lexer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/cypher_parser.cpp
${CMAKE_CURRENT_SOURCE_DIR}/include/cypher_lexer.h
${CMAKE_CURRENT_SOURCE_DIR}/include/cypher_parser.h
COMMAND cmake -D ROOT_DIR=${PROJECT_SOURCE_DIR} -P generate_grammar.cmake
DEPENDS
${PROJECT_SOURCE_DIR}/src/antlr4/Cypher.g4
${PROJECT_SOURCE_DIR}/scripts/antlr4/generate_grammar.cmake
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/scripts/antlr4)
endif()

add_library(antlr4_cypher
STATIC
Expand Down
6 changes: 5 additions & 1 deletion tools/rust_api/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,11 @@ 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")
.define("AUTO_UPDATE_GRAMMAR", "OFF");
if cfg!(windows) {
build.generator("Ninja");
build.cxxflag("/EHsc");
Expand Down

0 comments on commit f1dd6b6

Please sign in to comment.