Skip to content

adding support for custom platforms#3742

Merged
abertelrud merged 2 commits into
swiftlang:mainfrom
bflanagan-apple:eng/custom-platform
Sep 15, 2021
Merged

adding support for custom platforms#3742
abertelrud merged 2 commits into
swiftlang:mainfrom
bflanagan-apple:eng/custom-platform

Conversation

@bflanagan-apple

Copy link
Copy Markdown
Contributor

Allow Package.swift specification of minimum SDK version for unknown platforms by using new "custom" platform with platform name string, and version string.

Motivation:

Currently, platforms in SwiftPM have to always be hard-coded and we should get to a more flexible model here. As a first step, this PR adds the ability to declare custom platform deployment versions in the package manifest, which won’t be handled by SwiftPM’s own build system, but will be part of the package model, so that they can be utilized when using libSwiftPM together with another build system.

Modifications:

Added a new API, custom() to each of Platform and SupportedPlatform. Added fall back while reading manifest to create a custom platform where the platform is not recognized. Tests were added for Package Loading and Building.

Result:

From now on, anyone in the community who wishes to target a new platform for development without having to wait to add to the OSS, can do so in development by simply adding a '.custom("", "new platform version>")' to their Package.swift, and then adding the appropriate changes in their builder to recognize their new platform. They can then add the new platform and supported platform to the OSS for "official" support if the community needs/requires it.

'custom' platforms
@neonichu

Copy link
Copy Markdown
Contributor

@swift-ci please smoke test

@abertelrud

abertelrud commented Sep 14, 2021

Copy link
Copy Markdown
Contributor

Looks good; thanks for this change! One more place that would need a change in order to be complete would be in ManifestSourceGeneration.swift, where the line:

self.init(enum: platform.platformName, string: platform.version)

would change to something like:

self.init(enum: "custom", subnodes: [ .init(string: platform.platformName), .init(key: "versionString", string: platform.version) ]

to emit the right source.

@bflanagan-apple

Copy link
Copy Markdown
Contributor Author

@swift-ci please smoke test

@bflanagan-apple

Copy link
Copy Markdown
Contributor Author

@swift-ci please smoke test

1 similar comment
@abertelrud

Copy link
Copy Markdown
Contributor

@swift-ci please smoke test

@bflanagan-apple

Copy link
Copy Markdown
Contributor Author

@swift-ci please smoke test

@tomerd tomerd changed the title adding support for adding support for custom platforms Sep 15, 2021
@abertelrud abertelrud merged commit 5d3db35 into swiftlang:main Sep 15, 2021
neonichu added a commit that referenced this pull request Aug 10, 2023
In #3742, support for custom platforms was added and I think everyone understood it as supporting custom deployment targets, but it actually also added API for custom platform conditionals. Those never actually worked, though, because any platform that the platform registry doesn't know about was dropped when going from `TargetDescription` to `Target`. This fixes it and adds a unit test.

See also RevenueCat/purchases-ios#2998

rdar://113709387
neonichu added a commit that referenced this pull request Aug 11, 2023
In #3742, support for custom platforms was added and I think everyone understood it as supporting custom deployment targets, but it actually also added API for custom platform conditionals. Those never actually worked, though, because any platform that the platform registry doesn't know about was dropped when going from `TargetDescription` to `Target`. This fixes it and adds a unit test.

See also RevenueCat/purchases-ios#2998

rdar://113709387
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.

4 participants