Skip to content

build: only regenerate Cocoa bindings when their inputs change - #5594

Merged
ric-oliv merged 4 commits into
mainfrom
build/cocoa-bindings-incremental-inputs
Sep 18, 2026
Merged

ric-oliv merged 4 commits into
mainfrom
build/cocoa-bindings-incremental-inputs

Conversation

@ric-oliv

@ric-oliv ric-oliv commented Sep 17, 2026 •

Copy link
Copy Markdown
Member

Summary

Discovered in #5583:

_GenerateSentryCocoaBindings listed Carthage/Headers/**/*.h in its Inputs.
MSBuild does not glob-expand the Inputs attribute, so that entry was treated as a literal filename, never found, and the target was out of date on every build:

    Input file ".../Carthage/Headers/**/*.h" does not exist.
    Building target "_GenerateSentryCocoaBindings" completely.

Notes

Moving the glob into an ItemGroup instead would not work as item globs are evaluated before any target runs. On a fresh clone (where _BuildCocoaSDK has not yet staged the headers) the list is empty and MSBuild skips the
target ("Skipping target ... because it has no inputs"). That would also skip dirty-check.ps1, silently disabling the CI guard against stale committed bindings.

build-sentry-cocoa.sh deletes and re-creates the Carthage/.built-from-sha stamp last, so the stamp is never older than the
headers it describes.

Verification

Verified on macOS with a wiped Carthage, regenerates and reaches dirty-check; a repeat build skips; touching each of the three remaining inputs triggers exactly one regeneration; bindings stay byte-identical across regenerations.

#skip-changelog

@ric-oliv
ric-oliv marked this pull request as ready for review September 17, 2026 11:55
@codecov

codecov Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.84%. Comparing base (e67eb03) to head (b4a266e).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5594      +/-   ##
==========================================
- Coverage   74.85%   74.84%   -0.01%     
==========================================
  Files         515      515              
  Lines       18963    18963              
  Branches     3694     3694              
==========================================
- Hits        14194    14193       -1     
- Misses       3891     3892       +1     
  Partials      878      878              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions github-actions Bot added the risk: low PR risk score: low label Sep 17, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 94e1da9. Configure here.

Comment thread src/Sentry.Bindings.Cocoa/Sentry.Bindings.Cocoa.csproj Outdated
Comment thread src/Sentry.Bindings.Cocoa/Sentry.Bindings.Cocoa.csproj
@ric-oliv
ric-oliv marked this pull request as draft September 17, 2026 12:05
@ric-oliv
ric-oliv marked this pull request as ready for review September 17, 2026 14:38
Comment on lines +20 to +21
<!-- No Carthage/Headers glob: Inputs doesn't expand wildcards, and an ItemGroup glob is empty on a fresh clone, which skips the target.
.built-from-sha is written after the headers and suffices for the checks. -->

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<!-- No Carthage/Headers glob: Inputs doesn't expand wildcards, and an ItemGroup glob is empty on a fresh clone, which skips the target.
.built-from-sha is written after the headers and suffices for the checks. -->

I think we can remove this comment. The Inputs are self explanatory and the comment is fairly cryptic (probably made sense to the LLM at the time it wrote it - possibly makes sense to us now, in the context of reviewing this PR - likely won't make sense to our future selves reading this code independent of this PR).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, and removed!

@jamescrosswell jamescrosswell left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good - I'd just remove the cryptic comment.

@ric-oliv
ric-oliv merged commit 94c3804 into main Sep 18, 2026
49 checks passed
@ric-oliv
ric-oliv deleted the build/cocoa-bindings-incremental-inputs branch September 18, 2026 07:41
ric-oliv added a commit that referenced this pull request Sep 20, 2026
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: low PR risk score: low

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants