Skip to content
Merged
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
7 changes: 7 additions & 0 deletions .bcr/metadata.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"homepage": "https://github.com/jhurliman/kdtreepp",
"maintainers": [{"github": "jhurliman", "github_user_id": 195374}],
"repository": ["github:jhurliman/kdtreepp"],
"versions": [],
"yanked_versions": {}
}
11 changes: 11 additions & 0 deletions .bcr/presubmit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
matrix:
platform: [ubuntu2404, macos_arm64]
bazel: ["9.*"]
tasks:
verify_targets:
name: Verify library and regression tests
platform: ${{ platform }}
bazel: ${{ bazel }}
build_flags: ["--cxxopt=-std=c++17"]
build_targets: ["@kdtreepp//:kdtreepp"]
test_targets: ["@kdtreepp//:regression_test"]
19 changes: 19 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
node-version: 24
- run: npm install --global @bazel/bazelisk@1.28.1
- run: bazelisk test //:regression_test
- run: BAZEL=bazelisk python3 tools/test_bcr.py
- run: bazelisk test //:consumer --cxxopt=-std=c++17
working-directory: examples/bazel-consumer
cmake:
Expand All @@ -22,3 +23,21 @@ jobs:
- run: cmake -S . -B build -DKDTREEPP_BUILD_TESTS=ON -DCMAKE_CXX_FLAGS=-fsanitize=address,undefined -DCMAKE_INSTALL_PREFIX="$PWD/install"
- run: cmake --build build && ctest --test-dir build --output-on-failure && cmake --install build
- run: cmake -S examples/cmake-consumer -B consumer-build -DCMAKE_PREFIX_PATH="$PWD/install" && cmake --build consumer-build && ./consumer-build/consumer

conan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- run: pip install conan==2.32.0
- run: conan profile detect && conan create . --build=missing -s compiler.cppstd=17
make:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: sudo apt-get update && sudo apt-get install -y libeigen3-dev libbenchmark-dev clang llvm
- run: make test
- run: make bench BENCHMARK_FILTER='BM_Points3dConstruction/100$'
- run: CXX=clang++ make coverage
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,9 @@ bazel-testlogs
/bazel-kdtreepp
/examples/bazel-consumer/bazel-bazel-consumer
/build/

/test_package/build/
/test_package/CMakeUserPresets.json

/build-coverage/
__pycache__/
72 changes: 0 additions & 72 deletions .travis.yml

This file was deleted.

12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# Changelog

## 2.0.0 (release candidate)

- Provide a Bzlmod library target with transitive Eigen and independent consumer checks.
- Export CMake package targets without automatically invoking Conan or setting global compiler flags.
- Replace the nonfunctional Conan 1 recipe with a tested Conan 2 header-only package and consumer.
- Restore Make test, benchmark and coverage commands; update Google Benchmark APIs and remove obsolete Travis configuration.
- Prepare checksum-based BCR metadata from the actual release archive and test consumption through a generated registry without local overrides.
- Keep version metadata synchronized across the C++ header, CMake, Conan and Bazel modules.

The C++ API is unchanged; the build and package-manager migration motivates the major version. Publication/tagging and registry submission follow review and merge.
# 01/27/2021

* Initial release
9 changes: 7 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
cmake_minimum_required(VERSION 3.16)
project(kdtreepp VERSION 1.0.0 LANGUAGES CXX)
project(kdtreepp VERSION 2.0.0 LANGUAGES CXX)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
find_package(Eigen3 REQUIRED NO_MODULE)
Expand Down Expand Up @@ -39,7 +40,11 @@ configure_package_config_file(cmake/kdtreeppConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/kdtreeppConfig.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/kdtreepp)
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/kdtreeppConfigVersion.cmake
VERSION ${PROJECT_VERSION} COMPATIBILITY SameMajorVersion)
VERSION ${PROJECT_VERSION} COMPATIBILITY SameMajorVersion ARCH_INDEPENDENT)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/kdtreeppConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/kdtreeppConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/kdtreepp)

