Skip to content

Commit

Permalink
#53 improve build scripts (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
tzaeschke authored Aug 31, 2022
1 parent 2090229 commit 2c9174f
Show file tree
Hide file tree
Showing 43 changed files with 427 additions and 1,102 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/bazel.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Bazel build

on: [push]
on: [ push ]

jobs:
build:
Expand All @@ -24,6 +24,14 @@ jobs:
path: "~/.cache/bazel"
key: bazel

- name: Clang format
shell: bash
run: ./ci/linting/clang-format.sh

- name: Bazel format
shell: bash
run: ./ci/linting/buildifier.sh

- name: Build
shell: bash
run: bazel build ...
Expand Down
34 changes: 17 additions & 17 deletions .github/workflows/cmake-windows.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: CMake Windows build

on: [push]
on: [ push ]

env:
BUILD_TYPE: Release
Expand All @@ -10,24 +10,24 @@ jobs:
runs-on: windows-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v2

- uses: ilammy/msvc-dev-cmd@v1
- uses: ilammy/msvc-dev-cmd@v1

- name: Create Build Environment
run: cmake -E make_directory ${{github.workspace}}\out
- name: Create Build Environment
run: cmake -E make_directory ${{github.workspace}}\out

- name: Configure CMake
working-directory: ${{github.workspace}}\out
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -S ${{github.workspace}} -B ${{github.workspace}}\out -DPHTREE_BUILD_EXAMPLES=ON -DPHTREE_BUILD_TESTS=ON
- name: Configure CMake
working-directory: ${{github.workspace}}\out
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -S ${{github.workspace}} -B ${{github.workspace}}\out -DPHTREE_BUILD_EXAMPLES=ON -DPHTREE_BUILD_TESTS=ON

- name: Build
working-directory: ${{github.workspace}}\out
# Execute the build. You can specify a specific target with "--target <NAME>"
run: cmake --build . --config ${env:BUILD_TYPE}
- name: Build
working-directory: ${{github.workspace}}\out
# Execute the build. You can specify a specific target with "--target <NAME>"
run: cmake --build . --config ${env:BUILD_TYPE}

- name: Test
working-directory: ${{github.workspace}}\out
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest -C ${env:BUILD_TYPE}
- name: Test
working-directory: ${{github.workspace}}\out
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest -C ${env:BUILD_TYPE}
68 changes: 34 additions & 34 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: CMake build

on: [push]
on: [ push ]

env:
BUILD_TYPE: Release
Expand All @@ -10,36 +10,36 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Create Build Environment
run: cmake -E make_directory ${{github.workspace}}/build

- name: Configure CMake
# Use a bash shell so we can use the same syntax for environment variable
# access regardless of the host operating system
shell: bash
working-directory: ${{github.workspace}}/build
# Note the current convention is to use the -S and -B options here to specify source
# and build directories, but this is only available with CMake 3.13 and higher.
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DPHTREE_BUILD_ALL=ON

- name: Build
working-directory: ${{github.workspace}}/build
shell: bash
# Execute the build. You can specify a specific target with "--target <NAME>"
run: cmake --build . --config $BUILD_TYPE

- name: Test
working-directory: ${{github.workspace}}/build
shell: bash
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
# TODO Currently tests are run via bazel only.
run: ctest -C $BUILD_TYPE

- name: Example
working-directory: ${{github.workspace}}/build
shell: bash
run: examples/Example
- uses: actions/checkout@v2

- name: Create Build Environment
run: cmake -E make_directory ${{github.workspace}}/build

- name: Configure CMake
# Use a bash shell so we can use the same syntax for environment variable
# access regardless of the host operating system
shell: bash
working-directory: ${{github.workspace}}/build
# Note the current convention is to use the -S and -B options here to specify source
# and build directories, but this is only available with CMake 3.13 and higher.
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DPHTREE_BUILD_ALL=ON

- name: Build
working-directory: ${{github.workspace}}/build
shell: bash
# Execute the build. You can specify a specific target with "--target <NAME>"
run: cmake --build . --config $BUILD_TYPE

- name: Test
working-directory: ${{github.workspace}}/build
shell: bash
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
# TODO Currently tests are run via bazel only.
run: ctest -C $BUILD_TYPE

- name: Example
working-directory: ${{github.workspace}}/build
shell: bash
run: examples/Example
42 changes: 42 additions & 0 deletions .github/workflows/codcecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Upload CodeCov Report
on: [ push ]
jobs:
run:
runs-on: windows-latest
name: Build, Test , Upload Code Coverage Report
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: ‘2’
id: checkout_code
- name: Setup MSBuild and add to PATH
uses: microsoft/setup-msbuild@v1.0.2
id: setup_msbuild

- name: Generate Solution
run: cmake -G "Visual Studio 17 2022" -A x64 . -DPHTREE_CODE_COVERAGE=ON -DCMAKE_BUILD_TYPE=Debug

- name: Run MSBuild
id: run_msbuild
run: msbuild /p:Configuration=Debug /p:Platform=x64 /p:gtest_force_shared_crt=on phtree.sln
- name: Setup VSTest and add to PATH
uses: darenm/Setup-VSTest@v1
id: setup_vstest

- name: Setup OpenCppCoverage and add to PATH
id: setup_opencppcoverage
run: |
choco install OpenCppCoverage -y
echo "C:\Program Files\OpenCppCoverage" >> $env:GITHUB_PATH
- name: Generate Report
id: generate_test_report
shell: cmd
run: OpenCppCoverage.exe --modules phtree --export_type cobertura:phtree.xml -- "vstest.console.exe" test\Debug\all_tests.exe
- name: Upload Report to Codecov
uses: codecov/codecov-action@v3
with:
files: ./phtree.xml
fail_ci_if_error: true
functionalities: fix
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ compile_commands.json
perf.data*
build
out
cygwin
CMakeSettings.json

/cmake-build-debug/
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]
### Added
- Nothing.
- Added build features:
- linting for C++ and bazel files.
- Added CI status badges.
- Added test coverage
[#53](https://github.com/tzaeschke/phtree-cpp/issues/53)

### Changed
- Nothing.
- Cleaned up build scripts. [#53](https://github.com/tzaeschke/phtree-cpp/issues/53)

### Removed
- Nothing.
Expand Down
11 changes: 10 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose Release or Debug" FORCE)
endif ()


# ---------------------------------------------------------------------------------------
# Build options
# ---------------------------------------------------------------------------------------
Expand All @@ -28,10 +29,15 @@ option(PHTREE_BUILD_EXAMPLES "Build examples" OFF)
# testing options
option(PHTREE_BUILD_TESTS "Build tests" OFF)
#option(PHTREE_BUILD_TESTS_HO "Build tests using the header only version" OFF)
option(PHTREE_CODE_COVERAGE "Collect coverage from test library" OFF)
if (PHTREE_CODE_COVERAGE)
set(PHTREE_BUILD_TESTS ON)
endif ()

# bench options
option(PHTREE_BUILD_BENCHMARKS "Build benchmarks (Requires https://github.com/google/benchmark.git to be installed)" OFF)


# ---------------------------------------------------------------------------------------
# Compiler config
# ---------------------------------------------------------------------------------------
Expand Down Expand Up @@ -78,6 +84,9 @@ else ()
else ()
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -mavx")
endif ()
if (PHTREE_CODE_COVERAGE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -Wall -Werror -Wa,-mbig-obj")
endif ()
endif ()

# ---------------------------------------------------------------------------------------
Expand All @@ -90,7 +99,7 @@ if (PHTREE_BUILD_EXAMPLES OR PHTREE_BUILD_ALL)
add_subdirectory(examples)
endif ()

if (!MSVC AND (PHTREE_BUILD_BENCHMARKS OR PHTREE_BUILD_ALL))
if ((PHTREE_BUILD_BENCHMARKS OR PHTREE_BUILD_ALL) AND NOT MSVC)
message(STATUS "Generating benchmarks")
add_subdirectory(benchmark)
endif ()
Expand Down
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
**This is a fork of [Improbable's PH-tree](https://github.com/improbable-eng/phtree-cpp)**.
**This is a fork of [Improbable's (currently unmaintained) PH-tree](https://github.com/improbable-eng/phtree-cpp)**.

Multi-dimensional / spatial index with very fast insert/erase/relocate operations and scalability with large datasets.
This library is C++ / header only.

![Bazel Linux build](https://github.com/tzaeschke/phtree-cpp/actions/workflows/bazel.yml/badge.svg)
![CMake Linux build](https://github.com/tzaeschke/phtree-cpp/actions/workflows/cmake.yml/badge.svg)
![CMake Windows build](https://github.com/tzaeschke/phtree-cpp/actions/workflows/cmake-windows.yml/badge.svg)
[![codecov](https://codecov.io/gh/tzaeschke/phtree-cpp/branch/master/graph/badge.svg?token=V5XVRQG754)](https://codecov.io/gh/tzaeschke/phtree-cpp)
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)

# PH-Tree C++

Expand Down
14 changes: 1 addition & 13 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
# Bazel bootstrapping

load("//tools/build_rules:http.bzl", "http_archive", "http_file")

http_archive(
name = "bazel_skylib",
sha256 = "1dde365491125a3db70731e25658dfdd3bc5dbdfd11b840b3e987ecf043c7ca0",
url = "https://github.com/bazelbuild/bazel-skylib/releases/download/0.9.0/bazel_skylib-0.9.0.tar.gz",
)

load("@bazel_skylib//lib:versions.bzl", "versions")

versions.check(
minimum_bazel_version = "2.0.0",
)
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file")

# NOTE: We make third_party/ its own bazel workspace because it allows to run `bazel build ...` without
# having all targets defined in third-party BUILD files in that directory buildable.
Expand Down
Loading

0 comments on commit 2c9174f

Please sign in to comment.