From fe36191baf9022d303704617133695260bb32d5c Mon Sep 17 00:00:00 2001 From: Lion Kortlepel Date: Thu, 19 Aug 2021 15:41:27 +0200 Subject: [PATCH] fix github actions Possible fix for sentry url not showing up in windows build possible fix for sentry, again add static_assert in attempt to fix issue with sentry use target_compile_definitions instead of add_compile_definitions --- .github/workflows/cmake-linux.yml | 2 +- .github/workflows/cmake-windows.yml | 4 +++- CMakeLists.txt | 5 ++--- src/main.cpp | 10 ++++++++-- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/.github/workflows/cmake-linux.yml b/.github/workflows/cmake-linux.yml index 3cb9d29..288e3da 100644 --- a/.github/workflows/cmake-linux.yml +++ b/.github/workflows/cmake-linux.yml @@ -29,7 +29,7 @@ jobs: working-directory: ${{github.workspace}}/build-linux env: beammp_sentry_url: ${{ secrets.BEAMMP_SECRET_SENTRY_URL }} - run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_CXX_COMPILER=g++-10 -DBEAMMP_SECRET_SENTRY_URL=$beammp_sentry_url + run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_CXX_COMPILER=g++-10 -DBEAMMP_SECRET_SENTRY_URL="$beammp_sentry_url" - name: Build working-directory: ${{github.workspace}}/build-linux diff --git a/.github/workflows/cmake-windows.yml b/.github/workflows/cmake-windows.yml index bbb4bb9..8535355 100644 --- a/.github/workflows/cmake-windows.yml +++ b/.github/workflows/cmake-windows.yml @@ -29,7 +29,9 @@ jobs: - name: Configure CMake shell: bash working-directory: ${{github.workspace}}/build-windows - run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_TOOLCHAIN_FILE='${{ runner.workspace }}/b/vcpkg/scripts/buildsystems/vcpkg.cmake' -DVCPKG_TARGET_TRIPLET=x64-windows-static + env: + beammp_sentry_url: ${{ secrets.BEAMMP_SECRET_SENTRY_URL }} + run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_TOOLCHAIN_FILE='${{ runner.workspace }}/b/vcpkg/scripts/buildsystems/vcpkg.cmake' -DVCPKG_TARGET_TRIPLET=x64-windows-static -DBEAMMP_SECRET_SENTRY_URL="$beammp_sentry_url" - name: Build working-directory: ${{github.workspace}}/build-windows diff --git a/CMakeLists.txt b/CMakeLists.txt index 2348df3..db340d6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,6 @@ cmake_minimum_required(VERSION 3.0) message(STATUS "You can find build instructions and a list of dependencies in the README at \ https://github.com/BeamMP/BeamMP-Server") -# ---- start of CXX section ----- project(BeamMP-Server DESCRIPTION "Server for BeamMP - The Multiplayer Mod for BeamNG.drive" HOMEPAGE_URL https://beammp.com @@ -84,6 +83,8 @@ add_executable(BeamMP-Server include/TPPSMonitor.h src/TPPSMonitor.cpp include/TNetwork.h src/TNetwork.cpp) +target_compile_definitions(BeamMP-Server PRIVATE SECRET_SENTRY_URL="${BEAMMP_SECRET_SENTRY_URL}") + target_include_directories(BeamMP-Server PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" "${CMAKE_CURRENT_SOURCE_DIR}/commandline") @@ -105,7 +106,6 @@ find_package(OpenSSL REQUIRED) message(STATUS "CURL IS ${CURL_LIBRARIES}") if (UNIX) - add_definitions(-DSECRET_SENTRY_URL="${BEAMMP_SECRET_SENTRY_URL}") target_link_libraries(BeamMP-Server z pthread @@ -117,7 +117,6 @@ if (UNIX) sioclient_tls sentry) elseif (WIN32) - add_definitions(/DSECRET_SENTRY_URL="${BEAMMP_SECRET_SENTRY_URL}") include(FindLua) message(STATUS "Looking for libz") find_package(ZLIB REQUIRED) diff --git a/src/main.cpp b/src/main.cpp index a04370e..888be84 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -36,6 +36,10 @@ void UnixSignalHandler(int sig) { } #endif // __unix +int constexpr length(const char* str) { + return *str ? 1 + length(str + 1) : 0; +} + // this is provided by the build system, leave empty for source builds // global, yes, this is ugly, no, it cant be done another way TSentry Sentry { SECRET_SENTRY_URL }; @@ -55,6 +59,8 @@ int main(int argc, char** argv) try { #endif // __unix setlocale(LC_ALL, "C"); + static_assert(length(SECRET_SENTRY_URL) != 0); + bool Shutdown = false; Application::RegisterShutdownHandler([&Shutdown] { Shutdown = true; }); @@ -66,9 +72,9 @@ int main(int argc, char** argv) try { Assert(!Application::IsOutdated(std::array { 2, 0, 0 }, std::array { 1, 0, 1 })); TServer Server(argc, argv); - + Application::CheckForUpdates(); - + TConfig Config; if (Config.Failed()) {