Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 3 additions & 2 deletions .github/workflows/sdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ jobs:
shell: bash
run: |
if [[ "${TARGET}" == "Android" ]]; then
submodules="modules/sentry-java"
# Android needs sentry-native too — BuildAndroidSDK builds the NDK from source.
submodules="modules/sentry-java modules/sentry-native"
elif [[ "${TARGET}" == "Cocoa" ]]; then
submodules="modules/sentry-cocoa"
else
Expand Down Expand Up @@ -62,7 +63,7 @@ jobs:
# hash of package/package.json for cache busting on release builds (version bump)
path: |
package-dev/Plugins
key: sdk=${{ env.TARGET }}-${{ hashFiles('submodules-status', 'package/package.json', 'Directory.Build.targets', 'sdk-static/**', 'scripts/build-cocoa-sdk.ps1') }}
key: sdk=${{ env.TARGET }}-${{ hashFiles('submodules-status', 'package/package.json', 'Directory.Build.targets', 'build/native-sdks.targets', 'sdk-static/**', 'scripts/build-cocoa-sdk.ps1', 'scripts/build-native-ndk-local.ps1') }}

- name: Installing Linux Dependencies
if: ${{ env.TARGET == 'Linux' && steps.cache.outputs.cache-hit != 'true' }}
Expand Down
61 changes: 49 additions & 12 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,17 +148,19 @@ Builds run in Docker containers using `ghcr.io/unityci/editor` images:

### MSBuild Targets

Key targets defined in `Directory.Build.targets`:

| Target | Purpose |
| -------------------- | --------------------------------------- |
| `DownloadNativeSDKs` | Downloads prebuilt native SDKs from CI |
| `BuildAndroidSDK` | Builds Android SDK via Gradle |
| `BuildLinuxSDK` | Builds Linux SDK via CMake |
| `BuildWindowsSDK` | Builds Windows SDK via CMake (Crashpad) |
| `BuildCocoaSDK` | Downloads iOS/macOS SDKs from releases |
| `UnityEditModeTest` | Runs edit-mode unit tests |
| `UnityPlayModeTest` | Runs play-mode tests |
Key targets defined across `build/` target files:

| Target | Purpose |
| ----------------------- | ----------------------------------------------------------------------- |
| `BuildCocoaSDK` | Builds iOS + macOS SDKs via Xcode (`build/native-sdks.targets`) |
| `BuildAndroidSDK` | Builds Android SDK via Gradle (`build/native-sdks.targets`) |
| `BuildLinuxSDK` | Builds Linux SDK via CMake (`build/native-sdks.targets`) |
| `BuildWindowsSDK` | Builds Windows SDK via CMake + Crashpad (`build/native-sdks.targets`) |
| `Ensure<Platform>SDK` | Auto-bootstrap wrapper; fires from `dotnet build` when artifacts missing |
| `PublishNativeNdkLocal` | Builds and publishes `sentry-native-ndk` to `~/.m2` |
| `DownloadNativeSDKs` | Downloads prebuilt native SDKs from CI (`build/local-dev.targets`) |
| `UnityEditModeTest` | Runs edit-mode unit tests |
| `UnityPlayModeTest` | Runs play-mode tests |

### Artifact Caching

Expand Down Expand Up @@ -190,7 +192,7 @@ Key targets defined in `Directory.Build.targets`:

### Build System

Central configuration in `Directory.Build.targets` (900+ lines) and `Directory.Build.props`:
Core build configuration in `Directory.Build.props`. Build targets are split across `Directory.Build.targets` (CI-shared: `FindUnity`, Unity test/configure targets), `build/native-sdks.targets` (native SDK builders), and `build/local-dev.targets` (developer convenience targets):

```xml
<!-- Key properties -->
Expand Down Expand Up @@ -320,6 +322,41 @@ modules/
└── sentry-cocoa/ # iOS/macOS (prebuilt XCFramework)
```

### Local Android NDK Development

`BuildAndroidSDK` builds the NDK from source on every run (via `PublishNativeNdkLocal`)
and ships the resulting AAR alongside the sentry-java artifacts. Both
`modules/sentry-java` AND `modules/sentry-native` must be checked out — the target
aborts otherwise and prints the `git submodule update --init` command.

sentry-java's `dependencyResolutionManagement` block already lists `mavenLocal()`,
so Gradle resolves whatever version is declared in
`modules/sentry-java/gradle/libs.versions.toml` — falling through to Maven Central
when the version isn't found locally.

**The local build must publish a version that is NOT available on Maven Central.**
Otherwise Gradle uses the released artifact on Central (listed before `mavenLocal()`
in the repositories block) and your local changes are silently ignored.

To iterate on NDK code:

1. Bump the version in the sentry-native NDK source to something unique — e.g.
add a `-dev`, `-SNAPSHOT`, or hash suffix that doesn't exist on Maven Central.
2. Bump the matching `sentry-native-ndk` version in
`modules/sentry-java/gradle/libs.versions.toml` to the same value.
3. Run `dotnet msbuild /t:BuildAndroidSDK src/Sentry.Unity`. The target rebuilds
the NDK, publishes it to `~/.m2`, then builds sentry-java against the local
artifact.

To refresh only `~/.m2` without rebuilding the Android SDK:

```bash
dotnet msbuild /t:PublishNativeNdkLocal src/Sentry.Unity
# Purge cached Gradle artifacts (use when iterating on NDK source without
# bumping the version, so Gradle re-resolves rather than reusing its cache):
dotnet msbuild /t:PublishNativeNdkLocal src/Sentry.Unity -p:PurgeNdkCache=true
```

### Key Source Files

**Android (`src/Sentry.Unity.Android/`):**
Expand Down
Loading
Loading