diff --git a/CMakeLists.txt b/CMakeLists.txt index 9995132d..43acdaa3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -166,7 +166,7 @@ if (FLS_BUILD_TESTING OR FLS_BUILD_CUDA OR FLS_ENABLE_FSST_TESTING_AND_BENCHMARK # Gtest: ----------------------------------------------------------------------------------------------------------- FetchContent_Declare(googletest GIT_REPOSITORY https://github.com/google/googletest.git - GIT_TAG e2239ee6043f73722e7aa812a459f54a28552929 # release-1.11.0 + GIT_TAG v1.15.2 ) # For Windows: Prevent overriding the parent project's compiler/linker settings set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) @@ -174,21 +174,41 @@ if (FLS_BUILD_TESTING OR FLS_BUILD_CUDA OR FLS_ENABLE_FSST_TESTING_AND_BENCHMARK enable_testing() - # Silence clang-tidy warnings from googletest - set_target_properties(gtest PROPERTIES CXX_CLANG_TIDY "") - set_target_properties(gtest_main PROPERTIES CXX_CLANG_TIDY "") - set_target_properties(gmock PROPERTIES CXX_CLANG_TIDY "") - set_target_properties(gmock_main PROPERTIES CXX_CLANG_TIDY "") + # Silence clang-tidy warnings from googletest (we don't want to lint third-party code) + foreach (_t gtest gtest_main gmock gmock_main) + if (TARGET ${_t}) + set_target_properties(${_t} PROPERTIES CXX_CLANG_TIDY "") + endif () + endforeach () # On Windows, GoogleTest uses Microsoft-specific language extensions like `__try` - # that trigger Clang's `-Wlanguage-extension-token` warning. - # Since we build with `-Werror`, this causes the build to fail. - # This block selectively disables that warning (and suppresses all warnings with `-w`) - # only for GoogleTest targets, avoiding global suppression across the project. + # that trigger Clang's -Wlanguage-extension-token warning. Since we build with -Werror, + # selectively disable that warning (and suppress all warnings with -w) ONLY for GoogleTest. if (MSVC OR WIN32) - foreach (target gtest gtest_main gmock gmock_main) - if (TARGET ${target}) - target_compile_options(${target} PRIVATE -Wno-language-extension-token -w) + foreach (_t gtest gtest_main gmock gmock_main) + if (TARGET ${_t}) + # Skip alias targets (defensive; these names are real targets when fetched) + get_target_property(_aliased ${_t} ALIASED_TARGET) + if (NOT _aliased) + target_compile_options(${_t} PRIVATE -Wno-language-extension-token -w) + endif () + endif () + endforeach () + endif () + + # On Linux with Clang or GCC, libstdc++ deprecates get_temporary_buffer (used by stable_sort), + # which triggers -Wdeprecated-declarations; with -Werror that breaks the build. + # Relax ONLY this warning for GoogleTest targets. + if (UNIX AND NOT APPLE) + foreach (_t gtest gtest_main gmock gmock_main) + if (TARGET ${_t}) + get_target_property(_aliased ${_t} ALIASED_TARGET) + if (NOT _aliased) + target_compile_options(${_t} PRIVATE + $<$: + -Wno-error=deprecated-declarations + -Wno-deprecated-declarations>) + endif () endif () endforeach () endif () diff --git a/Makefile b/Makefile index 947db488..421c0336 100644 --- a/Makefile +++ b/Makefile @@ -3,23 +3,69 @@ # ──────────────────────────────────────────────────────── # Makefile # ──────────────────────────────────────────────────────── -include mk/preamble.mk -include mk/python.mk -include mk/format.mk -include mk/cpp.mk -include mk/rust.mk -include mk/data.mk -include mk/scripts.mk -include mk/embeddings.mk -include mk/flatbuffers.mk -include mk/quick_fuzz.mk -include mk/header_check.mk +SHELL := /bin/bash +VERBOSE ?= 0 +REPO_ROOT ?= $(CURDIR) +BUILD_DIR ?= build +CRATE_ROOT ?= $(REPO_ROOT)/rust +PREFIX ?= $(REPO_ROOT)/build/install +CARGO ?= $(shell command -v cargo 2>/dev/null) +CTEST ?= $(shell command -v ctest 2>/dev/null) +NUM_JOBS ?= $(shell nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 4) -.PHONY: all clean clang-format format-check rust-format-check format +# Test-specific config (separate build dir and build type) +TEST_BUILD_DIR ?= $(BUILD_DIR)/tests +TEST_BUILD_TYPE ?= Release -all: build-cpp build-rust +# Includes +include mk/preamble.mk # colors + root paths +include mk/python.mk # Python bindings +include mk/format.mk # Formatting helpers +include mk/cpp.mk # C++ build/test/install +include mk/rust.mk # Rust integration +include mk/data.mk # Data preparation +include mk/scripts.mk # General scripts +include mk/embeddings.mk # Embeddings + venv setup +include mk/flatbuffers.mk # FlatBuffers generation +include mk/quick_fuzz.mk # Fuzz testing +include mk/header_check.mk # Header checks -clean: - $(MAKE) clean-cpp clean-rust clean-python +.DEFAULT_GOAL := help +.PHONY: all build install test test-cpp help help-main \ + configure-cpp-tests build-cpp-tests + +# Build +all: build +build: build-cpp + +# Install +install: install-cpp + +# Format +.PHONY: format format: clang-format + @echo "✅ Formatting complete (clang-format)." + +# Help +help: help-main +help-main: + @echo "Targets:" + @echo " make build - Build C++ components" + @echo " make install - Install C++ artefacts" + @echo " make test [TEST_BUILD_TYPE=] - Configure+build+run tests in a separate tree (Debug by default)" + @echo " make format - Run clang-format on all source directories" + @echo " make bump - Bump fuzz seed version" + @echo " make verify - Verify fuzz seed bump correctness" + @echo " make check-header - Verify file headers" + @echo " make fix-header - Automatically fix headers" + @echo " make help - Show this message" + @echo + @echo "Variables (override via CLI):" + @echo " BUILD_DIR=$(BUILD_DIR)" + @echo " TEST_BUILD_DIR=$(TEST_BUILD_DIR)" + @echo " TEST_BUILD_TYPE=$(TEST_BUILD_TYPE)" + @echo " PREFIX=$(PREFIX)" + @echo " CRATE_ROOT=$(CRATE_ROOT)" + @echo " NUM_JOBS=$(NUM_JOBS)" + @echo " VERBOSE=$(VERBOSE)" diff --git a/mk/cpp.mk b/mk/cpp.mk index 7d3c382f..cae2cd24 100644 --- a/mk/cpp.mk +++ b/mk/cpp.mk @@ -49,3 +49,27 @@ clean-cpp: $(call echo_start,Cleaning C++ build…) rm -rf $(PROJECT_ROOT)/$(BUILD_DIR) $(call echo_done,C++ clean complete.) + +configure-cpp-tests: + $(call echo_start,Configuring C++ tests in $(TEST_BUILD_DIR) [$(TEST_BUILD_TYPE)]…) + @mkdir -p "$(TEST_BUILD_DIR)" + @cd "$(TEST_BUILD_DIR)" && cmake \ + -DCMAKE_INSTALL_PREFIX="$(PREFIX)" \ + -DCMAKE_BUILD_TYPE="$(TEST_BUILD_TYPE)" \ + -DFLS_BUILD_TESTING=ON \ + -DFLS_ENABLE_VERBOSE_OUTPUT=ON \ + "$(REPO_ROOT)" + $(call echo_done,Test configuration complete.) + +build-cpp-tests: configure-cpp-tests + $(call echo_start,Building C++ tests…) + @cmake --build "$(TEST_BUILD_DIR)" --parallel $(NUM_JOBS) + $(call echo_done,C++ tests built.) + +test-cpp: build-cpp-tests + $(call echo_start,Running C++ tests…) + @"$(CTEST)" --test-dir "$(TEST_BUILD_DIR)" --output-on-failure -j $(NUM_JOBS) + $(call echo_done,C++ tests complete.) + +# Keep "test" as the common entrypoint +test: test-cpp \ No newline at end of file diff --git a/mk/embeddings.mk b/mk/embeddings.mk index ca4966c9..32e266b6 100644 --- a/mk/embeddings.mk +++ b/mk/embeddings.mk @@ -3,13 +3,12 @@ # ──────────────────────────────────────────────────────── # mk/embeddings.mk # ──────────────────────────────────────────────────────── -# mk/embeddings.mk — Generate sentence embeddings # ----------------------------------------------------------- # Targets: -# make install – create .venv & install deps -# make generate – run generate_embedding.py -# make clean – delete __pycache__ -# make venv-clean – remove .venv entirely +# make install-embeddings-python – create .venv & install deps +# make generate-embeddings – run generate_embedding.py +# make clean-embeddings – delete __pycache__ +# make venv-clean – remove .venv entirely # ----------------------------------------------------------- include mk/venv.mk @@ -26,17 +25,17 @@ else endif .DEFAULT_GOAL := help -.PHONY: help install generate clean-embeddings venv-clean +.PHONY: help install-embeddings-python generate-embeddings clean-embeddings venv-clean help: @echo "Targets:" - @echo " make install – create .venv & install deps" - @echo " make generate – run generate_embedding.py" - @echo " make clean – delete __pycache__" - @echo " make venv-clean – remove .venv" + @echo " make install-embeddings-python – create .venv & install deps" + @echo " make generate-embeddings – run generate_embedding.py" + @echo " make clean-embeddings – delete __pycache__" + @echo " make venv-clean – remove .venv" # 1️⃣ Install deps (and auto-repair if venv was built with Python 3.13) -install: venv +install-embeddings-python: venv @if [ -f "$(VENV_DIR)/pyvenv.cfg" ] && \ grep -qE '^version = 3\.13' "$(VENV_DIR)/pyvenv.cfg"; then \ echo "⚠️ .venv uses Python 3.13 — recreating with ‘python’ on PATH"; \ @@ -55,11 +54,11 @@ install: venv --extra-index-url https://download.pytorch.org/whl/cpu # 2️⃣ Generate embeddings -generate-embeddings: install +generate-embeddings: install-embeddings-python @echo "Running generate_embedding.py with $$($(VENV_PY) --version) …" "$(VENV_PY)" "$(SCRIPT)" -# 3️⃣ House‑keeping helpers +# 3️⃣ House-keeping helpers clean-embeddings: find . -type d -name "__pycache__" -exec rm -rf {} + diff --git a/mk/preamble.mk b/mk/preamble.mk index d809a4ca..1d11f8ba 100644 --- a/mk/preamble.mk +++ b/mk/preamble.mk @@ -8,48 +8,57 @@ PREAMBLE_MK_INCLUDED := yes # mk/preamble.mk — Helpers for colored echo + root paths +# ── Coloring (portable; disable with COLOR=0) ─────────── +COLOR ?= 1 +ifeq ($(COLOR),1) + _Y := $(shell tput setaf 3 2>/dev/null || printf '\033[0;33m') + _G := $(shell tput setaf 2 2>/dev/null || printf '\033[0;32m') + _R := $(shell tput sgr0 2>/dev/null || printf '\033[0m') +else + _Y := + _G := + _R := +endif + define echo_done - @echo "\033[0;32m$(1)\033[0m" + @printf '%s%s%s\n' '$(_G)' '$(1)' '$(_R)' endef define echo_start - @echo "\033[0;33m$(1)\033[0m" + @printf '%s%s%s\n' '$(_Y)' '$(1)' '$(_R)' endef -# ── Root paths ───────────────────────────────────────────────────── - -# if that directory’s name is “mk”, repo-root is its parent; else it is itself -ifeq ($(notdir $(MKFILE_PATH)),mk) -REPO_ROOT := $(abspath $(MKFILE_PATH)/..) +# ── Root paths ────────────────────────────────────────── +MKFILE_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))) +ifeq ($(notdir $(MKFILE_DIR)),mk) + REPO_ROOT ?= $(abspath $(MKFILE_DIR)/..) else -REPO_ROOT := $(MKFILE_PATH) + REPO_ROOT ?= $(MKFILE_DIR) endif -# CRATE_ROOT always under repo -CRATE_ROOT := $(REPO_ROOT)/rust - -# ── Parallelism ──────────────────────────────────────────────────── -NUM_JOBS := $(shell \ - if command -v nproc >/dev/null 2>&1; then \ - nproc --all; \ - elif command -v sysctl >/dev/null 2>&1; then \ - sysctl -n hw.logicalcpu; \ - else \ - echo $${NUMBER_OF_PROCESSORS:-1}; \ - fi) +CRATE_ROOT ?= $(REPO_ROOT)/rust -# ── Exports & Info ───────────────────────────────────────────────── +# ── Parallelism ───────────────────────────────────────── +NUM_JOBS ?= $(shell \ + if command -v nproc >/dev/null 2>&1; then \ + nproc --all; \ + elif command -v sysctl >/dev/null 2>&1; then \ + sysctl -n hw.logicalcpu; \ + else \ + echo $${NUMBER_OF_PROCESSORS:-1}; \ + fi) +# ── Exports & Info ────────────────────────────────────── export REPO_ROOT CRATE_ROOT NUM_JOBS -# only print during normal runs -ifneq ($(MAKECMDGOALS),detect-cpu) +# only print when VERBOSE=1 +ifeq ($(VERBOSE),1) $(info REPO_ROOT: $(REPO_ROOT)) $(info CRATE_ROOT: $(CRATE_ROOT)) $(info NUM_JOBS: $(NUM_JOBS)) endif -# ── CI helper ───────────────────────────────────────────────────── +# ── CI helper ─────────────────────────────────────────── .PHONY: detect-cpu detect-cpu: @echo "BUILD_THREADS=$(NUM_JOBS)" diff --git a/mk/quick_fuzz.mk b/mk/quick_fuzz.mk index 1ba5cfaa..2b6a205d 100644 --- a/mk/quick_fuzz.mk +++ b/mk/quick_fuzz.mk @@ -3,7 +3,6 @@ # ──────────────────────────────────────────────────────── # mk/quick_fuzz.mk # ──────────────────────────────────────────────────────── -# mk/quick_fuzz.mk # ────────────────────────────────────────────────────────── # Bump & verify fuzz seed helper targets diff --git a/test/src/quick_fuzz_tests/fuzz_config.json b/test/src/quick_fuzz_tests/fuzz_config.json index 43850992..40893625 100644 --- a/test/src/quick_fuzz_tests/fuzz_config.json +++ b/test/src/quick_fuzz_tests/fuzz_config.json @@ -1,6 +1,6 @@ { "num_cases": 10, - "base_seed": 10, + "base_seed": 11, "delimiter": "|", "min_cols": 1, "max_cols": 2,