Skip to content

Commit

Permalink
Switch to using static libs on Windows (#433)
Browse files Browse the repository at this point in the history
  • Loading branch information
tustanivsky authored Nov 6, 2023
1 parent 0832b05 commit 842e0a6
Show file tree
Hide file tree
Showing 10 changed files with 72 additions and 38 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ jobs:
uses: ./.github/workflows/sdk.yml
with:
target: Win64-Crashpad
runsOn: windows-latest
runsOn: windows-2019

windows-breakpad-sdk:
uses: ./.github/workflows/sdk.yml
with:
target: Win64-Breakpad
runsOn: windows-latest
runsOn: windows-2019

build:
needs: [android-sdk, ios-sdk, macos-sdk, linux-sdk, windows-crashpad-sdk, windows-breakpad-sdk]
Expand Down Expand Up @@ -190,6 +190,11 @@ jobs:
pip3 install -Iv ue4cli==0.0.54 ;
ue4 setroot /home/ue4/UnrealEngine '

- name: Setup C++ runtime
run: docker exec --user root unreal bash -c '
apt-get update ;
apt-get install -y libc++-dev '

- name: Download package
uses: actions/download-artifact@v3
with:
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 Windows ([#433](https://github.com/getsentry/sentry-unreal/pull/433))

### Dependencies

- Bump Java SDK (Android) from v6.32.0 to v6.33.0 ([#432](https://github.com/getsentry/sentry-unreal/pull/432))
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ The SDK complies with three latest engine versions.

- To automatically capture crashes in Windows game builds that were made using engine versions prior to UE 5.2, the [Crash Reporter has to be configured](https://docs.sentry.io/platforms/unreal/setup-crashreport/) first.

- Using UGS binaries requires tagging of files to ensure the crashpad_handler.exe and sentry.dll is present. For inclusion in build graph, you'd want something like this:
- Using UGS binaries requires tagging of files to ensure the crashpad_handler.exe is present. For inclusion in build graph, you'd want something like this:
```
<Tag Files="#EditorBinaries$(EditorPlatform)" Filter="*.target" With="#TargetReceipts"/>
<TagReceipt Files="#TargetReceipts" RuntimeDependencies="true" With="#RuntimeDependencies"/>
Expand All @@ -53,6 +53,8 @@ The SDK complies with three latest engine versions.

- Only crash events captured on Android contain the full callstack. Events that were captured manually won't have the native C++ part there.

- On Linux `sudo apt-get install libc++-dev` is required to install the required `Crashpad` dependencies.

## Development

Please see the [contribution guide](./CONTRIBUTING.md).
Expand Down
15 changes: 9 additions & 6 deletions plugin-dev/Source/Sentry/Private/SentryModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,10 @@ void FSentryModule::StartupModule()
SentrySettings);
}

#if PLATFORM_WINDOWS
const FString SentryLibName = TEXT("sentry.dll");
#elif PLATFORM_MAC
#if PLATFORM_MAC
const FString SentryLibName = TEXT("sentry.dylib");
#endif
const FString BinariesDirPath = GIsEditor ? FPaths::Combine(GetThirdPartyPath(), TEXT("bin")) : GetBinariesPath();

#if PLATFORM_WINDOWS || PLATFORM_MAC
const FString BinariesDirPath = GetBinariesPath();
FPlatformProcess::PushDllDirectory(*BinariesDirPath);
mDllHandleSentry = FPlatformProcess::GetDllHandle(*FPaths::Combine(BinariesDirPath, SentryLibName));
FPlatformProcess::PopDllDirectory(*BinariesDirPath);
Expand Down Expand Up @@ -99,6 +95,13 @@ FString FSentryModule::GetBinariesPath()
return FPaths::Combine(PluginDir, TEXT("Binaries"), FPlatformProcess::GetBinariesSubdirectory());
}

FString FSentryModule::GetThirdPartyPath()
{
const FString PluginDir = IPluginManager::Get().FindPlugin(TEXT("Sentry"))->GetBaseDir();

return FPaths::Combine(PluginDir, TEXT("Source"), TEXT("ThirdParty"), FPlatformProcess::GetBinariesSubdirectory());
}

FString FSentryModule::GetPluginVersion()
{
TSharedPtr<IPlugin> plugin = IPluginManager::Get().FindPlugin(TEXT("Sentry"));
Expand Down
5 changes: 4 additions & 1 deletion plugin-dev/Source/Sentry/Public/SentryModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,12 @@ class SENTRY_API FSentryModule : public IModuleInterface
/** Gets internal settings object to support runtime configuration changes. */
USentrySettings* GetSettings() const;

/** Gets path to plugin's binaries folder. */
/** Gets path to plugin's binaries folder for current platform. */
FString GetBinariesPath();

/** Gets path to plugin's third-party resources folder for current platform. */
FString GetThirdPartyPath();

/** Gets plugin's version. */
static FString GetPluginVersion();

Expand Down
20 changes: 15 additions & 5 deletions plugin-dev/Source/Sentry/Sentry.Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,23 +98,33 @@ public Sentry(ReadOnlyTargetRules Target) : base(Target)
PublicIncludePaths.Add(Path.Combine(WindowsThirdPartyPath, "include"));
PrivateIncludePaths.Add(Path.Combine(ModuleDirectory, "Private", "Desktop"));

RuntimeDependencies.Add(Path.Combine(PlatformBinariesPath, "sentry.dll"), Path.Combine(WindowsThirdPartyPath, "bin", "sentry.dll"));
RuntimeDependencies.Add(Path.Combine(PlatformBinariesPath, "sentry.pdb"), Path.Combine(WindowsThirdPartyPath, "bin", "sentry.pdb"));

PublicDelayLoadDLLs.Add("sentry.dll");

PublicAdditionalLibraries.Add(Path.Combine(WindowsThirdPartyPath, "lib", "sentry.lib"));

if (CrashpadExists)
{
RuntimeDependencies.Add(Path.Combine(PlatformBinariesPath, "crashpad_handler.exe"), Path.Combine(WindowsThirdPartyPath, "bin", "crashpad_handler.exe"));

PublicAdditionalLibraries.Add(Path.Combine(WindowsThirdPartyPath, "lib", "crashpad_compat.lib"));
PublicAdditionalLibraries.Add(Path.Combine(WindowsThirdPartyPath, "lib", "crashpad_compat.lib"));
PublicAdditionalLibraries.Add(Path.Combine(WindowsThirdPartyPath, "lib", "crashpad_snapshot.lib"));
PublicAdditionalLibraries.Add(Path.Combine(WindowsThirdPartyPath, "lib", "crashpad_util.lib"));
PublicAdditionalLibraries.Add(Path.Combine(WindowsThirdPartyPath, "lib", "mini_chromium.lib"));
PublicAdditionalLibraries.Add(Path.Combine(WindowsThirdPartyPath, "lib", "crashpad_client.lib"));
PublicAdditionalLibraries.Add(Path.Combine(WindowsThirdPartyPath, "lib", "crashpad_zlib.lib"));
PublicAdditionalLibraries.Add(Path.Combine(WindowsThirdPartyPath, "lib", "crashpad_getopt.lib"));
PublicAdditionalLibraries.Add(Path.Combine(WindowsThirdPartyPath, "lib", "crashpad_tools.lib"));
PublicAdditionalLibraries.Add(Path.Combine(WindowsThirdPartyPath, "lib", "crashpad_handler_lib.lib"));
}
else
{
PublicAdditionalLibraries.Add(Path.Combine(WindowsThirdPartyPath, "lib", "breakpad_client.lib"));
}

PublicSystemLibraries.Add("winhttp.lib");
PublicSystemLibraries.Add("version.lib");

PublicDefinitions.Add("USE_SENTRY_NATIVE=1");
PublicDefinitions.Add("SENTRY_BUILD_STATIC=1");
}

// Additional routine for Linux
Expand Down
10 changes: 4 additions & 6 deletions scripts/build-win64-breakpad.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@ export sentryArtifactsDestination=$2

rm -rf "${sentryArtifactsDestination}/"*

cmake -S "${sentryNativeRoot}" -B "${sentryNativeRoot}/build" -D SENTRY_BACKEND=breakpad -D SENTRY_SDK_NAME=sentry.native.unreal
cmake -G "Visual Studio 16 2019" -S "${sentryNativeRoot}" -B "${sentryNativeRoot}/build" -D SENTRY_BACKEND=breakpad -D SENTRY_SDK_NAME=sentry.native.unreal -D SENTRY_BUILD_SHARED_LIBS=OFF
cmake --build "${sentryNativeRoot}/build" --target sentry --config RelWithDebInfo --parallel
cmake --install "${sentryNativeRoot}/build" --prefix "${sentryNativeRoot}/install" --config RelWithDebInfo

mkdir "${sentryArtifactsDestination}/bin"
mkdir "${sentryArtifactsDestination}/include"
mkdir "${sentryArtifactsDestination}/lib"

cp ${sentryNativeRoot}/build/RelWithDebInfo/sentry.lib ${sentryArtifactsDestination}/lib/sentry.lib
cp ${sentryNativeRoot}/build/RelWithDebInfo/sentry.dll ${sentryArtifactsDestination}/bin/sentry.dll
cp ${sentryNativeRoot}/build/RelWithDebInfo/sentry.pdb ${sentryArtifactsDestination}/bin/sentry.pdb
cp ${sentryNativeRoot}/build/external/RelWithDebInfo/breakpad_client.lib ${sentryArtifactsDestination}/lib/breakpad_client.lib
cp ${sentryNativeRoot}/include/sentry.h ${sentryArtifactsDestination}/include/sentry.h
cp ${sentryNativeRoot}/install/lib/*.lib ${sentryArtifactsDestination}/lib
cp ${sentryNativeRoot}/install/include/sentry.h ${sentryArtifactsDestination}/include/sentry.h
13 changes: 6 additions & 7 deletions scripts/build-win64-crashpad.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@ export sentryArtifactsDestination=$2

rm -rf "${sentryArtifactsDestination}/"*

cmake -S "${sentryNativeRoot}" -B "${sentryNativeRoot}/build" -D SENTRY_BACKEND=crashpad -D SENTRY_SDK_NAME=sentry.native.unreal
cmake -G "Visual Studio 16 2019" -S "${sentryNativeRoot}" -B "${sentryNativeRoot}/build" -D SENTRY_BACKEND=crashpad -D SENTRY_SDK_NAME=sentry.native.unreal -D SENTRY_BUILD_SHARED_LIBS=OFF
cmake --build "${sentryNativeRoot}/build" --target sentry --config RelWithDebInfo --parallel
cmake --build "${sentryNativeRoot}/build" --target crashpad_handler --config Release --parallel
cmake --build "${sentryNativeRoot}/build" --target crashpad_handler --config RelWithDebInfo --parallel
cmake --install "${sentryNativeRoot}/build" --prefix "${sentryNativeRoot}/install" --config RelWithDebInfo

mkdir "${sentryArtifactsDestination}/bin"
mkdir "${sentryArtifactsDestination}/include"
mkdir "${sentryArtifactsDestination}/lib"

cp ${sentryNativeRoot}/build/RelWithDebInfo/sentry.lib ${sentryArtifactsDestination}/lib/sentry.lib
cp ${sentryNativeRoot}/build/RelWithDebInfo/sentry.dll ${sentryArtifactsDestination}/bin/sentry.dll
cp ${sentryNativeRoot}/build/RelWithDebInfo/sentry.pdb ${sentryArtifactsDestination}/bin/sentry.pdb
cp ${sentryNativeRoot}/build/crashpad_build/handler/Release/crashpad_handler.exe ${sentryArtifactsDestination}/bin/crashpad_handler.exe
cp ${sentryNativeRoot}/include/sentry.h ${sentryArtifactsDestination}/include/sentry.h
cp ${sentryNativeRoot}/install/lib/*.lib ${sentryArtifactsDestination}/lib
cp ${sentryNativeRoot}/install/bin/crashpad_handler.exe ${sentryArtifactsDestination}/bin/crashpad_handler.exe
cp ${sentryNativeRoot}/install/include/sentry.h ${sentryArtifactsDestination}/include/sentry.h
15 changes: 10 additions & 5 deletions scripts/packaging/package-github.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,6 @@ Source/ThirdParty/Mac/include/Headers/SentryUser.h
Source/ThirdParty/Mac/include/Headers/SentryUserFeedback.h
Source/ThirdParty/Win64/
Source/ThirdParty/Win64/Breakpad/
Source/ThirdParty/Win64/Breakpad/bin/
Source/ThirdParty/Win64/Breakpad/bin/sentry.dll
Source/ThirdParty/Win64/Breakpad/bin/sentry.pdb
Source/ThirdParty/Win64/Breakpad/include/
Source/ThirdParty/Win64/Breakpad/include/sentry.h
Source/ThirdParty/Win64/Breakpad/lib/
Expand All @@ -342,9 +339,17 @@ Source/ThirdParty/Win64/Breakpad/lib/sentry.lib
Source/ThirdParty/Win64/Crashpad/
Source/ThirdParty/Win64/Crashpad/bin/
Source/ThirdParty/Win64/Crashpad/bin/crashpad_handler.exe
Source/ThirdParty/Win64/Crashpad/bin/sentry.dll
Source/ThirdParty/Win64/Crashpad/bin/sentry.pdb
Source/ThirdParty/Win64/Crashpad/include/
Source/ThirdParty/Win64/Crashpad/include/sentry.h
Source/ThirdParty/Win64/Crashpad/lib/
Source/ThirdParty/Win64/Crashpad/lib/crashpad_client.lib
Source/ThirdParty/Win64/Crashpad/lib/crashpad_compat.lib
Source/ThirdParty/Win64/Crashpad/lib/crashpad_getopt.lib
Source/ThirdParty/Win64/Crashpad/lib/crashpad_handler_lib.lib
Source/ThirdParty/Win64/Crashpad/lib/crashpad_minidump.lib
Source/ThirdParty/Win64/Crashpad/lib/crashpad_snapshot.lib
Source/ThirdParty/Win64/Crashpad/lib/crashpad_tools.lib
Source/ThirdParty/Win64/Crashpad/lib/crashpad_util.lib
Source/ThirdParty/Win64/Crashpad/lib/crashpad_zlib.lib
Source/ThirdParty/Win64/Crashpad/lib/mini_chromium.lib
Source/ThirdParty/Win64/Crashpad/lib/sentry.lib
15 changes: 10 additions & 5 deletions scripts/packaging/package-marketplace.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -328,19 +328,24 @@ Source/ThirdParty/Mac/include/Headers/SentryUser.h
Source/ThirdParty/Mac/include/Headers/SentryUserFeedback.h
Source/ThirdParty/Win64/
Source/ThirdParty/Win64/Breakpad/
Source/ThirdParty/Win64/Breakpad/bin/
Source/ThirdParty/Win64/Breakpad/bin/sentry.dll
Source/ThirdParty/Win64/Breakpad/bin/sentry.pdb
Source/ThirdParty/Win64/Breakpad/include/
Source/ThirdParty/Win64/Breakpad/include/sentry.h
Source/ThirdParty/Win64/Breakpad/lib/
Source/ThirdParty/Win64/Breakpad/lib/breakpad_client.lib
Source/ThirdParty/Win64/Breakpad/lib/sentry.lib
Source/ThirdParty/Win64/Crashpad/
Source/ThirdParty/Win64/Crashpad/bin/
Source/ThirdParty/Win64/Crashpad/bin/sentry.dll
Source/ThirdParty/Win64/Crashpad/bin/sentry.pdb
Source/ThirdParty/Win64/Crashpad/include/
Source/ThirdParty/Win64/Crashpad/include/sentry.h
Source/ThirdParty/Win64/Crashpad/lib/
Source/ThirdParty/Win64/Crashpad/lib/crashpad_client.lib
Source/ThirdParty/Win64/Crashpad/lib/crashpad_compat.lib
Source/ThirdParty/Win64/Crashpad/lib/crashpad_getopt.lib
Source/ThirdParty/Win64/Crashpad/lib/crashpad_handler_lib.lib
Source/ThirdParty/Win64/Crashpad/lib/crashpad_minidump.lib
Source/ThirdParty/Win64/Crashpad/lib/crashpad_snapshot.lib
Source/ThirdParty/Win64/Crashpad/lib/crashpad_tools.lib
Source/ThirdParty/Win64/Crashpad/lib/crashpad_util.lib
Source/ThirdParty/Win64/Crashpad/lib/crashpad_zlib.lib
Source/ThirdParty/Win64/Crashpad/lib/mini_chromium.lib
Source/ThirdParty/Win64/Crashpad/lib/sentry.lib

0 comments on commit 842e0a6

Please sign in to comment.