Skip to content

Commit

Permalink
Switch to using static libs on Linux (#424)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
tustanivsky authored Oct 27, 2023
1 parent 72dedd8 commit 749c72c
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/sdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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' }}
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
4 changes: 1 addition & 3 deletions plugin-dev/Source/Sentry/Private/SentryModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
14 changes: 10 additions & 4 deletions plugin-dev/Source/Sentry/Sentry.Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions sample/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,6 @@ Plugins/*/Intermediate/*
DerivedDataCache/*

**/sentry.properties
**/*.uproject.DotSettings.user

dist
16 changes: 7 additions & 9 deletions scripts/build-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
12 changes: 10 additions & 2 deletions scripts/packaging/package-github.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 10 additions & 2 deletions scripts/packaging/package-marketplace.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 749c72c

Please sign in to comment.