-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Package version data #122
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
Package version data #122
Conversation
Ideally these would be targets integrated into the build yaml so they are not generated every time. However not doing it this way at first is acceptable since we don't have a good way to specify the version dependency yet. |
|
||
try fputs("public let url: String = \"\(package.url)\" \n", file) | ||
let version = package.version | ||
try fputs("public let version: (Int, Int, Int, [String], String?) = " + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would be better if tuple had named values?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aciidb0mb3r something like:
public let version: (major: Int, minor: Int, patch: Int, etc: [String], metadata: String?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think using type inference would be even better:
What do you think @aciidb0mb3r @mxcl ?
public let version: (major: Int, minor: Int, patch: Int, etc: [String], metadata: String?) = (1, 0, 1, [], "")
//vs
public let version = (1, 0, 1, [], "")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imo, it would be fine if it was just public let version = (1, 0, 1)
as this is guessable but I have no way of knowing what is last two fields in public let version = (1, 0, 1, [], "")
without seeing doc (as they'll be empty for most packages)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's Version's properties.
- prereleaseIdentifiers: [String]
- buildMetadataIdentifier: String?
They describe a version tag of a package. So we need them.
Let’s resurrect this potentially fabulous addition. |
I'm sorry for being lazy here. I'm going to update it soon |
“Lazy” is certainly not the right word. But we owe it to everyone to prod each other and keep momentum up :) |
7894638
to
44a7f4c
Compare
Hi all. I'm back :) I'm thinking of adding |
@kostiakoval an optional seems like a bad idea to me. @mxcl isn't this something that SPM intends to enforce? i'm not sure how effect a package manager could be without version numbers 😄 |
Hi @jessesquires I'm not talking about a Version you specify in your Manifest file when you describe a package, that must be specified and it's not optional. The Local packages Does it make any sense, any suggestion how make it better? |
Ah! 😊 I see. In that case, we probably do want an optional. Maybe we could rename to |
No optional, I think in the case of the root package where we can't get a version just go with The other option is |
Unless this is only being exposed to SwiftPM, which seems likely, so |
Done. Review it please. On build generate swift file for every package with Version data. public let url: String
public let version: (Int, Int, Int, [String], String?)? |
@mxcl Can you please run CI and merge it? |
aa193c8
to
9549f1d
Compare
import func libc.fclose | ||
|
||
public func generateVersionData(rootDir: String, packages: [Package]) throws { | ||
let dirPath = rootDir + "/.build/versionData/" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prefer Path.join
9549f1d
to
e218e21
Compare
@aciidb0mb3r Thanks for feedback. Your comments are fixed now 👍 |
e218e21
to
466f603
Compare
I've changed my view here. If root package version data cannot be obtained, do not generate the version swift. If it can be obtained but commits or work has been done since a version, then add a build identifier with the date. |
@mxcl Can we review and merge this PR? Some parts of it can be reused when implementing |
7773b49
to
4e4bf44
Compare
Maybe I don't understand, how would other code use them if they aren't optional? |
I think you understand: other code can't use them if they don't exist. Thus they won't exist:
I think it is reasonable for version information to not exist when it literally doesn't exist. |
K, talked with Daniel and we think:
Additional longer term considerations:
I'll let Daniel correct me if he has any corrections. Otherwise, thoughts? |
I thought we agreed for assigning Otherwise yup that matches my thoughts. One thing to note about the implementation is you will need to treat PackageVersions as a dependency of every target in the top-level project (so they can import it, potentially). |
Oh yes, sorry. You are right. I agree. |
Indeed. Though @kostiakoval it is cool if we do this part of the implementation in a separate PR. |
Can you please clarify what you mean by It's a package with We should generate 1 swift file for a root-package. That file will contain version info about root-package and it's dependencies. |
When we say root package we mean the one |
d93e2d9
to
ac83b46
Compare
ac83b46
to
b2cb148
Compare
b2cb148
to
db36292
Compare
I've addressed 5 mentioned points:
Few questions:
|
My perspective is: yes.
Yes, use the origin if possible.
I think we can be consistent and if there is no git data:
|
I'm happy to merge this if you are. |
@swift-ci Please test |
I'm implementing these changes. Will be done in 30 min |
I don't feel this is optimal solution. I've tried to fix it but found more issue. We can merge it and improve it later if you like |
We aim for more incremental development. It doesn't need to be perfect to be landed. |
Agree. Let's wait for tests first |
@mxcl Test are passing. Can we merge it. It would be easier to do smaller improvements than |
Work in Progress
This is initial commit for SR-473
We need to generate version data for every package on build.
Now it creates a new folder
versionData
inside.build
dir and creates a swift file for every package.Could you please provide any feedback for the initial implementation.
.build
dir or somewhere else?.swift
file for every Package or place all data in 1 file?ToDo: