-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from delfrrr/layout-updates
Use mapbox hpp skel
- Loading branch information
Showing
30 changed files
with
1,298 additions
and
780 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Standard: Cpp11 | ||
IndentWidth: 4 | ||
AccessModifierOffset: -4 | ||
UseTab: Never | ||
BinPackParameters: false | ||
BinPackArguments: false | ||
AllowShortIfStatementsOnASingleLine: true | ||
AllowShortLoopsOnASingleLine: false | ||
AllowShortBlocksOnASingleLine: true | ||
AllowShortFunctionsOnASingleLine: false | ||
AllowAllParametersOfDeclarationOnNextLine: true | ||
ConstructorInitializerAllOnOneLineOrOnePerLine: true | ||
AlwaysBreakTemplateDeclarations: true | ||
NamespaceIndentation: None | ||
PointerBindsToType: true | ||
SpacesInParentheses: false | ||
BreakBeforeBraces: Attach | ||
ColumnLimit: 0 | ||
Cpp11BracedListStyle: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,56 @@ | ||
language: cpp | ||
dist: trusty | ||
compiler: clang++ | ||
os: linux | ||
language: generic | ||
|
||
matrix: | ||
include: | ||
# clang-format specific job | ||
- os: linux | ||
sudo: false | ||
env: CLANG_FORMAT | ||
addons: | ||
apt: | ||
sources: [ 'ubuntu-toolchain-r-test' ] | ||
packages: [ 'libstdc++6', 'libstdc++-5-dev' ] | ||
script: | ||
- make format | ||
- os: linux | ||
sudo: false | ||
env: CXX=g++-5 | ||
addons: | ||
apt: | ||
sources: [ 'ubuntu-toolchain-r-test' ] | ||
packages: [ 'g++-5' ] | ||
- os: linux | ||
sudo: false | ||
env: CXX=clang++ | ||
addons: | ||
apt: | ||
sources: [ 'ubuntu-toolchain-r-test' ] | ||
packages: [ 'libstdc++6', 'libstdc++-5-dev' ] | ||
# disabled before fixing https://github.com/delfrrr/delaunator-cpp/issues/5 | ||
# - os: linux | ||
# sudo: required # workaround https://github.com/mapbox/node-cpp-skel/issues/93 | ||
# env: CXXFLAGS="-fsanitize=address,undefined,integer -fno-sanitize-recover=all" | ||
# addons: | ||
# apt: | ||
# sources: [ 'ubuntu-toolchain-r-test' ] | ||
# packages: [ 'libstdc++6', 'libstdc++-5-dev' ] | ||
env: | ||
global: | ||
- CMAKE_VERSION="3.8.2" | ||
|
||
install: | ||
- cmake -DCMAKE_BUILD_TYPE=Release | ||
- VERBOSE=1 make | ||
script: ./delaunator-test | ||
# set up the environment by installing mason and clang++ | ||
- ./scripts/setup.sh --config local.env | ||
# put mason and clang++ on PATH | ||
- source local.env | ||
- mason install cmake ${CMAKE_VERSION} | ||
- mason link cmake ${CMAKE_VERSION} | ||
- which cmake | ||
|
||
script: | ||
- make release | ||
- make test | ||
- make clean | ||
- make debug | ||
- make test | ||
- make clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,63 @@ | ||
cmake_minimum_required(VERSION 3.0.0) | ||
project(delaunator VERSION 0.1.0) | ||
cmake_minimum_required(VERSION 3.8) | ||
project(delaunator VERSION 0.2.0) | ||
set (CMAKE_CXX_STANDARD 14) | ||
if (NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/includes") | ||
execute_process(COMMAND bash "-c" "(cd ${CMAKE_CURRENT_SOURCE_DIR} && ./fetch-includes.sh)") | ||
set(CMAKE_CXX_STANDARD_REQUIRED on) | ||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) | ||
|
||
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/mason.cmake) | ||
|
||
option(WERROR "Add -Werror flag to build (turns warnings into errors)" ON) | ||
|
||
# configure optimization | ||
if (CMAKE_BUILD_TYPE STREQUAL "Debug") | ||
set(OPTIMIZATION_FLAGS "-O0 -DDEBUG") | ||
message("-- Configuring debug build") | ||
else() | ||
set(OPTIMIZATION_FLAGS "-O3 -DNDEBUG") | ||
message("-- Configuring release build") | ||
endif() | ||
|
||
# Enable extra warnings to adhere to https://github.com/mapbox/cpp/issues/37 | ||
set(DESIRED_WARNINGS "-Wall -Wextra -Wconversion -Wunreachable-code -Wuninitialized -pedantic-errors -Wold-style-cast -Wno-error=unused-variable -Wshadow -Wfloat-equal -Weffc++") | ||
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") | ||
set(DESIRED_WARNINGS "${DESIRED_WARNINGS} -Wmost") | ||
endif() | ||
|
||
#delaunator | ||
add_library(delaunator src/delaunator.cpp) | ||
target_include_directories (delaunator PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/includes/rapidjson/include") | ||
target_include_directories (delaunator PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/includes/prettyprint") | ||
# Note: -D_GLIBCXX_USE_CXX11_ABI=0 is needed to support mason packages that are precompiled libs | ||
# Currently we only depend on a header only library, but this will help avoid issues when more libs are added via mason | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OPTIMIZATION_FLAGS} -D_GLIBCXX_USE_CXX11_ABI=0 ${DESIRED_WARNINGS}") | ||
|
||
if (WERROR) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") | ||
endif() | ||
|
||
# mason_use is a mason function within the mason.cmake file and provides ready-to-go vars, like "STATIC_LIBS" and "INCLUDE_DIRS" | ||
mason_use(catch VERSION 2.4.0 HEADER_ONLY) | ||
include_directories(SYSTEM ${MASON_PACKAGE_catch_INCLUDE_DIRS}) | ||
|
||
mason_use(rapidjson VERSION 1.1.0 HEADER_ONLY) | ||
include_directories(SYSTEM ${MASON_PACKAGE_rapidjson_INCLUDE_DIRS}) | ||
|
||
mason_use(benchmark VERSION 1.2.0) | ||
include_directories(SYSTEM ${MASON_PACKAGE_benchmark_INCLUDE_DIRS}) | ||
|
||
#delaunator | ||
add_library(json-helpers src/json-helpers.cpp) | ||
target_include_directories (json-helpers PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/includes/rapidjson/include") | ||
include_directories("${PROJECT_SOURCE_DIR}/include") | ||
|
||
#delaunator-test | ||
add_executable(delaunator-test src/delaunator-test.cpp) | ||
target_link_libraries(delaunator-test delaunator) | ||
target_include_directories (delaunator-test PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/includes/catch/single_include/catch2") | ||
target_link_libraries(delaunator-test json-helpers) | ||
file(GLOB TEST_SOURCES test/*.cpp) | ||
add_executable(unit-tests ${TEST_SOURCES}) | ||
|
||
#benchmark | ||
add_executable(benchmark src/benchmark.cpp) | ||
target_link_libraries(benchmark delaunator) | ||
target_link_libraries(benchmark json-helpers) | ||
# libbenchmark.a supports threads and therefore needs pthread support | ||
find_package(Threads REQUIRED) | ||
file(GLOB BENCH_SOURCES bench/*.cpp) | ||
add_executable(bench-tests ${BENCH_SOURCES}) | ||
|
||
#examples | ||
add_executable(triangulate-geojson examples/triangulate_geojson.cpp) | ||
add_executable(basic examples/basic.cpp) | ||
|
||
#triangulate | ||
add_executable(triangulate src/triangulate.cpp) | ||
target_include_directories (triangulate PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/includes/rapidjson/include") | ||
target_include_directories (triangulate PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/includes/prettyprint") | ||
target_link_libraries(triangulate delaunator) | ||
target_link_libraries(triangulate json-helpers) | ||
|
||
# link benchmark static library to the bench-tests binary so the bench tests know where to find the benchmark impl code | ||
target_link_libraries(bench-tests ${MASON_PACKAGE_benchmark_STATIC_LIBS} ${CMAKE_THREAD_LIBS_INIT}) | ||
|
||
set(CPACK_PROJECT_NAME ${PROJECT_NAME}) | ||
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
|
||
# Whether to turn compiler warnings into errors | ||
export WERROR ?= true | ||
export BUILD_DIR ?= cmake-build | ||
|
||
default: release | ||
|
||
release: | ||
mkdir -p ./$(BUILD_DIR) && cd ./$(BUILD_DIR) && cmake ../ -DCMAKE_BUILD_TYPE=Release -DWERROR=$(WERROR) && VERBOSE=1 cmake --build . | ||
|
||
debug: | ||
mkdir -p ./$(BUILD_DIR) && cd ./$(BUILD_DIR) && cmake ../ -DCMAKE_BUILD_TYPE=Debug -DWERROR=$(WERROR) && VERBOSE=1 cmake --build . | ||
|
||
test: | ||
@if [ -f ./$(BUILD_DIR)/unit-tests ]; then ./$(BUILD_DIR)/unit-tests; else echo "Please run 'make release' or 'make debug' first" && exit 1; fi | ||
|
||
bench: | ||
@if [ -f ./$(BUILD_DIR)/bench-tests ]; then ./$(BUILD_DIR)/bench-tests; else echo "Please run 'make release' or 'make debug' first" && exit 1; fi | ||
|
||
tidy: | ||
@echo "not implmented" | ||
|
||
coverage: | ||
@echo "not implmented" | ||
|
||
clean: | ||
rm -rf ./$(BUILD_DIR) | ||
# remove remains from running 'make coverage' | ||
rm -f *.profraw | ||
rm -f *.profdata | ||
@echo "run 'make distclean' to also clear mason_packages, .mason, and .toolchain directories" | ||
|
||
distclean: clean | ||
rm -rf mason_packages | ||
# remove remains from running './scripts/setup.sh' | ||
rm -rf .mason | ||
rm -rf .toolchain | ||
rm -f local.env | ||
|
||
format: | ||
./scripts/format.sh | ||
|
||
.PHONY: test bench |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include "../examples/utils.hpp" | ||
#include <benchmark/benchmark.h> | ||
#include <delaunator.hpp> | ||
#include <string> | ||
|
||
namespace { | ||
void BM_45K_geojson_nodes(benchmark::State& state) { | ||
std::string points_str = utils::read_file("./test/test-files/osm-nodes-45331-epsg-3857.geojson"); | ||
std::vector<double> coords = utils::get_geo_json_points(points_str); | ||
|
||
while (state.KeepRunning()) { | ||
delaunator::Delaunator delaunator(coords); | ||
} | ||
} | ||
} // namespace | ||
|
||
BENCHMARK(BM_45K_geojson_nodes)->Unit(benchmark::kMillisecond); | ||
|
||
BENCHMARK_MAIN() |
Oops, something went wrong.