From f1699e179d4b2ed0c98c4a84b7644c3933d12968 Mon Sep 17 00:00:00 2001 From: Mischan Toosarani-Hausberger Date: Wed, 20 Nov 2024 16:42:34 +0100 Subject: [PATCH 1/3] fix: DLL versioning for SDK usage as CMake subdirectory (#1086) --- CHANGELOG.md | 6 ++++++ CMakeLists.txt | 8 ++++++++ cmake/utils.cmake | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 154b2761a..094641c85 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Unreleased + +**Fixes**: + +- Fix DLL versioning for projects that add the Native SDK as a CMake subdirectory. ([#1086](https://github.com/getsentry/sentry-native/pull/1086)) + ## 0.7.14 **Features**: diff --git a/CMakeLists.txt b/CMakeLists.txt index 87ab26f5f..02e99cf96 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,6 +25,14 @@ if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR) set(SENTRY_MAIN_PROJECT ON) endif() +# We have 4 source directories: +# * `CMAKE_SOURCE_DIR`: points to the directory of the top-level CMakeLists.txt of the main project. +# * `CMAKE_CURRENT_SOURCE_DIR`: points to the directory of any CMakeLists.txt in any subdirectories. +# * `PROJECT_SOURCE_DIR`: points to the directory of any CMakeLists.txt in any subdirectories that defined a `project`. +# * `SENTRY_SOURCE_DIR`: points to the directory of this `CMakeLists.txt` independent of whether it was added as a +# subdirectory in another project or whether we access it from one of our subdirectories. +set(SENTRY_SOURCE_DIR ${PROJECT_SOURCE_DIR}) + if(NOT CMAKE_C_STANDARD) set(CMAKE_C_STANDARD 11) endif() diff --git a/cmake/utils.cmake b/cmake/utils.cmake index df3619c13..528557b67 100644 --- a/cmake/utils.cmake +++ b/cmake/utils.cmake @@ -11,7 +11,7 @@ function(sentry_add_version_resource TGT FILE_DESCRIPTION) list(GET _SENTRY_VERSION_LIST 2 SENTRY_VERSION_PATCH) # Produce the resource file with configure-time replacements - configure_file("${CMAKE_SOURCE_DIR}/sentry.rc.in" "${RESOURCE_PATH_TMP}" @ONLY) + configure_file("${SENTRY_SOURCE_DIR}/sentry.rc.in" "${RESOURCE_PATH_TMP}" @ONLY) # Replace the `ORIGINAL_FILENAME` at generate-time using the generator expression `TARGET_FILE_NAME` file(GENERATE OUTPUT ${RESOURCE_PATH} INPUT ${RESOURCE_PATH_TMP}) From ce76b361b2c25f21103e42d5f1613c14c3e6c8c4 Mon Sep 17 00:00:00 2001 From: Mischan Toosarani-Hausberger Date: Thu, 21 Nov 2024 12:54:40 +0100 Subject: [PATCH 2/3] fix: warnings in the Android NDK build (#1087) --- CMakeLists.txt | 1 + external/libunwindstack-ndk | 2 +- ndk/README.md | 66 ++++++++++++++++++------------------- src/sentry_value.c | 5 +++ 4 files changed, 40 insertions(+), 34 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 02e99cf96..e211efe1f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,7 @@ if(WIN32) else() # The Android tools ship with this ancient version, which we need to support. cmake_minimum_required (VERSION 3.10) + cmake_policy(SET CMP0077 NEW) endif() #read sentry-native version diff --git a/external/libunwindstack-ndk b/external/libunwindstack-ndk index f064cc8da..284202fb1 160000 --- a/external/libunwindstack-ndk +++ b/external/libunwindstack-ndk @@ -1 +1 @@ -Subproject commit f064cc8da606f38450ff5d345ae716ff9dab3d7c +Subproject commit 284202fb1e42dbeba6598e26ced2e1ec404eecd1 diff --git a/ndk/README.md b/ndk/README.md index 190b51251..26b270fe6 100644 --- a/ndk/README.md +++ b/ndk/README.md @@ -1,7 +1,7 @@ # Android NDK support for sentry-native | Package | Maven Central | Minimum Android API Level | Supported ABIs | -| ----------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------- | ------------------------------------------- | +|-------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------|---------------------------------------------| | `io.sentry:sentry-native-ndk` | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-native-ndk/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-native-ndk) | 19 | "x86", "armeabi-v7a", "x86_64", "arm64-v8a" | ## Resources @@ -29,46 +29,46 @@ The `ndk` project uses the Gradle build system in combination with CMake. You ca 1. Set a custom `versionName` in the `ndk/gradle.properties` file 2. Publish the package locally -```shell -cd ndk -./gradlew :sentry-native-ndk:publishToMavenLocal -``` + ```shell + cd ndk + ./gradlew :sentry-native-ndk:publishToMavenLocal + ``` 3. Consume the build in your app -``` -// usually settings.gradle -allprojects { - repositories { - mavenLocal() - } -} - -// usually app/build.gradle -android { - buildFeatures { - prefab = true - } -} - -dependencies { - implementation("io.sentry:sentry-native-ndk:") -} -``` + ``` + // usually settings.gradle + allprojects { + repositories { + mavenLocal() + } + } + + // usually app/build.gradle + android { + buildFeatures { + prefab = true + } + } + + dependencies { + implementation("io.sentry:sentry-native-ndk:") + } + ``` 4. Link the pre-built packages with your native code -```cmake -# usually app/CMakeLists.txt + ```cmake + # usually app/CMakeLists.txt -find_package(sentry-native-ndk REQUIRED CONFIG) + find_package(sentry-native-ndk REQUIRED CONFIG) -target_link_libraries( PRIVATE - ${LOG_LIB} - sentry-native-ndk::sentry-android - sentry-native-ndk::sentry -) -``` + target_link_libraries( PRIVATE + ${LOG_LIB} + sentry-native-ndk::sentry-android + sentry-native-ndk::sentry + ) + ``` ## Development diff --git a/src/sentry_value.c b/src/sentry_value.c index 4bfffbc30..1258ee818 100644 --- a/src/sentry_value.c +++ b/src/sentry_value.c @@ -9,12 +9,17 @@ #if defined(_MSC_VER) # pragma warning(push) # pragma warning(disable : 4127) // conditional expression is constant +#elif defined(__clang__) +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wstatic-in-inline" #endif #include "../vendor/mpack.h" #if defined(_MSC_VER) # pragma warning(pop) +#elif defined(__clang__) +# pragma clang diagnostic pop #endif #include "sentry_alloc.h" From a2bd91c7fe29efb9c47f6dfd680bae103b60adbd Mon Sep 17 00:00:00 2001 From: getsentry-bot Date: Thu, 21 Nov 2024 12:49:51 +0000 Subject: [PATCH 3/3] release: 0.7.15 --- CHANGELOG.md | 2 +- include/sentry.h | 2 +- ndk/gradle.properties | 2 +- tests/assertions.py | 4 ++-- tests/test_integration_http.py | 2 +- tests/win_utils.py | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 094641c85..84fe2539f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## Unreleased +## 0.7.15 **Fixes**: diff --git a/include/sentry.h b/include/sentry.h index 06d2b6909..a0150d1ef 100644 --- a/include/sentry.h +++ b/include/sentry.h @@ -30,7 +30,7 @@ extern "C" { # define SENTRY_SDK_NAME "sentry.native" # endif #endif -#define SENTRY_SDK_VERSION "0.7.14" +#define SENTRY_SDK_VERSION "0.7.15" #define SENTRY_SDK_USER_AGENT SENTRY_SDK_NAME "/" SENTRY_SDK_VERSION /* common platform detection */ diff --git a/ndk/gradle.properties b/ndk/gradle.properties index 09d308b7c..93734dcc4 100644 --- a/ndk/gradle.properties +++ b/ndk/gradle.properties @@ -10,7 +10,7 @@ android.useAndroidX=true android.defaults.buildfeatures.buildconfig=true # Release information, used for maven publishing -versionName=0.7.14 +versionName=0.7.15 # disable renderscript, it's enabled by default android.defaults.buildfeatures.renderscript=false diff --git a/tests/assertions.py b/tests/assertions.py index fee84ca4e..a60368e41 100644 --- a/tests/assertions.py +++ b/tests/assertions.py @@ -90,9 +90,9 @@ def assert_event_meta( } expected_sdk = { "name": "sentry.native", - "version": "0.7.14", + "version": "0.7.15", "packages": [ - {"name": "github:getsentry/sentry-native", "version": "0.7.14"}, + {"name": "github:getsentry/sentry-native", "version": "0.7.15"}, ], } if is_android: diff --git a/tests/test_integration_http.py b/tests/test_integration_http.py index a30a3f032..14ff794ae 100644 --- a/tests/test_integration_http.py +++ b/tests/test_integration_http.py @@ -29,7 +29,7 @@ # fmt: off auth_header = ( - "Sentry sentry_key=uiaeosnrtdy, sentry_version=7, sentry_client=sentry.native/0.7.14" + "Sentry sentry_key=uiaeosnrtdy, sentry_version=7, sentry_client=sentry.native/0.7.15" ) # fmt: on diff --git a/tests/win_utils.py b/tests/win_utils.py index ff99c663e..e1f1f5b68 100644 --- a/tests/win_utils.py +++ b/tests/win_utils.py @@ -1,7 +1,7 @@ import pathlib import win32api -sentry_version = "0.7.14" +sentry_version = "0.7.15" def check_binary_version(binary_path: pathlib.Path):