Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify swift_common.compile so that it returns a SwiftInfo that can be propagated by callers #1370

Conversation

brentleyjones
Copy link
Collaborator

The impetus for this change was the fact that inferred cross-import overlay providers weren't being merged into the propagated SwiftInfo, so compiling a target that directly depended on one would succeed but compiling something depending on that other target would fail.

Since provider merging was being done by the rules, not by the compile call that collected the providers, we would have had to offer a separate API for rule implementations to collect those same cross-import providers or have compile return them in some separate fashion.

However, all current callers of swift_common.compile are doing exactly the same thing: creating a new SwiftInfo that merges the returned module context with the deps SwiftInfos that it already collected and passed to compile. So, it's straightforward to just return that SwiftInfo, into which we can merge the cross-import providers. This ensures we don't drop anything on the floor and it's a major API improvement.

PiperOrigin-RevId: 500710468
(cherry picked from commit ac4375d)

… can be propagated by callers

The impetus for this change was the fact that inferred cross-import overlay providers weren't being merged into the propagated `SwiftInfo`, so compiling a target that directly depended on one would succeed but compiling something depending on that other target would fail.

Since provider merging was being done by the rules, not by the `compile` call that collected the providers, we would have had to offer a separate API for rule implementations to collect those same cross-import providers or have `compile` return them in some separate fashion.

However, all current callers of `swift_common.compile` are doing exactly the same thing: creating a new `SwiftInfo` that merges the returned module context with the deps `SwiftInfo`s that it already collected and passed to `compile`. So, it's straightforward to just return that `SwiftInfo`, into which we can merge the cross-import providers. This ensures we don't drop anything on the floor *and* it's a major API improvement.

PiperOrigin-RevId: 500710468
(cherry picked from commit ac4375d)
Signed-off-by: Brentley Jones <github@brentleyjones.com>
@brentleyjones brentleyjones enabled auto-merge (rebase) October 13, 2024 20:13
brentleyjones referenced this pull request Oct 13, 2024
… can be propagated by callers.

The impetus for this change was the fact that inferred cross-import overlay providers weren't being merged into the propagated `SwiftInfo`, so compiling a target that directly depended on one would succeed but compiling something depending on that other target would fail.

Since provider merging was being done by the rules, not by the `compile` call that collected the providers, we would have had to offer a separate API for rule implementations to collect those same cross-import providers or have `compile` return them in some separate fashion.

However, all current callers of `swift_common.compile` are doing exactly the same thing: creating a new `SwiftInfo` that merges the returned module context with the deps `SwiftInfo`s that it already collected and passed to `compile`. So, it's straightforward to just return that `SwiftInfo`, into which we can merge the cross-import providers. This ensures we don't drop anything on the floor *and* it's a major API improvement.

PiperOrigin-RevId: 500710468
@brentleyjones brentleyjones merged commit 2bf5360 into master Oct 13, 2024
14 checks passed
@brentleyjones brentleyjones deleted the bj/simplify-swift_common.compile-so-that-it-returns-a-swiftinfo-that-can-be-propagated-by-callers branch October 13, 2024 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants