Skip to content
New issue

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

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

Already on GitHub? # to your account

Manifest source generation should encode platform versions using their symbolic forms when possible #3707

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

abertelrud
Copy link
Contributor

Manifest source generation had a FIXME to encode their symbolic forms when possible, instead of using the freeform strings. This fixes that and adds a unit test.

Motivation:

This was always something left over to fix. A client of libSwiftPM wants to make use of this to avoid spurious changes from input manifest.

rdar://82467001

…ing their symbolic forms when possible, instead of using the freeform strings. This fixes that and adds a unit test.

rdar://82467001
@abertelrud
Copy link
Contributor Author

@swift-ci please smoke test

default:
self.init(enum: platform.platformName, string: platform.version)
// Provides knowledge about what the current version of PackageDescription provides.
struct PlatformManifestRepresentation {
Copy link
Contributor

Choose a reason for hiding this comment

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

is this information not also found anywhere else? does it make sense to make it more generally available?

Copy link
Contributor Author

@abertelrud abertelrud Sep 2, 2021

Choose a reason for hiding this comment

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

Unfortunately it isn't. There is no sharing of state today between what is defined in PackageDescription and what libSwiftPM knows to be defined in PackageDescription.

There are a lot of cases where this would be useful, in particular to share the Codable struct definitions for the stuff that is gets as JSON from the PackageDescription library to SwiftPM proper. Perhaps the best way would be to be able to share source files between PackageDescription and PackageModel, and have the same types be available in both. In that case there might be some kind of a runtime CaseIterable thing that we could do here.

There's no doubt that this is a really unfortunate thing to have to have here. I hope that if we have good mechanical editing we might perhaps be able to sunset the source generation in the future, though that's not imminent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But to your point, I think perhaps we can figure out something involving a custom source path that reaches into PackageDescription and includes one of its source files where the types are defined. That would be generally useful and maybe this is a good time to spend that effort rather than add more data like this.

Copy link
Contributor

Choose a reason for hiding this comment

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

side note: today we don't allow overlapping source files between targets (but IIRC it's a restriction we have previously talked about lifting), so we would likely need to use symlinks for now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see — I thought sources allowed it and it was just targets directories that couldn't intersect (the path parameter). There seem to be some rather arbitrary rules for what can and cannot be in a target, and I think SwiftPM would do well to relax them. That's obvious a separate discussion.

I'll see what I can do with a symlink here.

var knownVersions: Set<String>
}
let platformManifestReps = [
"macos": PlatformManifestRepresentation(manifestName: "macOS", knownVersions: ["10.10", "10.11", "10.12", "10.13", "10.14", "10.15", "11", "12"]),
Copy link
Contributor

@tomerd tomerd Sep 2, 2021

Choose a reason for hiding this comment

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

nit: can use .init( instead of long form PlatformManifestRepresentation( if the array type is defined

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I actually had it that way to start with but I dislike having to add a type to the collection more than I do spelling out the type. But I can change it, I don't feel superstrongly.

@abertelrud abertelrud marked this pull request as draft September 7, 2021 16:44
@abertelrud abertelrud self-assigned this Sep 16, 2021
@abertelrud
Copy link
Contributor Author

Still need to make time to see if we can avoid repeating the set of enums that PackageDescription declares, by sharing a source file between the two targets using a symlink. Lower priority than some other PRs.

@abertelrud abertelrud added the WIP Work in progress label Sep 17, 2021
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
WIP Work in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants