From 749c72c9ab6415493cf6ec3c9041f7823b828b7e Mon Sep 17 00:00:00 2001 From: Ivan Tustanivskyi Date: Fri, 27 Oct 2023 16:03:21 +0300 Subject: [PATCH] Switch to using static libs on Linux (#424) * Switch to using `sentry-native` static libs on Linux * Fix artifacts path * Add debug message * Fix path * Fix build errors * Fix more build errors * Try another build settings for sentry-native * Fix * Fix * Fix * Fix * Fix * Fix Linux deps * Fix * Update plugin snapshot * Update gitignore * Script formatting * Update changelog --- .github/workflows/sdk.yml | 2 +- CHANGELOG.md | 4 ++++ .../Source/Sentry/Private/SentryModule.cpp | 4 +--- plugin-dev/Source/Sentry/Sentry.Build.cs | 14 ++++++++++---- sample/.gitignore | 2 ++ scripts/build-linux.sh | 16 +++++++--------- scripts/packaging/package-github.snapshot | 12 ++++++++++-- scripts/packaging/package-marketplace.snapshot | 12 ++++++++++-- 8 files changed, 45 insertions(+), 21 deletions(-) diff --git a/.github/workflows/sdk.yml b/.github/workflows/sdk.yml index e9ce8fac..b7caa822 100644 --- a/.github/workflows/sdk.yml +++ b/.github/workflows/sdk.yml @@ -47,7 +47,7 @@ jobs: if: ${{ inputs.target == 'Linux' && steps.cache.outputs.cache-hit != 'true' }} run: | sudo apt-get update - sudo apt-get install zlib1g-dev libcurl4-openssl-dev + sudo apt-get install zlib1g-dev libcurl4-openssl-dev clang libc++-dev - uses: actions/setup-java@v3 if: ${{ inputs.target == 'Android' }} diff --git a/CHANGELOG.md b/CHANGELOG.md index e004dcca..c8b1cca4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### Features + +- Switch to using static libs on Linux ([#424](https://github.com/getsentry/sentry-unreal/pull/424)) + ### Fixes - Fix invalid breadcrumbs level for Win/Linux ([#426](https://github.com/getsentry/sentry-unreal/pull/426)) diff --git a/plugin-dev/Source/Sentry/Private/SentryModule.cpp b/plugin-dev/Source/Sentry/Private/SentryModule.cpp index e4010b96..3e6d5a48 100644 --- a/plugin-dev/Source/Sentry/Private/SentryModule.cpp +++ b/plugin-dev/Source/Sentry/Private/SentryModule.cpp @@ -33,11 +33,9 @@ void FSentryModule::StartupModule() const FString SentryLibName = TEXT("sentry.dll"); #elif PLATFORM_MAC const FString SentryLibName = TEXT("sentry.dylib"); -#elif PLATFORM_LINUX - const FString SentryLibName = TEXT("libsentry.so"); #endif -#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX +#if PLATFORM_WINDOWS || PLATFORM_MAC const FString BinariesDirPath = GetBinariesPath(); FPlatformProcess::PushDllDirectory(*BinariesDirPath); mDllHandleSentry = FPlatformProcess::GetDllHandle(*FPaths::Combine(BinariesDirPath, SentryLibName)); diff --git a/plugin-dev/Source/Sentry/Sentry.Build.cs b/plugin-dev/Source/Sentry/Sentry.Build.cs index 3bd0f355..4aa9151f 100644 --- a/plugin-dev/Source/Sentry/Sentry.Build.cs +++ b/plugin-dev/Source/Sentry/Sentry.Build.cs @@ -123,14 +123,20 @@ public Sentry(ReadOnlyTargetRules Target) : base(Target) PublicIncludePaths.Add(Path.Combine(PlatformThirdPartyPath, "include")); PrivateIncludePaths.Add(Path.Combine(ModuleDirectory, "Private", "Desktop")); - RuntimeDependencies.Add(Path.Combine(PlatformBinariesPath, "libsentry.so"), Path.Combine(PlatformThirdPartyPath, "bin", "libsentry.so")); RuntimeDependencies.Add(Path.Combine(PlatformBinariesPath, "crashpad_handler"), Path.Combine(PlatformThirdPartyPath, "bin", "crashpad_handler")); - PublicRuntimeLibraryPaths.Add(PlatformBinariesPath); - - PublicAdditionalLibraries.Add(Path.Combine(PlatformBinariesPath, "libsentry.so")); + PublicAdditionalLibraries.Add(Path.Combine(PlatformThirdPartyPath, "lib", "libcrashpad_client.a")); + PublicAdditionalLibraries.Add(Path.Combine(PlatformThirdPartyPath, "lib", "libcrashpad_compat.a")); + PublicAdditionalLibraries.Add(Path.Combine(PlatformThirdPartyPath, "lib", "libcrashpad_handler_lib.a")); + PublicAdditionalLibraries.Add(Path.Combine(PlatformThirdPartyPath, "lib", "libcrashpad_minidump.a")); + PublicAdditionalLibraries.Add(Path.Combine(PlatformThirdPartyPath, "lib", "libcrashpad_snapshot.a")); + PublicAdditionalLibraries.Add(Path.Combine(PlatformThirdPartyPath, "lib", "libcrashpad_tools.a")); + PublicAdditionalLibraries.Add(Path.Combine(PlatformThirdPartyPath, "lib", "libcrashpad_util.a")); + PublicAdditionalLibraries.Add(Path.Combine(PlatformThirdPartyPath, "lib", "libmini_chromium.a")); + PublicAdditionalLibraries.Add(Path.Combine(PlatformThirdPartyPath, "lib", "libsentry.a")); PublicDefinitions.Add("USE_SENTRY_NATIVE=1"); + PublicDefinitions.Add("SENTRY_BUILD_STATIC=1"); } // Additional routine for Mac diff --git a/sample/.gitignore b/sample/.gitignore index 5929a676..f9493cdb 100644 --- a/sample/.gitignore +++ b/sample/.gitignore @@ -76,4 +76,6 @@ Plugins/*/Intermediate/* DerivedDataCache/* **/sentry.properties +**/*.uproject.DotSettings.user + dist diff --git a/scripts/build-linux.sh b/scripts/build-linux.sh index 6a923451..044bfd1c 100755 --- a/scripts/build-linux.sh +++ b/scripts/build-linux.sh @@ -6,17 +6,15 @@ export sentryArtifactsDestination=$2 rm -rf "${sentryArtifactsDestination}/"* -cmake -S "${sentryNativeRoot}" -B "${sentryNativeRoot}/build" -D SENTRY_BACKEND=crashpad -D SENTRY_TRANSPORT=none -D SENTRY_SDK_NAME=sentry.native.unreal -D CMAKE_BUILD_TYPE=RelWithDebInfo +cmake -S "${sentryNativeRoot}" -B "${sentryNativeRoot}/build" -D SENTRY_BACKEND=crashpad -D SENTRY_TRANSPORT=none -D SENTRY_SDK_NAME=sentry.native.unreal -D SENTRY_BUILD_SHARED_LIBS=OFF \ + -D CMAKE_BUILD_TYPE=RelWithDebInfo -D CMAKE_C_COMPILER=clang -D CMAKE_CXX_COMPILER="clang++" -D CMAKE_CXX_FLAGS="-stdlib=libc++" -D CMAKE_EXE_LINKER_FLAGS="-stdlib=libc++" cmake --build "${sentryNativeRoot}/build" --target sentry --parallel +cmake --install "${sentryNativeRoot}/build" --prefix "${sentryNativeRoot}/install" mkdir "${sentryArtifactsDestination}/bin" mkdir "${sentryArtifactsDestination}/include" +mkdir "${sentryArtifactsDestination}/lib" -strip -s "${sentryNativeRoot}/build/libsentry.so" -w -K sentry_[^_]* -o "${sentryArtifactsDestination}/bin/libsentry.so" -cp "${sentryNativeRoot}/build/libsentry.so" "${sentryArtifactsDestination}/bin/libsentry.dbg.so" -strip -x "${sentryNativeRoot}/build/crashpad_build/handler/crashpad_handler" -o "${sentryArtifactsDestination}/bin/crashpad_handler" -cp "${sentryNativeRoot}/include/sentry.h" "${sentryArtifactsDestination}/include/sentry.h" - -pushd ${sentryArtifactsDestination}/bin -objcopy --add-gnu-debuglink="libsentry.dbg.so" "libsentry.so" -popd +cp -r "${sentryNativeRoot}/install/lib/"*.a "${sentryArtifactsDestination}/lib" +strip -x "${sentryNativeRoot}/install/bin/crashpad_handler" -o "${sentryArtifactsDestination}/bin/crashpad_handler" +cp "${sentryNativeRoot}/install/include/sentry.h" "${sentryArtifactsDestination}/include/sentry.h" diff --git a/scripts/packaging/package-github.snapshot b/scripts/packaging/package-github.snapshot index 2d7c2a06..9b95c510 100644 --- a/scripts/packaging/package-github.snapshot +++ b/scripts/packaging/package-github.snapshot @@ -250,10 +250,18 @@ Source/ThirdParty/IOS/Sentry.framework/Sentry Source/ThirdParty/Linux/ Source/ThirdParty/Linux/bin/ Source/ThirdParty/Linux/bin/crashpad_handler -Source/ThirdParty/Linux/bin/libsentry.dbg.so -Source/ThirdParty/Linux/bin/libsentry.so Source/ThirdParty/Linux/include/ Source/ThirdParty/Linux/include/sentry.h +Source/ThirdParty/Linux/lib/ +Source/ThirdParty/Linux/lib/libcrashpad_client.a +Source/ThirdParty/Linux/lib/libcrashpad_compat.a +Source/ThirdParty/Linux/lib/libcrashpad_handler_lib.a +Source/ThirdParty/Linux/lib/libcrashpad_minidump.a +Source/ThirdParty/Linux/lib/libcrashpad_snapshot.a +Source/ThirdParty/Linux/lib/libcrashpad_tools.a +Source/ThirdParty/Linux/lib/libcrashpad_util.a +Source/ThirdParty/Linux/lib/libmini_chromium.a +Source/ThirdParty/Linux/lib/libsentry.a Source/ThirdParty/Mac/ Source/ThirdParty/Mac/bin/ Source/ThirdParty/Mac/bin/sentry.dylib diff --git a/scripts/packaging/package-marketplace.snapshot b/scripts/packaging/package-marketplace.snapshot index 8532d98d..c1b5ea85 100644 --- a/scripts/packaging/package-marketplace.snapshot +++ b/scripts/packaging/package-marketplace.snapshot @@ -247,10 +247,18 @@ Source/ThirdParty/IOS/Sentry.framework/Sentry Source/ThirdParty/Linux/ Source/ThirdParty/Linux/bin/ Source/ThirdParty/Linux/bin/crashpad_handler -Source/ThirdParty/Linux/bin/libsentry.dbg.so -Source/ThirdParty/Linux/bin/libsentry.so Source/ThirdParty/Linux/include/ Source/ThirdParty/Linux/include/sentry.h +Source/ThirdParty/Linux/lib/ +Source/ThirdParty/Linux/lib/libcrashpad_client.a +Source/ThirdParty/Linux/lib/libcrashpad_compat.a +Source/ThirdParty/Linux/lib/libcrashpad_handler_lib.a +Source/ThirdParty/Linux/lib/libcrashpad_minidump.a +Source/ThirdParty/Linux/lib/libcrashpad_snapshot.a +Source/ThirdParty/Linux/lib/libcrashpad_tools.a +Source/ThirdParty/Linux/lib/libcrashpad_util.a +Source/ThirdParty/Linux/lib/libmini_chromium.a +Source/ThirdParty/Linux/lib/libsentry.a Source/ThirdParty/Mac/ Source/ThirdParty/Mac/bin/ Source/ThirdParty/Mac/bin/sentry.dylib