From 1e11e06efa8aebe7a8fe4d35c09a715d07dac9a3 Mon Sep 17 00:00:00 2001 From: Keenan Gugeler Date: Tue, 5 Dec 2023 10:11:02 -0500 Subject: [PATCH] rust: disable scripts 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. --- CMakeLists.txt | 2 ++ src/CMakeLists.txt | 24 +++++++++++++----------- third_party/antlr4_cypher/CMakeLists.txt | 24 +++++++++++++----------- tools/rust_api/build.rs | 6 +++++- 4 files changed, 33 insertions(+), 23 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ad14baef8f..fe3b6074f9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 98ca3e14fa..285430a333 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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) diff --git a/third_party/antlr4_cypher/CMakeLists.txt b/third_party/antlr4_cypher/CMakeLists.txt index f893c87eb6..2c8b639231 100644 --- a/third_party/antlr4_cypher/CMakeLists.txt +++ b/third_party/antlr4_cypher/CMakeLists.txt @@ -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 diff --git a/tools/rust_api/build.rs b/tools/rust_api/build.rs index 0e9b30614e..bdc48afe9d 100644 --- a/tools/rust_api/build.rs +++ b/tools/rust_api/build.rs @@ -96,7 +96,11 @@ fn build_bundled_cmake() -> Result, Box> { }; 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");