Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
0695563
WIP: GRDK (Gaming.Desktop.x64)
jpnurmi Jul 11, 2025
6b101e4
cmake -G Visual Studio 17 2022 -A Gaming.Desktop.x64
jpnurmi Jul 11, 2025
764bbe9
Cache GDK
jpnurmi Jul 11, 2025
c7e9c22
Add CMakeGDKDesktop.cmake
jpnurmi Jul 11, 2025
0b321a7
add missing cache-gdk.outputs.cache-hit check
jpnurmi Jul 11, 2025
5a15eae
pass GDK_VERSION
jpnurmi Jul 11, 2025
2fec2a1
restore & save cache
jpnurmi Jul 11, 2025
afc6d3b
disable zlib
jpnurmi Jul 11, 2025
18c6016
GDK_VERSION vs. GDK_WINGET_VERSION :(
jpnurmi Jul 11, 2025
998587c
try forward slashes
jpnurmi Jul 11, 2025
80a7a3d
adapt DIRECTX_DXC_TOOL from the others
jpnurmi Jul 11, 2025
674f674
drop quotes
jpnurmi Jul 11, 2025
57a1c5d
Revert "adapt DIRECTX_DXC_TOOL from the others"
jpnurmi Jul 11, 2025
6ea7a95
DIRECTX_DXC_TOOL: drop REQUIRED
jpnurmi Jul 11, 2025
14129d3
GDK vs. XBOX
jpnurmi Jul 11, 2025
f9f8592
check cache-gdk.outputs.cache-hit
jpnurmi Jul 11, 2025
cfdea92
comment out cache
jpnurmi Jul 11, 2025
afcd2dd
dbg
jpnurmi Jul 11, 2025
17262ed
restore cache
jpnurmi Jul 11, 2025
e5513a6
fixup registry
jpnurmi Jul 11, 2025
d298015
setup gdk is win-only
jpnurmi Jul 12, 2025
0d8bf69
fix skip_test
jpnurmi Jul 12, 2025
2715d16
add SENTRY_PLATFORM_GDK
jpnurmi Jul 12, 2025
d4ccc7b
setup-gdk composite action
jpnurmi Jul 12, 2025
4f637f3
respect CMAKE_DEFINES
jpnurmi Jul 12, 2025
dacc744
setup-gdk: restore/save cache
jpnurmi Jul 12, 2025
f11ad8c
fix actions/cache/restore
jpnurmi Jul 12, 2025
a2360f7
respect CMAKE_DEFINES
jpnurmi Jul 12, 2025
adb69c2
merge gdk caches
jpnurmi Jul 13, 2025
8eba500
Update .github/actions/setup-gdk/action.yml
jpnurmi Jul 16, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/actions/setup-gdk/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Setup GDK
description: Installs Microsoft.Gaming.GDK using WinGet
inputs:
gdk-version:
description: GDK version to install (e.g. 2504.1.4046)
required: true

runs:
using: composite
steps:
- name: Restore GDK
id: cache-gdk
uses: actions/cache/restore@v4
with:
path: |
C:/Program Files (x86)/Microsoft GDK
C:/Program Files/Microsoft Visual Studio/2022/Enterprise/MSBuild/Microsoft/VC/v170/Platforms/Gaming.Desktop.x64
${{ runner.temp }}/gdk.reg
key: setup-gdk-${{ inputs.gdk-version }}

- name: Setup GDK
if: ${{ steps.cache-gdk.outputs.cache-hit == 'true' }}
shell: pwsh
run: |
reg import "$env:RUNNER_TEMP\gdk.reg"

- name: Install GDK
if: ${{ steps.cache-gdk.outputs.cache-hit != 'true' }}
shell: pwsh
env:
GDK_VERSION: ${{ inputs.gdk-version }}
run: |
winget install --accept-source-agreements --accept-package-agreements --silent --disable-interactivity --version "$env:GDK_VERSION" Microsoft.Gaming.GDK
reg export "HKLM\SOFTWARE\WOW6432Node\Microsoft\GDK" "$env:RUNNER_TEMP\gdk.reg"

- name: Cache GDK
if: ${{ steps.cache-gdk.outputs.cache-hit != 'true' }}
uses: actions/cache/save@v4
with:
path: |
C:/Program Files (x86)/Microsoft GDK
C:/Program Files/Microsoft Visual Studio/2022/Enterprise/MSBuild/Microsoft/VC/v170/Platforms/Gaming.Desktop.x64
${{ runner.temp }}/gdk.reg
key: setup-gdk-${{ inputs.gdk-version }}
12 changes: 12 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ jobs:
ANDROID_API: 35
ANDROID_NDK: 27.2.12479018
ANDROID_ARCH: x86_64
- name: Windows (Gaming.Desktop.x64)
os: windows-2025
GDK_VERSION: 2504.1.4046
CMAKE_DEFINES: -DCMAKE_TOOLCHAIN_FILE="./toolchains/xbox/grdk_toolchain.cmake" -DGDK_VERSION=250401
VS_GENERATOR_TOOLSET: GRDK

name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
Expand All @@ -163,6 +168,7 @@ jobs:
SYSTEM_VERSION_COMPAT: ${{ matrix.SYSTEM_VERSION_COMPAT }}
VS_GENERATOR_TOOLSET: ${{ matrix.VS_GENERATOR_TOOLSET }}
SYSTEM_PYTHON: ${{ matrix.SYSTEM_PYTHON }}
GDK_VERSION: ${{ matrix.GDK_VERSION }}

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -257,6 +263,12 @@ jobs:
run: bash scripts/start-android.sh
timeout-minutes: 20

- name: Setup GDK
if: ${{ runner.os == 'Windows' && env['GDK_VERSION'] }}
uses: ./.github/actions/setup-gdk
with:
gdk-version: ${{ env['GDK_VERSION'] }}

- name: Add sentry.native.test hostname
if: ${{ runner.os == 'Windows' }}
# The path is usually C:\Windows\System32\drivers\etc\hosts
Expand Down
18 changes: 12 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,16 @@ set(SENTRY_TOOLCHAINS_DIR "${CMAKE_CURRENT_LIST_DIR}/toolchains")
if ("${CMAKE_GENERATOR_PLATFORM}" STREQUAL "Gaming.Xbox.Scarlett.x64")
include("${SENTRY_TOOLCHAINS_DIR}/xbox/CMakeGDKScarlett.cmake")
set(XBOX TRUE)
set(GDK TRUE)
endif()
if ("${CMAKE_GENERATOR_PLATFORM}" STREQUAL "Gaming.Xbox.XboxOne.x64")
include("${SENTRY_TOOLCHAINS_DIR}/xbox/CMakeGDKXboxOne.cmake")
set(XBOX TRUE)
set(GDK TRUE)
endif()
if ("${CMAKE_GENERATOR_PLATFORM}" STREQUAL "Gaming.Desktop.x64")
include("${SENTRY_TOOLCHAINS_DIR}/xbox/CMakeGDKDesktop.cmake")
set(GDK TRUE)
endif()

#read sentry-native version
Expand Down Expand Up @@ -81,7 +87,7 @@ option(SENTRY_BUILD_TESTS "Build sentry-native tests" "${SENTRY_MAIN_PROJECT}")
option(SENTRY_BUILD_EXAMPLES "Build sentry-native example(s)" "${SENTRY_MAIN_PROJECT}")
option(SENTRY_BUILD_BENCHMARKS "Build sentry-native benchmarks" OFF)

if(NOT XBOX)
if(NOT GDK)
option(SENTRY_LINK_PTHREAD "Link platform threads library" ON)
if(SENTRY_LINK_PTHREAD)
set(THREADS_PREFER_PTHREAD_FLAG ON)
Expand Down Expand Up @@ -171,7 +177,7 @@ option(SENTRY_ENABLE_INSTALL "Enable sentry installation" "${SENTRY_MAIN_PROJECT
if(MSVC AND CMAKE_GENERATOR_TOOLSET MATCHES "_xp$")
message(WARNING "Crashpad is not supported for MSVC with XP toolset. Default backend was switched to 'breakpad'")
set(SENTRY_DEFAULT_BACKEND "breakpad")
elseif(MSVC AND XBOX)
elseif(MSVC AND GDK)
set(SENTRY_DEFAULT_BACKEND "breakpad")
elseif((APPLE AND NOT IOS) OR WIN32 OR LINUX)
set(SENTRY_DEFAULT_BACKEND "crashpad")
Expand Down Expand Up @@ -288,7 +294,7 @@ endfunction()
# ===== sentry library =====

add_library(sentry ${SENTRY_LIBRARY_TYPE} "${PROJECT_SOURCE_DIR}/vendor/mpack.c")
if (XBOX)
if (GDK)
set_target_properties(sentry PROPERTIES VS_USER_PROPS gdk_build.props)
endif()
target_sources(sentry PRIVATE "${PROJECT_SOURCE_DIR}/include/sentry.h")
Expand Down Expand Up @@ -383,7 +389,7 @@ if(MSVC)

# using `/Wall` is not feasible, as it spews tons of warnings from windows headers
# supress C5105, introduced in VS 16.8, which breaks on the Windows SDKs own `winbase.h` header
if (XBOX)
if (GDK)
target_compile_options(sentry PRIVATE $<BUILD_INTERFACE:/W4 /wd5105 /wd4115>)
else()
target_compile_options(sentry PRIVATE $<BUILD_INTERFACE:/W4 /wd5105>)
Expand Down Expand Up @@ -500,7 +506,7 @@ if(SENTRY_TRANSPORT_WINHTTP)
endif()

# handle platform threads library
if(NOT XBOX)
if(NOT GDK)
if(SENTRY_LINK_PTHREAD)
list(APPEND _SENTRY_PLATFORM_LIBS "Threads::Threads")
endif()
Expand Down Expand Up @@ -705,7 +711,7 @@ endif()

if(SENTRY_BUILD_EXAMPLES)
add_executable(sentry_example examples/example.c)
if(XBOX)
if(GDK)
set_target_properties(sentry_example PROPERTIES VS_USER_PROPS gdk_build.props)
endif()
target_link_libraries(sentry_example PRIVATE sentry)
Expand Down
6 changes: 5 additions & 1 deletion include/sentry.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,12 @@ extern "C" {
/* common platform detection */
#ifdef _WIN32
# define SENTRY_PLATFORM_WINDOWS
# ifdef _GAMING_XBOX
# if defined(_GAMING_XBOX)
# define SENTRY_PLATFORM_XBOX
# define SENTRY_PLATFORM_GDK
# endif
# if defined(_GAMING_DESKTOP)
# define SENTRY_PLATFORM_GDK
# endif
#elif defined(__APPLE__)
# include <TargetConditionals.h>
Expand Down
2 changes: 1 addition & 1 deletion scripts/install-zlib.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ if ($env:TEST_MINGW -eq 1) {
$NEW_CMAKE_DEFINES="CMAKE_DEFINES=${env:CMAKE_DEFINES} -DZLIB_LIBRARY=${ZLIB_BUILD_PATH}\libzlibstatic.a -DZLIB_INCLUDE_DIR=${ZLIB_BUILD_PATH} -GNinja"
}
Else {
$NEW_CMAKE_DEFINES="CMAKE_DEFINES=-DZLIB_LIBRARY=${ZLIB_BUILD_PATH}\Debug\zlibstaticd.lib -DZLIB_INCLUDE_DIR=${ZLIB_BUILD_PATH}"
$NEW_CMAKE_DEFINES="CMAKE_DEFINES=${env:CMAKE_DEFINES} -DZLIB_LIBRARY=${ZLIB_BUILD_PATH}\Debug\zlibstaticd.lib -DZLIB_INCLUDE_DIR=${ZLIB_BUILD_PATH}"
}
$NEW_CMAKE_DEFINES | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
4 changes: 4 additions & 0 deletions tests/cmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ def cmake(cwd, targets, options=None, cflags=[]):
config_cmd.append("-A x64")
config_cmd.append("-T ClangCL")

if os.environ.get("VS_GENERATOR_TOOLSET") == "GRDK":
config_cmd.append("-G Visual Studio 17 2022")
config_cmd.append("-A Gaming.Desktop.x64")

for key, value in options.items():
config_cmd.append("-D{}={}".format(key, value))
if sys.platform == "win32" and os.environ.get("TEST_X86"):
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_symbolizer.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ asserter(const sentry_frame_info_t *info, void *data)
SENTRY_TEST(symbolizer)
{
#if defined(SENTRY_PLATFORM_NX) || defined(SENTRY_PLATFORM_XBOX)
return SKIP_TEST();
SKIP_TEST();
#endif
int called = 0;
#ifdef SENTRY_PLATFORM_AIX
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_unwinder.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ find_frame(const sentry_frame_info_t *info, void *data)
SENTRY_TEST(unwinder)
{
#if defined(SENTRY_PLATFORM_NX) || defined(SENTRY_PLATFORM_XBOX)
return SKIP_TEST();
SKIP_TEST();
#endif
void *backtrace1[MAX_FRAMES] = { 0 };
size_t frame_count1 = invoke_unwinder(backtrace1);
Expand Down
40 changes: 40 additions & 0 deletions toolchains/xbox/CMakeGDKDesktop.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Adapted by Sentry from:
# https://github.com/microsoft/Xbox-GDK-Samples/blob/710f4bd9095d3796d07505249a7b383857e8a23f/Samples/Tools/CMakeExample/CMake/CMakeGDKDesktop.cmake
#
# CMakeGDKDesktop.cmake : CMake definitions for Microsoft GDK targeting PC
#
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

mark_as_advanced(CMAKE_TOOLCHAIN_FILE)

if(_GDK_DESKTOP_TOOLCHAIN_)
return()
endif()

#--- Microsoft Game Development Kit

include("${CMAKE_CURRENT_LIST_DIR}/DetectGDK.cmake")

set(CMAKE_TRY_COMPILE_PLATFORM_VARIABLES GDK_VERSION BUILD_USING_BWOI)

set(CMAKE_SYSTEM_NAME WINDOWS)
set(CMAKE_SYSTEM_VERSION 10.0)

#--- GameRuntime and Extension Libraries
include(${CMAKE_CURRENT_LIST_DIR}/GDK-targets.cmake)

message("Microsoft GDK = ${Console_SdkRoot}/${GDK_VERSION}")

#--- Tools
find_program(MAKEPKG_TOOL makepkg.exe
REQUIRED NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH NO_DEFAULT_PATH
HINTS "${Console_SdkRoot}/bin")

message("MGC Tool = ${MAKEPKG_TOOL}")

find_program(DIRECTX_DXC_TOOL dxc.exe)

message("DXC Compiler = ${DIRECTX_DXC_TOOL}")

set(_GDK_DESKTOP_TOOLCHAIN_ ON)
2 changes: 1 addition & 1 deletion toolchains/xbox/GDK-targets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ else()
endif()

if(NOT EXISTS "${Console_SdkRoot}/${GDK_VERSION}")
message(FATAL_ERROR "ERROR: Cannot locate Microsoft Game Development Kit (GDK) - ${GDK_VERSION}")
message(FATAL_ERROR "ERROR: Cannot locate Microsoft Game Development Kit (GDK) - ${GDK_VERSION} in ${Console_SdkRoot}")
endif()

#--- GameRuntime Library (for Xbox these are included in the Console_Libs variable)
Expand Down
52 changes: 52 additions & 0 deletions toolchains/xbox/grdk_toolchain.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Adapted by Sentry from:
# https://github.com/microsoft/Xbox-GDK-Samples/blob/710f4bd9095d3796d07505249a7b383857e8a23f/Samples/Tools/CMakeGDKExample/grdk_toolchain.cmake
#
# grdk_toolchain.cmake : CMake Toolchain file for Gaming.Desktop.x64
#
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

mark_as_advanced(CMAKE_TOOLCHAIN_FILE)

if(_GRDK_TOOLCHAIN_)
return()
endif()

# Microsoft Game Development Kit

include("${CMAKE_CURRENT_LIST_DIR}/DetectGDK.cmake")

set(CMAKE_TRY_COMPILE_PLATFORM_VARIABLES GDK_VERSION)

set(CMAKE_SYSTEM_NAME WINDOWS)
set(CMAKE_SYSTEM_VERSION 10.0)

set(CMAKE_GENERATOR_PLATFORM "Gaming.Desktop.x64" CACHE STRING "" FORCE)
set(CMAKE_VS_PLATFORM_NAME "Gaming.Desktop.x64" CACHE STRING "" FORCE)

# Ensure our platform toolset is x64
set(CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE "x64" CACHE STRING "" FORCE)

# Let the GDK MSBuild rules decide the WindowsTargetPlatformVersion
set(CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION "" CACHE STRING "" FORCE)

if(${CMAKE_VERSION} GREATER_EQUAL "3.30")
set(CMAKE_VS_USE_DEBUG_LIBRARIES "$<CONFIG:Debug>" CACHE STRING "" FORCE)
endif()

# Sets platform defines
set(CMAKE_CXX_FLAGS_INIT "$ENV{CFLAGS} ${CMAKE_CXX_FLAGS_INIT} -D_GAMING_DESKTOP -DWINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP" CACHE STRING "" FORCE)

# Add GDK props file
file(GENERATE OUTPUT gdk_build.props INPUT ${CMAKE_CURRENT_LIST_DIR}/gdk_build.props)

# Find DXC compiler
if(NOT GDK_DXCTool)
set(GDK_DXCTool "dxc.exe")
mark_as_advanced(GDK_DXCTool)
endif()

# The MicrosoftGame.Config file needs to be in the directory with the project to enable deploy for Gaming.Desktop.x64
#file(GENERATE OUTPUT MicrosoftGame.Config INPUT ${CMAKE_CURRENT_LIST_DIR}/MicrosoftGameConfig.mgc)

set(_GRDK_TOOLCHAIN_ ON)
Loading