Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 40 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
os: [ubuntu-latest, macos-latest, windows-latest]
build_type: [Debug, Release]

steps:
Expand All @@ -38,6 +38,14 @@ jobs:
brew update
brew install cmake ninja

- name: Install build tools (Windows)
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1

- name: Install Ninja (Windows)
if: runner.os == 'Windows'
run: choco install ninja --no-progress -y

- name: Report toolchain versions
run: |
cmake --version
Expand All @@ -58,28 +66,54 @@ jobs:
- name: Build
run: cmake --build build --config ${{ matrix.build_type }} --parallel

- name: List built targets
- name: List built targets (POSIX)
if: runner.os != 'Windows'
run: ls -la build

- name: List built targets (Windows)
if: runner.os == 'Windows'
run: dir build

- name: Run tests (CTest)
working-directory: build
run: ctest --output-on-failure --build-config ${{ matrix.build_type }}

- name: Run tests (verbose)
- name: Run tests (verbose, POSIX)
if: runner.os != 'Windows'
working-directory: build
run: ./logosdb-test --test-suite-exclude=stress

- name: List test suites
- name: Run tests (verbose, Windows)
if: runner.os == 'Windows'
working-directory: build
run: .\logosdb-test.exe --test-suite-exclude=stress

- name: List test suites (POSIX)
if: runner.os != 'Windows'
working-directory: build
run: ./logosdb-test --list-test-suites

- name: Smoke-test CLI
- name: List test suites (Windows)
if: runner.os == 'Windows'
working-directory: build
run: .\logosdb-test.exe --list-test-suites

- name: Smoke-test CLI (POSIX)
if: runner.os != 'Windows'
working-directory: build
run: |
rm -rf /tmp/ci-smoke-db
./logosdb-cli info /tmp/ci-smoke-db --dim 16

# libFuzzer smoke (short run)
- name: Smoke-test CLI (Windows)
if: runner.os == 'Windows'
working-directory: build
run: |
$smoke = "$env:RUNNER_TEMP\ci-smoke-db"
if (Test-Path $smoke) { Remove-Item -Recurse -Force $smoke }
.\logosdb-cli.exe info $smoke --dim 16

# libFuzzer smoke (short run) — Linux + Clang only
fuzz-smoke-jsonl:
name: Fuzz smoke (JSONL parse harness)
runs-on: ubuntu-latest
Expand Down
24 changes: 23 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
cmake_minimum_required(VERSION 3.15)
project(logosdb VERSION 0.9.0 LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# MSVC-specific compile flags
if(MSVC)
add_compile_options(
/utf-8 # Source and execution charset: UTF-8
/EHsc # C++ exception handling
/W3 # Warning level 3
/wd4068 # Suppress unknown pragma warnings (for clang pragmas in vendored headers)
)
# Suppress deprecation warnings for POSIX-named functions (_open, _write, etc.)
add_compile_definitions(_CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_DEPRECATE)
endif()

option(LOGOSDB_BUILD_TOOLS "Build CLI and benchmark tools" ON)
option(LOGOSDB_BUILD_TESTS "Build unit tests" ON)
option(LOGOSDB_BUILD_PYTHON "Build Python bindings (pybind11)" OFF)
Expand Down Expand Up @@ -43,6 +55,11 @@ endif()
if(LOGOSDB_BUILD_TOOLS)
add_executable(logosdb-cli tools/logosdb-cli.cpp)
target_link_libraries(logosdb-cli PRIVATE logosdb)
# MSVC's format-string checker cannot parse "%" PRIu64 macro concatenation
# and emits false-positive C4474/C4477. Suppress only for this target.
if(MSVC)
target_compile_options(logosdb-cli PRIVATE /wd4474 /wd4477)
endif()

add_executable(logosdb-bench tools/logosdb-bench.cpp)
target_link_libraries(logosdb-bench PRIVATE logosdb)
Expand All @@ -68,6 +85,11 @@ if(LOGOSDB_BUILD_FUZZ)
WARNING
"LOGOSDB_BUILD_FUZZ skipped: Apple Clang does not ship libFuzzer here. Use Linux + Clang (see CI)."
)
elseif(WIN32)
message(
WARNING
"LOGOSDB_BUILD_FUZZ skipped: libFuzzer is not available on Windows. Use Linux + Clang (see CI)."
)
else()
add_executable(logosdb-fuzz-jsonl tools/fuzz_jsonl_metadata.cpp)
target_link_libraries(logosdb-fuzz-jsonl PRIVATE nlohmann_json)
Expand Down
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,31 @@ cd logosdb

# Building

This project supports [CMake](https://cmake.org/) out of the box.
This project supports [CMake](https://cmake.org/) on Linux, macOS, and Windows.

Quick start:
**Linux / macOS:**

```bash
mkdir -p build && cd build
cmake -DCMAKE_BUILD_TYPE=Release .. && cmake --build .
```

**Windows (MSVC, Visual Studio 2019+):**

Open a *Developer Command Prompt for VS* (or use the `ilammy/msvc-dev-cmd` action in CI), then:

```cmd
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release
cmake --build build --parallel
```

Alternatively, use the Visual Studio generator (binaries land in `build\Release\`):

```cmd
cmake -S . -B build
cmake --build build --config Release
```

This builds:

| Target | Description |
Expand Down
8 changes: 8 additions & 0 deletions src/hnsw_index.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
#include "hnsw_index.h"

// Suppress MSVC narrowing/conversion warnings from vendored hnswlib headers
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4244 4267)
#endif
#include <hnswlib/hnswlib/hnswlib.h>
#ifdef _MSC_VER
#pragma warning(pop)
#endif

#include <cstring>
#include <fstream>
Expand Down
13 changes: 9 additions & 4 deletions src/metadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#ifdef _WIN32
#include <io.h>
#include <share.h>
#else
#include <unistd.h>
#endif
Expand All @@ -32,11 +33,15 @@ bool MetadataStore::open(const std::string& path, std::string& err)
path_ = path;

#ifdef _WIN32
int flags = O_RDWR | O_CREAT | O_APPEND | O_BINARY;
{
int fd = -1;
_sopen_s(&fd, path.c_str(), O_RDWR | O_CREAT | O_APPEND | O_BINARY, _SH_DENYNO,
_S_IREAD | _S_IWRITE);
fd_ = fd;
}
#else
int flags = O_RDWR | O_CREAT | O_APPEND;
fd_ = ::open(path.c_str(), O_RDWR | O_CREAT | O_APPEND, 0644);
#endif
fd_ = ::open(path.c_str(), flags, 0644);
if (fd_ < 0)
{
err = std::string("open meta: ") + strerror(errno);
Expand All @@ -58,7 +63,7 @@ bool MetadataStore::open(const std::string& path, std::string& err)
{
j = json::parse(line);
}
catch (const json::exception& e)
catch (const json::exception&)
{
// Invalid JSON line - skip but don't fail
continue;
Expand Down
Loading
Loading