PlatformFilter support for SwiftPM prebuilts.#1317
Conversation
SwiftPM Prebuilts are only supported currently for the host. For other platforms we need to be able to build from the source of the prebuilts. To model this in the PIF, we need to be able to add platform filters on dependencies to select the prebuilt targets for host and the source targets for not host. This adds an exclude flag to the PlatformFilter to signal to filter out dependencies for the given platform, as opposed to filtering in for the given platform which is the current semantics. We'll reach a point with SwiftPM that we'll need a more advanced expression model for platform filtering, but this should enable us for now with the prebuilt requirements and add support for host tools along with our current support for macros.
|
Can you add some tests for this? |
|
Definitely. That's the [WIP] part in the title :). I need to do some more manual testing as well. |
|
@swift-ci please test |
|
One more set of tests incoming. I'm working on some tests to make sure the exclusions affect the build graph like I need for prebuilts. |
|
One more tweak to the test and it'll be ready. |
|
This is ready for review. |
|
|
||
| /// Task construction tests related to prebuilts from SwiftPM. | ||
| @Suite fileprivate struct PrebuiltsTaskConstructionTests: CoreBasedTests { | ||
| @Test func prebuiltsAreHostOnly() async throws { |
There was a problem hiding this comment.
This should specify .requireSDKs(.host)
There was a problem hiding this comment.
I was wondering if I should. I'll do that.
| /// Task construction tests related to prebuilts from SwiftPM. | ||
| @Suite fileprivate struct PrebuiltsTaskConstructionTests: CoreBasedTests { | ||
| @Test func prebuiltsAreHostOnly() async throws { | ||
| let prebuiltsDir = Path.root.join("tmp").join("Test").join("prebuiltsProject").join("build").join("prebuilts") |
There was a problem hiding this comment.
We prefer to use withTemporaryDirectory for tests instead of /tmp so it gets cleaned up afterwards
There was a problem hiding this comment.
ah, you're using PseudoFS, this should be alright
There was a problem hiding this comment.
Yup. I was actually disappointed I had to use a temporary directory for the Swift SDK manifest. SwiftPM has FileSystem plumbed throughout and am able to use the InMemoryFileSystem for pretty much everything. Apparently Core does not.
|
@swift-ci please test |
SwiftPM Prebuilts are only supported currently for the host. For other platforms we need to be able to build from the source of the prebuilts. To model this in the PIF, we need to be able to add platform filters on dependencies to select the prebuilt targets for host and the source targets for not host.
This adds an exclude flag to the PlatformFilter to signal to filter out dependencies for the given platform, as opposed to filtering in for the given platform which is the current semantics.
We'll reach a point with SwiftPM that we'll need a more advanced expression model for platform filtering, but this should enable us for now with the prebuilt requirements and add support for host tools along with our current support for macros.
The matching SwiftPM PR is here. swiftlang/swift-package-manager#9905