build: gate Cocoa bindings regeneration on a stamp file - #5598
Merged
Merged
Conversation
The generated files were the target's Outputs, but Objective Sharpie writes ApiDefinition.cs before patch-cocoa-bindings.cs makes it valid C#. A parallel build sampling the timestamps in between skipped generation and compiled the unpatched output. Gate the check on a stamp touched once generation and patching are both done, so a late instance blocks on the in-flight TargetFramework=once request. The generated files stay in Outputs so a deleted one still forces regeneration. Latent until #5594 removed a non-existent glob input that had been forcing the target to run every time. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5598 +/- ##
==========================================
+ Coverage 74.81% 74.83% +0.02%
==========================================
Files 515 515
Lines 18963 18963
Branches 3694 3694
==========================================
+ Hits 14187 14191 +4
+ Misses 3894 3893 -1
+ Partials 882 879 -3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
ric-oliv
enabled auto-merge (squash)
September 18, 2026 18:05
jamescrosswell
approved these changes
Sep 20, 2026
jamescrosswell
left a comment
Collaborator
There was a problem hiding this comment.
Nice - thanks @ric-oliv !
jamescrosswell
approved these changes
Sep 20, 2026
jamescrosswell
left a comment
Collaborator
There was a problem hiding this comment.
Nice - thanks @ric-oliv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TL;DR: Objective Sharpie writes ApiDefinition.cs before patch-cocoa-bindings.cs makes it valid C#, so the generated files can't gate their own regeneration.
Problem
The macOS build fails intermittently on
mainwith invalid C# in the generatedCocoa bindings (failing run):
ApiDefinition.cs(1860,9): error CS1519: Invalid token '"In the next major version, the hint parameter will be added to "'
SentryObjCOptions.hdeclaresbeforeSendWithHint/beforeBreadcrumbWithHintwithDEPRECATED_MSG_ATTRIBUTEmessages split across adjacent ObjC string literals — legal in C,a syntax error in C#.
scripts/patch-cocoa-bindings.csjoins them back together._GenerateSentryCocoaBindingsused the generated files as itsOutputs, but they're producedin two stages: Objective Sharpie writes
ApiDefinition.cs, and the patch script makes it validC# ~20s later. The incremental check went up-to-date at the end of stage one.
Sentry.Bindings.Cocoabuilds in three configurations (the two inner TFMs plus thecross-targeting outer build). In the failing run one of them sampled the timestamps inside that
window, logged
Skipping target "_GenerateSentryCocoaBindings" because all output files are up-to-date, and compiled the unpatched output:08:34:06 sharpie finishes — unpatched ApiDefinition.cs on disk
08:34:15 other instance: "Skipping target ... up-to-date"
08:34:17 CS1519 x8
08:34:21 Patching .../ApiDefinition.cs
This was latent in the two-stage generation. It became reachable in #5594, which removed a
non-existent
Carthage/Headers/**/*.hglob fromInputs; while that phantom path was there thetarget ran every time, so every instance went through the
TargetFramework=oncerequest and wasserialised behind it.
Fix
Gate the check on a stamp touched only after generation and patching complete, so a late
instance blocks on the in-flight
TargetFramework=oncerequest instead of skipping past it. Thegenerated files stay in
Outputs, so deleting one still forces regeneration.Same pattern as
_SetGeneratedSupportDelegatesInternalbelow it, and asbuild-sentry-cocoa.sh, which writesCarthage/.built-from-shalast for this reason.Verification
Reproduced locally by adding a delay between Sharpie and the patch step and building the project
in two configurations with the second starting inside the window — identical failure, same
errors and line numbers. With the fix, the second instance waits for the generation and the build
succeeds:
11:29:31 leader _GenerateSentryCocoaBindings "Building target completely"
11:30:16 follower _GenerateSentryCocoaBindings "Building target completely" <- not skipped
11:31:04 leader generation done
11:31:04 follower _InnerGenerateSentryCocoaBindings "Previously built successfully"
obj/Sentry-CI-Build-macOS.slnfmainobj/is gitignored, so the stamp isn't committed.#skip-changelog