if(KDTREEPP_BUILD_TESTS)
add_test(NAME architecture-independent-version COMMAND ${CMAKE_COMMAND} -DVERSION_FILE=${CMAKE_CURRENT_BINARY_DIR}/kdtreeppConfigVersion.cmake -P ${CMAKE_CURRENT_SOURCE_DIR}/test/architecture-version.cmake)
endif()
2 changes: 1 addition & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module(name = "kdtreepp", version = "1.0.0")
module(name = "kdtreepp", version = "2.0.0")
bazel_dep(name = "rules_cc", version = "0.2.22")
bazel_dep(name = "eigen", version = "3.4.1.bcr.1")
46 changes: 18 additions & 28 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,35 +1,25 @@

# Whether to turn compiler warnings into errors
export WERROR ?= true
export BUILD_DIR ?= build

default: release

BUILD_DIR ?= build
BENCHMARK_FILTER ?= .
.PHONY: release debug test bench clean format coverage tidy
release:
mkdir -p ./$(BUILD_DIR) && cd ./$(BUILD_DIR) && cmake ../ -DCMAKE_BUILD_TYPE=Release -DWERROR=$(WERROR) && VERBOSE=1 cmake --build .

cmake -S . -B $(BUILD_DIR) -DCMAKE_BUILD_TYPE=Release -DKDTREEPP_BUILD_TESTS=ON
cmake --build $(BUILD_DIR)
debug:
mkdir -p ./$(BUILD_DIR) && cd ./$(BUILD_DIR) && cmake ../ -DCMAKE_BUILD_TYPE=Debug -DWERROR=$(WERROR) && VERBOSE=1 cmake --build .

test:
@if [ -f ./$(BUILD_DIR)/bin/unit-tests ]; then ./$(BUILD_DIR)/bin/unit-tests; else echo "Please run 'make release' or 'make debug' first" && exit 1; fi

cmake -S . -B $(BUILD_DIR) -DCMAKE_BUILD_TYPE=Debug -DKDTREEPP_BUILD_TESTS=ON
cmake --build $(BUILD_DIR)
test: release
ctest --test-dir $(BUILD_DIR) --output-on-failure
bench:
@if [ -f ./$(BUILD_DIR)/bin/bench-tests ]; then ./$(BUILD_DIR)/bin/bench-tests; else echo "Please run 'make release' or 'make debug' first" && exit 1; fi

tidy:
./scripts/clang-tidy.sh

coverage:
./scripts/coverage.sh

cmake -S . -B $(BUILD_DIR) -DCMAKE_BUILD_TYPE=Release -DKDTREEPP_BUILD_BENCHMARKS=ON
cmake --build $(BUILD_DIR) --target bench-tests
$(BUILD_DIR)/bench-tests --benchmark_filter="$(BENCHMARK_FILTER)" --benchmark_min_time=0.01s
clean:
rm -rf ./$(BUILD_DIR)
# remove remains from running 'make coverage'
rm -f *.profraw
rm -f *.profdata

cmake -E rm -rf $(BUILD_DIR)
format:
./scripts/format.sh

.PHONY: test bench
coverage:
BUILD_DIR="$(BUILD_DIR)-coverage" ./scripts/coverage.sh

tidy: debug
BUILD_DIR="$(BUILD_DIR)" ./scripts/clang-tidy.sh
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Requires C++17 and Eigen. The library is header-only; tests and benchmarks are o
Until a release is registered in the Bazel Central Registry, use a checkout override:

```starlark
bazel_dep(name = "kdtreepp", version = "1.0.0")
bazel_dep(name = "kdtreepp", version = "2.0.0")
local_path_override(module_name = "kdtreepp", path = "third_party/kdtreepp")
```

