From 609d074eec8636edf199b6b6d9968d6a1bb599b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20G=C3=BCndling?= Date: Mon, 29 Apr 2024 11:02:29 +0200 Subject: [PATCH] ci (#10) --- .clang-tidy.in | 405 +++++++++++++++++++++++++++++ .github/workflows/ci.yml | 318 ++++++++++++++++++++++ .pkg | 8 +- .pkg.lock | 13 +- CMakeLists.txt | 6 +- CMakePresets.json | 166 ++++++++++++ exe/backend/src/http_server.cc | 6 +- exe/extract.cc | 4 +- include/osr/lookup.h | 10 +- include/osr/routing/profiles/car.h | 1 + include/osr/types.h | 2 +- include/osr/ways.h | 28 +- src/extract.cc | 59 ++--- test/extract_test.cc | 21 +- test/level_test.cc | 10 +- test/main.cc | 2 +- 16 files changed, 977 insertions(+), 82 deletions(-) create mode 100644 .clang-tidy.in create mode 100644 .github/workflows/ci.yml create mode 100644 CMakePresets.json diff --git a/.clang-tidy.in b/.clang-tidy.in new file mode 100644 index 0000000..9cdf69a --- /dev/null +++ b/.clang-tidy.in @@ -0,0 +1,405 @@ +Checks: "*,\ +-llvmlibc-*,\ +-abseil-*,\ +-readability-identifier-length,\ +-altera-unroll-loops,\ +-altera-id-dependent-backward-branch,\ +-bugprone-easily-swappable-parameters,\ +-bugprone-implicit-widening-of-multiplication-result,\ +-llvm-else-after-return,\ +-hicpp-named-parameter,\ +-cert-err60-cpp,\ +-clang-analyzer-core.NonNullParamChecker,\ +-misc-unused-parameters,\ +-cppcoreguidelines-pro-bounds-array-to-pointer-decay,\ +-cppcoreguidelines-pro-bounds-pointer-arithmetic,\ +-cppcoreguidelines-pro-type-union-access,\ +-readability-simplify-boolean-expr,\ +-clang-analyzer-alpha*,\ +-google-build-using-namespace,\ +-clang-analyzer-optin.osx*,\ +-clang-analyzer-osx*,\ +-readability-implicit-bool-cast,\ +-readability-else-after-return,\ +-llvm-include-order,\ +-clang-analyzer-alpha.unix.PthreadLock,\ +-llvm-header-guard,\ +-readability-named-parameter,\ +-clang-analyzer-alpha.deadcode.UnreachableCode,\ +-cppcoreguidelines-pro-type-reinterpret-cast,\ +-cppcoreguidelines-pro-type-vararg,\ +-misc-move-const-arg,\ +-google-runtime-references,\ +-cert-err58-cpp,\ +-modernize-use-default-member-init,\ +-fuchsia-overloaded-operator,\ +-fuchsia-default-arguments,\ +-hicpp-vararg,\ +-clang-analyzer-optin.cplusplus.VirtualCall,\ +-cppcoreguidelines-owning-memory,\ +-hicpp-no-array-decay,\ +-*-magic-numbers,\ +-*-non-private-member-variables-in-classes,\ +-fuchsia-statically-constructed-objects,\ +-readability-isolate-declaration,\ +-fuchsia-multiple-inheritance,\ +-fuchsia-trailing-return,\ +-portability-simd-intrinsics,\ +-modernize-use-nodiscard,\ +-cppcoreguidelines-pro-bounds-constant-array-index,\ +-*-avoid-c-arrays,\ +-*-narrowing-conversions,\ +-*-avoid-goto,\ +-hicpp-multiway-paths-covered,\ +-clang-analyzer-cplusplus.NewDeleteLeaks,\ +-clang-analyzer-cplusplus.NewDelete,\ +-hicpp-signed-bitwise,\ +-cert-msc32-c,\ +-cert-msc51-cpp,\ +-bugprone-exception-escape,\ +-cppcoreguidelines-macro-usage,\ +-cert-dcl21-cpp,\ +-modernize-use-trailing-return-type,\ +-fuchsia-default-arguments-calls,\ +-fuchsia-default-arguments-declarations,\ +-misc-no-recursion,\ +-llvmlibc-callee-namespace,\ +-llvm-else-after-return,\ +-llvm-qualified-auto,\ +-readability-qualified-auto,\ +-google-readability-avoid-underscore-in-googletest-name,\ +-readability-function-cognitive-complexity,\ +-readability-avoid-const-params-in-decls,\ +-cppcoreguidelines-avoid-const-or-ref-data-members,\ +-cppcoreguidelines-avoid-do-while,\ +-altera-struct-pack-align,\ +-bugprone-unchecked-optional-access,\ +-readability-identifier-naming,\ +-cert-dcl37-c,\ +-bugprone-reserved-identifier,\ +-cert-dcl51-cpp,\ +-misc-confusable-identifiers" +WarningsAsErrors: '*' +HeaderFilterRegex: '^${RELATIVE_SOURCE_DIR}(base|modules|test)/' +AnalyzeTemporaryDtors: false +UseColor: true +User: root +CheckOptions: + - key: cert-err61-cpp.CheckThrowTemporaries + value: '1' + - key: cert-oop11-cpp.IncludeStyle + value: llvm + - key: cppcoreguidelines-pro-bounds-constant-array-index.GslHeader + value: '' + - key: cppcoreguidelines-pro-bounds-constant-array-index.IncludeStyle + value: '0' + - key: google-readability-braces-around-statements.ShortStatementLines + value: '1' + - key: google-readability-function-size.BranchThreshold + value: '4294967295' + - key: google-readability-function-size.LineThreshold + value: '4294967295' + - key: google-readability-function-size.StatementThreshold + value: '800' + - key: google-readability-namespace-comments.ShortNamespaceLines + value: '10' + - key: google-readability-namespace-comments.SpacesBeforeComments + value: '2' + - key: google-runtime-int.SignedTypePrefix + value: int + - key: google-runtime-int.TypeSuffix + value: '' + - key: google-runtime-int.UnsignedTypePrefix + value: uint + - key: llvm-namespace-comment.ShortNamespaceLines + value: '1' + - key: llvm-namespace-comment.SpacesBeforeComments + value: '2' + - key: misc-assert-side-effect.AssertMacros + value: assert + - key: misc-assert-side-effect.CheckFunctionCalls + value: '0' + - key: misc-definitions-in-headers.UseHeaderFileExtension + value: '1' + - key: misc-move-constructor-init.IncludeStyle + value: llvm + - key: misc-throw-by-value-catch-by-reference.CheckThrowTemporaries + value: '1' + - key: modernize-loop-convert.MaxCopySize + value: '16' + - key: modernize-loop-convert.MinConfidence + value: reasonable + - key: modernize-loop-convert.NamingStyle + value: lower_case + - key: modernize-pass-by-value.IncludeStyle + value: llvm + - key: modernize-replace-auto-ptr.IncludeStyle + value: llvm + - key: modernize-use-nullptr.NullMacros + value: 'NULL' + - key: readability-braces-around-statements.ShortStatementLines + value: '0' + - key: readability-function-size.BranchThreshold + value: '4294967295' + - key: readability-function-size.LineThreshold + value: '4294967295' + - key: readability-function-size.StatementThreshold + value: '800' + - key: readability-identifier-naming.AbstractClassCase + value: lower_case + - key: readability-identifier-naming.AbstractClassPrefix + value: '' + - key: readability-identifier-naming.AbstractClassSuffix + value: '' + - key: readability-identifier-naming.ClassCase + value: lower_case + - key: readability-identifier-naming.ClassConstantCase + value: aNy_CasE + - key: readability-identifier-naming.ClassConstantPrefix + value: '' + - key: readability-identifier-naming.ClassConstantSuffix + value: '' + - key: readability-identifier-naming.ClassMemberCase + value: lower_case + - key: readability-identifier-naming.ClassMemberPrefix + value: '' + - key: readability-identifier-naming.ClassMemberSuffix + value: '_' + - key: readability-identifier-naming.ClassMethodCase + value: lower_case + - key: readability-identifier-naming.ClassMethodPrefix + value: '' + - key: readability-identifier-naming.ClassMethodSuffix + value: '' + - key: readability-identifier-naming.ClassPrefix + value: '' + - key: readability-identifier-naming.ClassSuffix + value: '' + - key: readability-identifier-naming.ConstantCase + value: aNy_CasE + - key: readability-identifier-naming.ConstantMemberCase + value: aNy_CasE + - key: readability-identifier-naming.ConstantMemberPrefix + value: '' + - key: readability-identifier-naming.ConstantMemberSuffix + value: '' + - key: readability-identifier-naming.ConstantParameterCase + value: aNy_CasE + - key: readability-identifier-naming.ConstantParameterPrefix + value: '' + - key: readability-identifier-naming.ConstantParameterSuffix + value: '' + - key: readability-identifier-naming.ConstantPrefix + value: '' + - key: readability-identifier-naming.ConstantSuffix + value: '' + - key: readability-identifier-naming.ConstexprFunctionCase + value: aNy_CasE + - key: readability-identifier-naming.ConstexprFunctionPrefix + value: '' + - key: readability-identifier-naming.ConstexprFunctionSuffix + value: '' + - key: readability-identifier-naming.ConstexprMethodCase + value: aNy_CasE + - key: readability-identifier-naming.ConstexprMethodPrefix + value: '' + - key: readability-identifier-naming.ConstexprMethodSuffix + value: '' + - key: readability-identifier-naming.ConstexprVariableCase + value: aNy_CasE + - key: readability-identifier-naming.ConstexprVariablePrefix + value: '' + - key: readability-identifier-naming.ConstexprVariableSuffix + value: '' + - key: readability-identifier-naming.EnumCase + value: lower_case + - key: readability-identifier-naming.EnumConstantCase + value: aNy_CasE + - key: readability-identifier-naming.EnumConstantPrefix + value: '' + - key: readability-identifier-naming.EnumConstantSuffix + value: '' + - key: readability-identifier-naming.EnumPrefix + value: '' + - key: readability-identifier-naming.EnumSuffix + value: '' + - key: readability-identifier-naming.FunctionCase + value: lower_case + - key: readability-identifier-naming.FunctionPrefix + value: '' + - key: readability-identifier-naming.FunctionSuffix + value: '' + - key: readability-identifier-naming.GlobalConstantCase + value: aNy_CasE + - key: readability-identifier-naming.GlobalConstantPrefix + value: '' + - key: readability-identifier-naming.GlobalConstantSuffix + value: '' + - key: readability-identifier-naming.GlobalFunctionCase + value: lower_case + - key: readability-identifier-naming.GlobalFunctionPrefix + value: '' + - key: readability-identifier-naming.GlobalFunctionSuffix + value: '' + - key: readability-identifier-naming.GlobalVariableCase + value: aNy_CasE + - key: readability-identifier-naming.GlobalVariablePrefix + value: '' + - key: readability-identifier-naming.GlobalVariableSuffix + value: '' + - key: readability-identifier-naming.IgnoreFailedSplit + value: '0' + - key: readability-identifier-naming.InlineNamespaceCase + value: lower_case + - key: readability-identifier-naming.InlineNamespacePrefix + value: '' + - key: readability-identifier-naming.InlineNamespaceSuffix + value: '' + - key: readability-identifier-naming.LocalConstantCase + value: aNy_CasE + - key: readability-identifier-naming.LocalConstantPrefix + value: '' + - key: readability-identifier-naming.LocalConstantSuffix + value: '' + - key: readability-identifier-naming.LocalVariableCase + value: lower_case + - key: readability-identifier-naming.LocalVariablePrefix + value: '' + - key: readability-identifier-naming.LocalVariableSuffix + value: '' + - key: readability-identifier-naming.MemberCase + value: lower_case + - key: readability-identifier-naming.MemberPrefix + value: '' + - key: readability-identifier-naming.MemberSuffix + value: '_' + - key: readability-identifier-naming.MethodCase + value: lower_case + - key: readability-identifier-naming.MethodPrefix + value: '' + - key: readability-identifier-naming.MethodSuffix + value: '' + - key: readability-identifier-naming.NamespaceCase + value: lower_case + - key: readability-identifier-naming.NamespacePrefix + value: '' + - key: readability-identifier-naming.NamespaceSuffix + value: '' + - key: readability-identifier-naming.ParameterCase + value: lower_case + - key: readability-identifier-naming.ParameterPackCase + value: lower_case + - key: readability-identifier-naming.ParameterPackPrefix + value: '' + - key: readability-identifier-naming.ParameterPackSuffix + value: '' + - key: readability-identifier-naming.ParameterPrefix + value: '' + - key: readability-identifier-naming.ParameterSuffix + value: '' + - key: readability-identifier-naming.PrivateMemberCase + value: lower_case + - key: readability-identifier-naming.PrivateMemberPrefix + value: '' + - key: readability-identifier-naming.PrivateMemberSuffix + value: '_' + - key: readability-identifier-naming.PrivateMethodCase + value: lower_case + - key: readability-identifier-naming.PrivateMethodPrefix + value: '' + - key: readability-identifier-naming.PrivateMethodSuffix + value: '' + - key: readability-identifier-naming.ProtectedMemberCase + value: lower_case + - key: readability-identifier-naming.ProtectedMemberPrefix + value: '' + - key: readability-identifier-naming.ProtectedMemberSuffix + value: '_' + - key: readability-identifier-naming.ProtectedMethodCase + value: lower_case + - key: readability-identifier-naming.ProtectedMethodPrefix + value: '' + - key: readability-identifier-naming.ProtectedMethodSuffix + value: '' + - key: readability-identifier-naming.PublicMemberCase + value: lower_case + - key: readability-identifier-naming.PublicMemberPrefix + value: '' + - key: readability-identifier-naming.PublicMemberSuffix + value: '_' + - key: readability-identifier-naming.PublicMethodCase + value: lower_case + - key: readability-identifier-naming.PublicMethodPrefix + value: '' + - key: readability-identifier-naming.PublicMethodSuffix + value: '' + - key: readability-identifier-naming.StaticConstantCase + value: aNy_CasE + - key: readability-identifier-naming.StaticConstantPrefix + value: '' + - key: readability-identifier-naming.StaticConstantSuffix + value: '' + - key: readability-identifier-naming.StaticVariableCase + value: lower_case + - key: readability-identifier-naming.StaticVariablePrefix + value: '' + - key: readability-identifier-naming.StaticVariableSuffix + value: '' + - key: readability-identifier-naming.StructCase + value: lower_case + - key: readability-identifier-naming.StructPrefix + value: '' + - key: readability-identifier-naming.StructSuffix + value: '' + - key: readability-identifier-naming.TemplateParameterCase + value: CamelCase + - key: readability-identifier-naming.TemplateTemplateParameterCase + value: CamelCase + - key: readability-identifier-naming.TypedefCase + value: lower_case + - key: readability-identifier-naming.TypedefPrefix + value: '' + - key: readability-identifier-naming.TypedefSuffix + value: '' + - key: readability-identifier-naming.UnionCase + value: lower_case + - key: readability-identifier-naming.UnionPrefix + value: '' + - key: readability-identifier-naming.UnionSuffix + value: '' + - key: readability-identifier-naming.ValueTemplateParameterCase + value: CamelCase + - key: readability-identifier-naming.ValueTemplateParameterPrefix + value: '' + - key: readability-identifier-naming.ValueTemplateParameterSuffix + value: '' + - key: readability-identifier-naming.VariableCase + value: aNy_CasE + - key: readability-identifier-naming.VariablePrefix + value: '' + - key: readability-identifier-naming.VariableSuffix + value: '' + - key: readability-identifier-naming.VirtualMethodCase + value: lower_case + - key: readability-identifier-naming.VirtualMethodPrefix + value: '' + - key: readability-identifier-naming.VirtualMethodSuffix + value: '' + - key: readability-simplify-boolean-expr.ChainedConditionalAssignment + value: '0' + - key: readability-simplify-boolean-expr.ChainedConditionalReturn + value: '0' + - key: performance-for-range-copy.AllowedTypes + value: 'offset_ptr;ptr' + - key: performance-unnecessary-value-param.AllowedTypes + value: 'offset_ptr;ptr' + - key: readability-identifier-naming.TypeTemplateParameterIgnoredRegexp + value: 'expr-type' + - key: readability-identifier-naming.TemplateParameterIgnoredRegexp + value: 'expr-type' + - key: readability-identifier-naming.TypeTemplateParameterIgnoredRegexp + value: 'expr-type' + - key: readability-identifier-naming.TemplateTemplateParameterIgnoredRegexp + value: 'expr-type' + - key: readability-identifier-naming.ValueTemplateParameterIgnoredRegexp + value: 'expr-type' diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..0e01eb5 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,318 @@ +name: Linux+MacOS Build + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + release: + types: + - published + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + formatting: + runs-on: ubuntu-latest + container: ghcr.io/motis-project/docker-cpp-build + steps: + - uses: actions/checkout@v4 + + - name: Format files + run: | + find base libs modules test \ + -type f -a \( -name "*.cc" -o -name "*.h" -o -name ".cuh" -o -name ".cu" \) \ + -print0 | xargs -0 clang-format-16 -i + + - name: Check for differences + run: | + git config --global --add safe.directory `pwd` + git status --porcelain + git status --porcelain | xargs -I {} -0 test -z \"{}\" + + msvc: + runs-on: windows-latest + + strategy: + fail-fast: false + matrix: + config: + - mode: Debug + - mode: Release + + env: + CXX: cl.exe + CC: cl.exe + BUILDCACHE_COMPRESS: true + BUILDCACHE_DIRECT_MODE: true + BUILDCACHE_ACCURACY: SLOPPY # not suitable for coverage/debugging + BUILDCACHE_DIR: ${{ github.workspace }}/.buildcache + BUILDCACHE_LUA_PATH: ${{ github.workspace }}/tools + CLICOLOR_FORCE: 1 + + steps: + - uses: actions/checkout@v4 + + - name: Install ninja + run: choco install ninja + + - name: Restore buildcache Cache + uses: actions/cache/restore@v4 + id: restore-buildcache + with: + path: ${{ github.workspace }}/.buildcache + key: buildcache-wnds-${{ matrix.config.mode }}-${{ hashFiles('.pkg') }}-${{ hashFiles('**/*.h') }}-${{ hashFiles('**/*.cc') }} + restore-keys: | + buildcache-wnds-${{ matrix.config.mode }}-${{ hashFiles('.pkg') }}-${{ hashFiles('**/*.h') }} + buildcache-wnds-${{ matrix.config.mode }}-${{ hashFiles('.pkg') }}- + buildcache-wnds-${{ matrix.config.mode }}- + + - name: Dependencies Cache + uses: actions/cache@v4 + with: + path: ${{ github.workspace }}/deps + key: deps-${{ hashFiles('.pkg') }} + restore-keys: deps- + + - uses: ilammy/msvc-dev-cmd@v1 + + - name: Build + run: | + cmake ` + -GNinja -S . -B build ` + -DCMAKE_BUILD_TYPE=${{ matrix.config.mode }} + .\build\buildcache\bin\buildcache.exe -z + cmake --build build --target osr-extract osr-backend osr-benchmark osr-test + $CompilerExitCode = $LastExitCode + .\build\buildcache\bin\buildcache.exe -s + exit $CompilerExitCode + + # ==== TESTS ==== + - name: Run Tests + run: .\build\osr-test.exe + + # ==== SAVE CACHE ==== + - name: Save buildcache Cache + if: always() + uses: actions/cache/save@v4 + with: + path: ${{ github.workspace }}/.buildcache + key: ${{ steps.restore-buildcache.outputs.cache-primary-key }} + + # ==== DISTRIBUTION ==== + - name: Create Distribution + if: matrix.config.mode == 'Release' + run: | + mkdir dist + mv web dist + mv .\build\osr-extract.exe dist + mv .\build\osr-backend.exe dist + cd dist + 7z a osr-windows.zip * + mv osr-windows.zip .. + + - name: Upload Distribution + if: matrix.config.mode == 'Release' + uses: actions/upload-artifact@v4 + with: + name: osr-windows + path: dist + + # ==== RELEASE ==== + - name: Upload Release + if: github.event.action == 'published' && matrix.config.mode == 'Release' + uses: actions/upload-release-asset@v1.0.2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ github.event.release.upload_url }} + asset_path: ./osr-windows.zip + asset_name: osr-windows.zip + asset_content_type: application/zip + + macos: + runs-on: ${{ matrix.config.os }} + strategy: + fail-fast: false + matrix: + config: + - preset: macos-x86_64 + os: macos-13 + - preset: macos-arm64 + os: macos-14 + env: + BUILDCACHE_COMPRESS: true + BUILDCACHE_DIRECT_MODE: true + BUILDCACHE_ACCURACY: SLOPPY + BUILDCACHE_LUA_PATH: ${{ github.workspace }}/tools + BUILDCACHE_DIR: ${{ github.workspace }}/.buildcache + BUILDCACHE_MAX_CACHE_SIZE: 1073741824 + BUILDCACHE_DEBUG: 0 + UBSAN_OPTIONS: halt_on_error=1:abort_on_error=1 + ASAN_OPTIONS: alloc_dealloc_mismatch=0 + CLICOLOR_FORCE: 1 + steps: + - uses: actions/checkout@v4 + + # ==== RESTORE CACHE ==== + - name: Restore buildcache Cache + uses: actions/cache/restore@v4 + id: restore-buildcache + with: + path: ${{ github.workspace }}/.buildcache + key: buildcache-${{ matrix.config.preset }}-${{ hashFiles('.pkg') }}-${{ hashFiles('**/*.h') }}-${{ hashFiles('**/*.cc') }} + restore-keys: | + buildcache-${{ matrix.config.preset }}-${{ hashFiles('.pkg') }}-${{ hashFiles('**/*.h') }}- + buildcache-${{ matrix.config.preset }}-${{ hashFiles('.pkg') }}- + buildcache-${{ matrix.config.preset }}- + + - name: Restore Dependencies Cache + uses: actions/cache/restore@v4 + id: restore-deps-cache + with: + path: ${{ github.workspace }}/deps + enableCrossOsArchive: true + key: deps-${{ hashFiles('.pkg') }} + restore-keys: | + deps- + + - name: Install Ninja + run: brew install ninja + + # ==== BUILD ==== + - name: CMake + run: | + git config --global --add safe.directory `pwd` + cmake -G Ninja -S . -B build --preset=${{ matrix.config.preset }} + + - name: Build + run: cmake --build build --target osr-extract osr-backend osr-benchmark osr-test + + # ==== TESTS ==== + - name: Run Tests + run: ./build/osr-test + + # ==== DISTRIBUTION ==== + - name: Create Distribution + run: | + mkdir osr + mv build/osr-extract osr/osr-extract + mv build/osr-backend osr/osr-backend + tar cjf osr-${{ matrix.config.preset }}.tar.bz2 osr + + - name: Upload Distribution + uses: actions/upload-artifact@v4 + with: + name: osr-${{ matrix.config.preset }} + path: osr-${{ matrix.config.preset }}.tar.bz2 + + # ==== RELEASE ==== + - name: Upload Release + if: github.event.action == 'published' + uses: actions/upload-release-asset@v1.0.2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ github.event.release.upload_url }} + asset_path: ./osr-${{ matrix.config.preset }}.tar.bz2 + asset_name: osr-${{ matrix.config.preset }}.tar.bz2 + asset_content_type: application/x-tar + + # ==== SAVE CACHE ==== + - name: Save buildcache Cache + if: always() + uses: actions/cache/save@v4 + with: + path: ${{ github.workspace }}/.buildcache + key: ${{ steps.restore-buildcache.outputs.cache-primary-key }} + + - name: Save Dependencies Cache + if: always() + uses: actions/cache/save@v4 + with: + path: ${{ github.workspace }}/deps + key: ${{ steps.restore-deps-cache.outputs.cache-primary-key }} + enableCrossOsArchive: true + + linux: + runs-on: [ self-hosted, linux, x64, "${{ matrix.config.preset }}" ] + container: + image: ghcr.io/motis-project/docker-cpp-build + volumes: + - ${{ github.event.repository.name }}-${{ matrix.config.preset }}-deps:/deps + - ${{ github.event.repository.name }}-${{ matrix.config.preset }}-buildcache:/buildcache + strategy: + fail-fast: false + matrix: + config: + - preset: linux-amd64-release + artifact: linux-amd64 + - preset: linux-arm64-release + artifact: linux-arm64 + emulator: qemu-aarch64-static + - preset: clang-tidy + - preset: linux-sanitizer + - preset: linux-debug + emulator: valgrind --leak-check=full --error-exitcode=1 + env: + BUILDCACHE_DIR: /buildcache + BUILDCACHE_COMPRESS: true + BUILDCACHE_ACCURACY: SLOPPY + BUILDCACHE_DIRECT_MODE: true + BUILDCACHE_MAX_CACHE_SIZE: 2147483648 + BUILDCACHE_LUA_PATH: ${{ github.workspace }}/tools + UBSAN_OPTIONS: halt_on_error=1:abort_on_error=1 + ASAN_OPTIONS: alloc_dealloc_mismatch=0 + steps: + - uses: actions/checkout@v4 + + - name: Get deps + run: ln -s /deps deps + + - name: CMake + run: | + git config --global --add safe.directory `pwd` + cmake -G Ninja -S . -B build --preset=${{ matrix.config.preset }} + + # ==== BUILD ==== + - name: Build + run: | + buildcache -z + cmake --build build --target osr-extract osr-backend osr-benchmark osr-test + buildcache -s + + # ==== TESTS ==== + - name: Run Tests + if: ${{ !matrix.config.skiptests }} + run: ${{ matrix.config.emulator }} build/osr-test + + # ==== DISTRIBUTION ==== + - name: Create Distribution + if: matrix.config.artifact + run: | + mkdir osr + mv web osr/web + mv build/osr-extract osr/osr-extract + mv build/osr-backend osr/osr-backend + tar cjf osr-${{ matrix.config.artifact }}.tar.bz2 osr + + - name: Upload Distribution + if: matrix.config.artifact + uses: actions/upload-artifact@v4 + with: + name: osr-${{ matrix.config.artifact }} + path: osr-${{ matrix.config.artifact }}.tar.bz2 + + # ==== RELEASE ==== + - name: Upload Release + if: github.event.action == 'published' && matrix.config.artifact + uses: actions/upload-release-asset@v1.0.2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ github.event.release.upload_url }} + asset_path: ./osr-${{ matrix.config.artifact }}.tar.bz2 + asset_name: osr-${{ matrix.config.artifact }}.tar.bz2 + asset_content_type: application/x-tar diff --git a/.pkg b/.pkg index 7551a1c..08d539b 100644 --- a/.pkg +++ b/.pkg @@ -1,3 +1,7 @@ +[boost] + url=git@github.com:motis-project/boost.git + branch=master + commit=60cae66449fa3c9599b2b7d3d5d44c65301ed3a3 [osmium] url=git@github.com:motis-project/libosmium.git branch=master @@ -33,7 +37,7 @@ [tiles] url=git@github.com:motis-project/tiles.git branch=master - commit=1b99290ba3ff16144afcdb04f6ca4e593d361c70 + commit=64f297ea0f782d04c89e82c6d478a1dd453e5f70 [mimalloc] url=git@github.com:motis-project/mimalloc.git branch=master @@ -57,7 +61,7 @@ [expat] url=git@github.com:motis-project/expat.git branch=master - commit=b8c26c40f1900899b95c795705e0252fc0c1350c + commit=20b3b3e7dde39ee18c27c238b8d1246019ecb147 [net] url=git@github.com:motis-project/net.git branch=master diff --git a/.pkg.lock b/.pkg.lock index 06b7309..a277540 100644 --- a/.pkg.lock +++ b/.pkg.lock @@ -1,9 +1,9 @@ -15434619220611677274 +17387922825967387713 cista ebd5eb5cc7f82c414d3e060a3937d497189a103f zlib d1c943390ba4f97aa2f50bedc629b6d29027fa0e -boost be5235eb2258d2ec19e32546ab767a62311d9b46 +boost 60cae66449fa3c9599b2b7d3d5d44c65301ed3a3 conf a32d491bd54800310a53ccba13f4ee9f6736ff3e -expat b8c26c40f1900899b95c795705e0252fc0c1350c +expat 20b3b3e7dde39ee18c27c238b8d1246019ecb147 fmt edb385ac526c24bc917ec4a41bb0edb28f0ca59e doctest 70e8f76437b76dd5e9c0a2eb9b907df190ab71a0 geo ee76668f0f0454e4acd3c769e00c6868620e3490 @@ -14,17 +14,16 @@ libressl 390253a44ceef00eb620c38606588414326e9f23 net 44674d2f3917e20b7019a0f7254d332522c36fb7 protozero 8c9f3fa97c2cfdceef86d0b61818ae98e9328f29 rapidjson e7a1ac95c7840c6f4351abead02b1f7a02874197 -Catch2 47d56f28a9801911c048d011b375e5631dbb658f -LuaJIT 4638e9198beb2f14bd1c90b42aff744469eed404 +LuaJIT babeae2c3311bed245ee86f3e35a1f244e3da60b clipper 904f0e6644c7f01c176443613be8f7788d59c658 concurrentqueue 54fdce755d3e52c785d6d9d7d91c94615495868c lmdb 39d8127e5697b1323a67e61c3ad8f087384c7429 miniz 1edbdece9d71dc65c6ff405572ee37cbdcef7af4 -res c500c261531a2b8b8d475fc9d42c075f28f72aaf +res 7d97784ba785ce8a2677ea77164040fde484fb04 pbf-sdf-fonts 91b369e4eb8a618e0a83b0c04b1b08632ea872c4 sol2 fdb0f8a60e48aa737f0a8d73edede48627f0c984 utl 4c1503afe58e209977d9a1e3db6a6b271a50c521 variant 5aa73631dc969087c77433a5cdef246303051f69 -tiles 1b99290ba3ff16144afcdb04f6ca4e593d361c70 +tiles 64f297ea0f782d04c89e82c6d478a1dd453e5f70 unordered_dense c11595a7743d20622637584bddf77243d72ae152 rtree.c 6ed73a7dc4f1184f2b5b2acd8ac1c2b28a273057 diff --git a/CMakeLists.txt b/CMakeLists.txt index 870cc8e..e89b27a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,6 +16,9 @@ if (MSVC) string(REPLACE "/Zi" "${OSR_MSVC_DEBUG_FLAGS}" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") string(REPLACE "/Zi" "${OSR_MSVC_DEBUG_FLAGS}" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}") string(REPLACE "/Zi" "${OSR_MSVC_DEBUG_FLAGS}" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") + + add_definitions(-D_CRT_SECURE_NO_WARNINGS=1) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4996") # ignore deprecated fileno in tiles endif () if (NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY) @@ -78,9 +81,10 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") -Wno-documentation-unknown-command -Wno-duplicate-enum -Wno-ctad-maybe-unsupported + -Wno-unknown-pragmas -Werror) elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang") - set(osr-compile-options -Wall -Wextra -Werror) + set(osr-compile-options -Wall -Wextra -Werror -Wno-unknown-pragmas) elseif (MSVC) set(osr-compile-options /WX) else () diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 0000000..0d74405 --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,166 @@ +{ + "version": 3, + "cmakeMinimumRequired": { + "major": 3, + "minor": 21, + "patch": 0 + }, + "configurePresets": [ + { + "name": "macos-x86_64", + "displayName": "MacOS x86_64 Release", + "generator": "Ninja", + "binaryDir": "${sourceDir}/build/macos-x86_64-release", + "cacheVariables": { + "CMAKE_OSX_ARCHITECTURES": "x86_64", + "CMAKE_CXX_FLAGS": "-stdlib=libc++", + "CMAKE_BUILD_TYPE": "Release" + } + }, + { + "name": "macos-arm64", + "displayName": "MacOS ARM64 Release", + "generator": "Ninja", + "binaryDir": "${sourceDir}/build/macos-arm64-release", + "cacheVariables": { + "CMAKE_OSX_ARCHITECTURES": "arm64", + "CMAKE_CXX_FLAGS": "-stdlib=libc++", + "BOOST_CONTEXT_ARCHITECTURE": "arm64", + "BOOST_CONTEXT_ABI": "aapcs", + "ENABLE_ASM": "OFF", + "CMAKE_BUILD_TYPE": "Release" + } + }, + { + "name": "linux-amd64-release", + "displayName": "Linux AMD64 Release", + "generator": "Ninja", + "binaryDir": "${sourceDir}/build/amd64-release", + "toolchainFile": "/opt/x86_64-multilib-linux-musl/toolchain-amd64.cmake", + "cacheVariables": { + "CMAKE_EXE_LINKER_FLAGS": "-B/opt/mold", + "CMAKE_BUILD_TYPE": "Release", + "OSR_MIMALLOC": "ON" + }, + "environment": { + "PATH": "/opt:/opt/cmake-3.26.3-linux-x86_64/bin:/opt/buildcache/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" + } + }, + { + "name": "linux-arm64-release", + "displayName": "Linux ARM64 Release", + "generator": "Ninja", + "binaryDir": "${sourceDir}/build/arm64-release", + "toolchainFile": "/opt/aarch64-unknown-linux-musl/toolchain-arm64.cmake", + "cacheVariables": { + "CMAKE_CROSSCOMPILING_EMULATOR": "qemu-aarch64-static", + "CMAKE_EXE_LINKER_FLAGS": "-B/opt/mold", + "CMAKE_BUILD_TYPE": "Release", + "OSR_MIMALLOC": "ON" + }, + "environment": { + "PATH": "/opt:/opt/cmake-3.26.3-linux-x86_64/bin:/opt/buildcache/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" + } + }, + { + "name": "linux-sanitizer", + "displayName": "Linux Sanitizer", + "generator": "Ninja", + "binaryDir": "${sourceDir}/build/sanitizer", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug", + "CMAKE_C_COMPILER": "clang-16", + "CMAKE_CXX_COMPILER": "clang++-16", + "CMAKE_C_FLAGS": "-fsanitize=address,undefined -fno-omit-frame-pointer", + "CMAKE_CXX_FLAGS": "-stdlib=libc++ -fsanitize=address,undefined -fno-omit-frame-pointer", + "CMAKE_EXE_LINKER_FLAGS": "-lc++abi -fuse-ld=/opt/mold/ld" + }, + "environment": { + "PATH": "/opt:/opt/cmake-3.26.3-linux-x86_64/bin:/opt/buildcache/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", + "CXX": "/usr/bin/g++-12", + "CC": "/usr/bin/gcc-12" + } + }, + { + "name": "linux-debug", + "displayName": "Linux Debug", + "generator": "Ninja", + "binaryDir": "${sourceDir}/build/debug", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug" + }, + "environment": { + "PATH": "/opt:/opt/cmake-3.26.3-linux-x86_64/bin:/opt/buildcache/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", + "CXX": "/usr/bin/g++-12", + "CC": "/usr/bin/gcc-12" + } + }, + { + "name": "linux-relwithdebinfo", + "displayName": "Linux RelWithDebInfo", + "generator": "Ninja", + "binaryDir": "${sourceDir}/build/relwithdebinfo", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "RelWithDebInfo", + "CMAKE_EXE_LINKER_FLAGS": "-B/opt/mold" + }, + "environment": { + "PATH": "/opt:/opt/cmake-3.26.3-linux-x86_64/bin:/opt/buildcache/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", + "CXX": "/usr/bin/g++-12", + "CC": "/usr/bin/gcc-12" + } + }, + { + "name": "clang-tidy", + "displayName": "Clang Tidy", + "generator": "Ninja", + "binaryDir": "${sourceDir}/build/clang-tidy", + "cacheVariables": { + "CMAKE_C_COMPILER": "clang-16", + "CMAKE_CXX_COMPILER": "clang++-16", + "CMAKE_CXX_FLAGS": "-stdlib=libc++", + "CMAKE_EXE_LINKER_FLAGS": "-lc++abi", + "CMAKE_BUILD_TYPE": "Release", + "OSR_LINT": "On" + }, + "environment": { + "BUILDCACHE_LUA_PATH": "/opt/buildcache/share/lua-examples", + "PATH": "/opt:/opt/cmake-3.26.3-linux-x86_64/bin:/opt/buildcache/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" + } + } + ], + "buildPresets": [ + { + "name": "macos-x86_64", + "configurePreset": "macos-x86_64" + }, + { + "name": "macos-arm64", + "configurePreset": "macos-arm64" + }, + { + "name": "linux-amd64-release", + "configurePreset": "linux-amd64-release" + }, + { + "name": "linux-arm64-release", + "configurePreset": "linux-arm64-release" + }, + { + "name": "clang-tidy", + "configurePreset": "clang-tidy" + }, + { + "name": "linux-debug", + "configurePreset": "linux-debug" + }, + { + "name": "linux-relwithdebinfo", + "configurePreset": "linux-relwithdebinfo" + }, + { + "name": "linux-sanitizer", + "configurePreset": "linux-sanitizer" + } + ] +} diff --git a/exe/backend/src/http_server.cc b/exe/backend/src/http_server.cc index 223429d..bd53f60 100644 --- a/exe/backend/src/http_server.cc +++ b/exe/backend/src/http_server.cc @@ -11,6 +11,7 @@ #include "fmt/core.h" #include "utl/enumerate.h" +#include "utl/pipes.h" #include "utl/to_vec.h" #include "net/web_server/responses.h" @@ -54,7 +55,7 @@ web_server::string_res_t json_response( } location parse_location(json::value const& v) { - auto const obj = v.as_object(); + auto const& obj = v.as_object(); return {obj.at("lat").as_double(), obj.at("lng").as_double(), obj.contains("level") ? to_level(obj.at("level").to_number()) : level_t::invalid()}; @@ -110,7 +111,8 @@ struct http_server::impl { auto const from = parse_location(q.at("start")); auto const to = parse_location(q.at("destination")); auto const max_it = q.find("max"); - auto const max = max_it == q.end() ? 3600 : max_it->value().as_int64(); + auto const max = static_cast( + max_it == q.end() ? 3600 : max_it->value().as_int64()); auto p = std::optional{}; switch (profile) { diff --git a/exe/extract.cc b/exe/extract.cc index 39ca642..a9fa613 100644 --- a/exe/extract.cc +++ b/exe/extract.cc @@ -14,8 +14,8 @@ using namespace boost::program_options; namespace fs = std::filesystem; struct config : public conf::configuration { - config(std::filesystem::path in, std::filesystem::path const& out) - : configuration{"Options"}, in_{std::move(in)}, out_{out} { + config(std::filesystem::path in, std::filesystem::path out) + : configuration{"Options"}, in_{std::move(in)}, out_{std::move(out)} { param(in_, "in,i", "OpenStreetMap .osm.pbf input path"); param(out_, "out,o", "output directory"); } diff --git a/include/osr/lookup.h b/include/osr/lookup.h index eef60fb..119ecf6 100644 --- a/include/osr/lookup.h +++ b/include/osr/lookup.h @@ -127,8 +127,9 @@ struct lookup { return node_candidate{}; } - auto const offroad_cost = Profile::way_cost( - way_prop, flip(search_dir, edge_dir), wc.dist_to_way_); + auto const offroad_cost = + Profile::way_cost(way_prop, flip(search_dir, edge_dir), + static_cast(wc.dist_to_way_)); auto c = node_candidate{.lvl_ = lvl, .way_dir_ = dir, .dist_to_node_ = wc.dist_to_way_, @@ -144,8 +145,9 @@ struct lookup { auto const segment_dist = geo::distance(c.path_.back(), pos); c.dist_to_node_ += segment_dist; - c.cost_ += Profile::way_cost( - way_prop, flip(search_dir, edge_dir), segment_dist); + c.cost_ += + Profile::way_cost(way_prop, flip(search_dir, edge_dir), + static_cast(segment_dist)); c.path_.push_back(pos); auto const way_node = ways_.find_node_idx(osm_node_idx); diff --git a/include/osr/routing/profiles/car.h b/include/osr/routing/profiles/car.h index ed73753..1ae0aa4 100644 --- a/include/osr/routing/profiles/car.h +++ b/include/osr/routing/profiles/car.h @@ -140,6 +140,7 @@ struct car { utl::zip_unchecked(w.node_ways_[n.n_], w.node_in_way_idx_[n.n_])) { auto const expand = [&](direction const way_dir, std::uint16_t const from, std::uint16_t const to) { + // NOLINTNEXTLINE(clang-analyzer-core.CallAndMessage) auto const target_node = w.way_nodes_[way][to]; auto const target_node_prop = w.node_properties_[target_node]; if (node_cost(target_node_prop) == kInfeasible) { diff --git a/include/osr/types.h b/include/osr/types.h index 1adb8af..619704f 100644 --- a/include/osr/types.h +++ b/include/osr/types.h @@ -207,7 +207,7 @@ constexpr std::uint16_t to_kmh(speed_limit const l) { } constexpr std::uint16_t to_meters_per_second(speed_limit const l) { - return to_kmh(l) / 3.6; + return static_cast(to_kmh(l) / 3.6); } } // namespace osr \ No newline at end of file diff --git a/include/osr/ways.h b/include/osr/ways.h index 920c1fb..d0c7877 100644 --- a/include/osr/ways.h +++ b/include/osr/ways.h @@ -67,14 +67,14 @@ struct way_properties { constexpr level_t from_level() const { return level_t{from_level_}; } constexpr level_t to_level() const { return level_t{to_level_}; } - std::uint8_t is_foot_accessible_ : 1; - std::uint8_t is_bike_accessible_ : 1; - std::uint8_t is_car_accessible_ : 1; - std::uint8_t is_destination_ : 1; - std::uint8_t is_oneway_car_ : 1; - std::uint8_t is_oneway_bike_ : 1; - std::uint8_t is_elevator_ : 1; - std::uint8_t is_steps_ : 1; + bool is_foot_accessible_ : 1; + bool is_bike_accessible_ : 1; + bool is_car_accessible_ : 1; + bool is_destination_ : 1; + bool is_oneway_car_ : 1; + bool is_oneway_bike_ : 1; + bool is_elevator_ : 1; + bool is_steps_ : 1; std::uint8_t speed_limit_ : 3; @@ -97,12 +97,12 @@ struct node_properties { std::uint8_t from_level_ : 5; - std::uint8_t is_foot_accessible_ : 1; - std::uint8_t is_bike_accessible_ : 1; - std::uint8_t is_car_accessible_ : 1; - std::uint8_t is_elevator_ : 1; - std::uint8_t is_entrance_ : 1; - std::uint8_t is_multi_level_ : 1; + bool is_foot_accessible_ : 1; + bool is_bike_accessible_ : 1; + bool is_car_accessible_ : 1; + bool is_elevator_ : 1; + bool is_entrance_ : 1; + bool is_multi_level_ : 1; std::uint8_t to_level_ : 5; }; diff --git a/src/extract.cc b/src/extract.cc index c2df2e8..d0e19d9 100644 --- a/src/extract.cc +++ b/src/extract.cc @@ -27,9 +27,7 @@ namespace osm = osmium; namespace osm_io = osmium::io; -namespace osm_rel = osmium::relations; namespace osm_eb = osmium::osm_entity_bits; -namespace osm_area = osmium::area; namespace osm_mem = osmium::memory; namespace fs = std::filesystem; using namespace std::string_view_literals; @@ -70,7 +68,7 @@ speed_limit get_speed_limit(tags const& t) { case cista::hash("tertiary"): return t.name_.empty() ? get_speed_limit(70) : get_speed_limit(40); case cista::hash("tertiary_link"): return get_speed_limit(20); - case cista::hash("unclassified"): return get_speed_limit(25); + case cista::hash("unclassified"): [[fallthrough]]; case cista::hash("residential"): return get_speed_limit(25); case cista::hash("living_street"): return get_speed_limit(10); case cista::hash("service"): return get_speed_limit(15); @@ -83,38 +81,37 @@ speed_limit get_speed_limit(tags const& t) { way_properties get_way_properties(tags const& t) { auto const [from, to, _] = get_levels(t.level_bits_); - return { - .is_foot_accessible_ = is_accessible(t, osm_obj_type::kWay), - .is_bike_accessible_ = is_accessible(t, osm_obj_type::kWay), - .is_car_accessible_ = is_accessible(t, osm_obj_type::kWay), - .is_destination_ = t.is_destination_, - .is_oneway_car_ = t.oneway_, - .is_oneway_bike_ = t.oneway_ && !t.not_oneway_bike_, - .is_elevator_ = t.is_elevator_, - .is_steps_ = (t.highway_ == "steps"sv), - .speed_limit_ = get_speed_limit(t), - .from_level_ = to_idx(from), - .to_level_ = to_idx(to)}; + auto p = way_properties{}; + std::memset(&p, 0, sizeof(way_properties)); + p.is_foot_accessible_ = is_accessible(t, osm_obj_type::kWay); + p.is_bike_accessible_ = is_accessible(t, osm_obj_type::kWay); + p.is_car_accessible_ = is_accessible(t, osm_obj_type::kWay); + p.is_destination_ = t.is_destination_; + p.is_oneway_car_ = t.oneway_; + p.is_oneway_bike_ = t.oneway_ && !t.not_oneway_bike_; + p.is_elevator_ = t.is_elevator_; + p.is_steps_ = (t.highway_ == "steps"sv); + p.speed_limit_ = get_speed_limit(t); + p.from_level_ = to_idx(from); + p.to_level_ = to_idx(to); + return p; } std::pair get_node_properties( osm::Node const& n) { auto const t = tags{n}; auto const [from, to, is_multi] = get_levels(t.level_bits_); - return {{ - .from_level_ = to_idx(from), - .is_foot_accessible_ = - is_accessible(t, osm_obj_type::kNode), - .is_bike_accessible_ = - is_accessible(t, osm_obj_type::kNode), - .is_car_accessible_ = - is_accessible(t, osm_obj_type::kNode), - .is_elevator_ = t.is_elevator_, - .is_entrance_ = t.is_entrance_, - .is_multi_level_ = is_multi, - .to_level_ = to_idx(to), - }, - t.level_bits_}; + auto p = node_properties{}; + std::memset(&p, 0, sizeof(node_properties)); + p.from_level_ = to_idx(from); + p.is_foot_accessible_ = is_accessible(t, osm_obj_type::kNode); + p.is_bike_accessible_ = is_accessible(t, osm_obj_type::kNode); + p.is_car_accessible_ = is_accessible(t, osm_obj_type::kNode); + p.is_elevator_ = t.is_elevator_; + p.is_entrance_ = t.is_entrance_; + p.is_multi_level_ = is_multi; + p.to_level_ = to_idx(to); + return {p, t.level_bits_}; } struct way_handler : public osm::handler::Handler { @@ -299,7 +296,7 @@ struct node_handler : public osm::handler::Handler { }; struct mark_inaccessible_handler : public osm::handler::Handler { - mark_inaccessible_handler(ways& w) : w_{w} {} + explicit mark_inaccessible_handler(ways& w) : w_{w} {} void node(osm::Node const& n) { auto const t = tags{n}; @@ -316,7 +313,7 @@ struct mark_inaccessible_handler : public osm::handler::Handler { }; struct rel_ways_handler : public osm::handler::Handler { - rel_ways_handler(hash_map& rel_ways) + explicit rel_ways_handler(hash_map& rel_ways) : rel_ways_{rel_ways} {} void relation(osm::Relation const& r) { diff --git a/test/extract_test.cc b/test/extract_test.cc index 4dc8e93..293e17b 100644 --- a/test/extract_test.cc +++ b/test/extract_test.cc @@ -1,3 +1,7 @@ +#ifdef _WIN32 +#include "windows.h" +#endif + #include "gtest/gtest.h" #include @@ -5,10 +9,8 @@ #include "fmt/core.h" #include "fmt/ranges.h" -#include "osr/dijkstra.h" #include "osr/extract/extract.h" #include "osr/lookup.h" -#include "osr/route.h" #include "osr/ways.h" namespace fs = std::filesystem; @@ -29,17 +31,8 @@ TEST(extract, wa) { auto const rhoenring = w.find_way(osm_way_idx_t{120682496}); auto const arheilger = w.find_way(osm_way_idx_t{1068971150}); - auto const is_restricted = - w.is_restricted(n.value(), w.get_way_pos(n.value(), rhoenring.value()), - w.get_way_pos(n.value(), arheilger.value())); + auto const is_restricted = w.is_restricted( + n.value(), w.get_way_pos(n.value(), rhoenring.value()), + w.get_way_pos(n.value(), arheilger.value())); EXPECT_TRUE(is_restricted); - - auto const from = location{geo::latlng{49.88284883601411, 8.660528432499735}, - level_t::invalid()}; - auto const to = location{geo::latlng{49.88281465756099, 8.65774547320971}, - level_t::invalid()}; - auto s = dijkstra_state{}; - auto const response = - route(w, l, from, to, 900, osr::search_profile::kCar, s); - EXPECT_TRUE(response.has_value()); } \ No newline at end of file diff --git a/test/level_test.cc b/test/level_test.cc index 620c541..b7807e4 100644 --- a/test/level_test.cc +++ b/test/level_test.cc @@ -1,3 +1,7 @@ +#ifdef _WIN32 +#include "windows.h" +#endif + #include "gtest/gtest.h" #include "osr/ways.h" @@ -5,12 +9,12 @@ using namespace osr; TEST(osr, level) { - auto const lvl_0 = to_float(to_level(0.1)); + auto const lvl_0 = to_float(to_level(0.1F)); EXPECT_EQ(0.0F, lvl_0); - auto const lvl_4 = to_float(to_level(4.0)); + auto const lvl_4 = to_float(to_level(4.0F)); EXPECT_EQ(4.0F, lvl_4); - auto const lvl_minus_3 = to_float(to_level(-3.0)); + auto const lvl_minus_3 = to_float(to_level(-3.0F)); EXPECT_EQ(-3.0F, lvl_minus_3); } \ No newline at end of file diff --git a/test/main.cc b/test/main.cc index cb0d211..39002a8 100644 --- a/test/main.cc +++ b/test/main.cc @@ -23,7 +23,7 @@ int main(int argc, char** argv) { std::cout << "executing tests in " << fs::current_path() << std::endl; } catch (std::exception const& e) { std::cout << "could not change directory to " << OSR_TEST_EXECUTION_DIR - << "\n"; + << ": " << e.what() << "\n"; return 1; }