Expand All @@ -31,7 +31,7 @@ find_package(kdtreepp CONFIG REQUIRED)
target_link_libraries(my_application PRIVATE kdtreepp::kdtreepp)
```

CMake no longer invokes Conan automatically or changes global compiler flags. Existing Conan 1 recipes remain legacy and have not been validated with this integration; supply Eigen through a package manager or installed CMake package.
CMake no longer invokes Conan automatically or changes global compiler flags. The Conan 2 recipe declares Eigen transitively and is validated with `conan create . --build=missing -s compiler.cppstd=17`. Conan 1 is no longer supported.

## Usage

Expand Down Expand Up @@ -104,3 +104,7 @@ For sanitizer checks, configure with `-DCMAKE_CXX_FLAGS=-fsanitize=address,undef
kdtreepp is licensed under [MIT](https://opensource.org/licenses/MIT).

Made with [hpp-skel](https://github.com/mapbox/hpp-skel).

## Release preparation

See [RELEASING.md](RELEASING.md) for the tested Conan consumer, restored Make commands and BCR archive/registry validation and submission procedure. Version 2.0.0 is prepared in this branch; it is not yet published or registered.
29 changes: 29 additions & 0 deletions RELEASING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Release 2.0.0

This branch prepares a major release because integration now uses Bzlmod, exported CMake targets and Conan 2 instead of automatically invoking Conan 1. The C++17 library API is unchanged.

## Verify before tagging

- `bazel test //:regression_test`, then run the renamed-repository consumer in `examples/bazel-consumer`.
- `make test`; `make bench` with Google Benchmark installed; `make coverage` with Clang and matching LLVM tools.
- `conan profile detect` if no profile exists, then `conan create . --build=missing -s compiler.cppstd=17`.
- `BAZEL=bazel python3 tools/test_bcr.py`. This archives the committed HEAD and tests an independent Bazel consumer through a temporary registry and checksum-verified archive, without a source override. Commit all intended release changes first.

CI performs these checks on the reviewed commit. Merging the stacked PRs and publishing/tagging are separate maintainer actions; test/pack commands do not publish anything.

## Bazel Central Registry submission

After the reviewed commit is merged and tagged `v2.0.0`, download the actual GitHub tag archive:

```sh
curl -fL https://github.com/jhurliman/kdtreepp/archive/refs/tags/v2.0.0.tar.gz -o kdtreepp-2.0.0.tar.gz
python3 tools/prepare_bcr.py kdtreepp-2.0.0.tar.gz --output /path/to/bazel-central-registry
```

The generator copies the archive's MODULE.bazel, computes its SHA-256 integrity, and prepares `modules/kdtreepp/metadata.json`, `2.0.0/source.json` and `presubmit.yml`. Use the downloaded release archive, not a locally recompressed copy: integrity must match the bytes served at the public URL. Review the files and run the BCR validation tools from that checkout before opening the registry PR, following [BCR contribution guidance](https://github.com/bazelbuild/bazel-central-registry/blob/main/docs/README.md).

There is no pre-existing registry entry in this release preparation. Until the BCR PR is merged, use the documented source override. After registration, a monorepo can use `bazel_dep(name = "kdtreepp", version = "2.0.0")` and depend on `@kdtreepp//:kdtreepp`.

## Conan 2

The recipe packages headers and the license without cloning another revision or downloading build-time test tools. Eigen is a declared transitive header dependency, and `test_package` compiles/runs a real consumer. ConanCenter submission or upload to a remote is an explicit release action; `conan create` only populates the local cache.
13 changes: 7 additions & 6 deletions bench/run.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ using AlignedBox3 = Eigen::AlignedBox3d;

static void BM_Points3dConstruction(benchmark::State& state) {
std::vector<Vector3, Eigen::aligned_allocator<Vector3>> points;
std::mt19937_64 randGen{size_t(state.thread_index)};
std::mt19937_64 randGen{size_t(state.thread_index())};
std::uniform_real_distribution<double> dist{-1000.0, 1000.0};

// Make random points
Expand All @@ -20,7 +20,7 @@ static void BM_Points3dConstruction(benchmark::State& state) {
}

while (state.KeepRunning()) {
const auto node = kdtreepp::MakeEigenKdTreeNode<double, 3>(
auto node = kdtreepp::MakeEigenKdTreeNode<double, 3>(
points.begin(), points.end(), [](const Vector3& p) { return p; },
[](const Vector3& p) { return p; });
benchmark::DoNotOptimize(node);
Expand All @@ -30,7 +30,7 @@ static void BM_Points3dConstruction(benchmark::State& state) {

static void BM_Points3dClosest(benchmark::State& state) {
std::vector<Vector3, Eigen::aligned_allocator<Vector3>> points;
std::mt19937_64 randGen{size_t(state.thread_index)};
std::mt19937_64 randGen{size_t(state.thread_index())};
std::uniform_real_distribution<double> dist{-1000.0, 1000.0};

// Make random points
Expand Down Expand Up @@ -80,7 +80,8 @@ int main(int argc, char* argv[]) {
->Arg(1000000);
benchmark::RegisterBenchmark("BM_Points3dClosest", BM_Points3dClosest)->Args({100000, 10000});
benchmark::Initialize(&argc, argv);
benchmark::RunSpecifiedBenchmarks();

return 0;
if (benchmark::ReportUnrecognizedArguments(argc, argv)) return 1;
const auto matched = benchmark::RunSpecifiedBenchmarks();
benchmark::Shutdown();
return matched == 0 ? 1 : 0;
}
43 changes: 20 additions & 23 deletions conanfile.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,29 @@
from conans import ConanFile, CMake

import os
from conan import ConanFile
from conan.tools.files import copy

class KdTreePpConan(ConanFile):
name = "kdtreepp"
version = "1.0.0"
version = "2.0.0"
package_type = "header-library"
license = "MIT"
url = "https://github.com/jhurliman/kdtreepp"
homepage = "https://github.com/jhurliman/kdtreepp"
description = "A C++ k-d tree implementation"
license = ("MIT")
topics = ("data-structures", "spatial", "eigen")
settings = "os", "compiler", "build_type", "arch"
requires = "eigen/3.3.9"
build_requires = "catch2/2.13.4", "benchmark/1.5.2"
generators = "cmake"

def source(self):
self.run("git clone https://github.com/jhurliman/kdtreepp.git")
homepage = url
description = "A header-only C++17 k-d tree for Eigen"
exports_sources = "include/*", "LICENSE"
no_copy_source = True

def build(self):
cmake = CMake(self)
cmake.configure(source_folder="kdtreepp")
cmake.build()
def requirements(self):
self.requires("eigen/3.4.0", transitive_headers=True)

def package(self):
cmake = CMake(self)
cmake.configure(source_folder=self._source_subfolder)
cmake.install()
copy(self, "*.hpp", src=os.path.join(self.source_folder, "include"),
dst=os.path.join(self.package_folder, "include"))
copy(self, "LICENSE", src=self.source_folder,
dst=os.path.join(self.package_folder, "licenses"))

def package_info(self):
self.cpp_info.names["cmake_find_package"] = "kdtreepp"
self.cpp_info.names["pkg_config"] = "kdtreepp"
self.cpp_info.bindirs = []
self.cpp_info.libdirs = []
self.cpp_info.set_property("cmake_file_name", "kdtreepp")
self.cpp_info.set_property("cmake_target_name", "kdtreepp::kdtreepp")
2 changes: 1 addition & 1 deletion examples/bazel-consumer/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module(name = "consumer")
bazel_dep(name = "rules_cc", version = "0.2.22")
bazel_dep(name = "kdtreepp", version = "1.0.0", repo_name = "spatial")
bazel_dep(name = "kdtreepp", version = "2.0.0", repo_name = "spatial")
local_path_override(module_name = "kdtreepp", path = "../..")
4 changes: 2 additions & 2 deletions include/kdtreepp/version.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

/// The major version number
#define KDTREEPP_VERSION_MAJOR 1
#define KDTREEPP_VERSION_MAJOR 2

/// The minor version number
#define KDTREEPP_VERSION_MINOR 0
Expand All @@ -14,4 +14,4 @@
(KDTREEPP_VERSION_MAJOR * 10000 + KDTREEPP_VERSION_MINOR * 100 + KDTREEPP_VERSION_PATCH)

/// Version number as string
#define KDTREEPP_VERSION_STRING "1.0.0"
#define KDTREEPP_VERSION_STRING "2.0.0"
Loading
Loading