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

[SR-473] Add version constants to each package #5327

Open
mxcl opened this issue Jan 5, 2016 · 15 comments
Open

[SR-473] Add version constants to each package #5327

mxcl opened this issue Jan 5, 2016 · 15 comments

Comments

@mxcl
Copy link
Contributor

mxcl commented Jan 5, 2016

Previous ID SR-473
Radar None
Original Reporter @mxcl
Type New Feature
Additional Detail from JIRA
Votes 0
Component/s Package Manager
Labels New Feature
Assignee kkoval (JIRA)
Priority Medium

md5: a3094f8613e66dbff0c75b9857d3ac66

relates to:

  • SR-12926 provide a way to get the SHA of the current package in code

Issue Description:

Every package should generate a swift file that contains two public constants:

public let url: String
public let version: (Int, Int, Int, String?)

Ideally this would be part of llbuild’s YAML so it is involved in the build graph. But it will be enough for now to just generate the file every build.

@mxcl
Copy link
Contributor Author

mxcl commented Jan 5, 2016

We should consider the namespace implications of these names.

@swift-ci
Copy link
Contributor

swift-ci commented Jan 6, 2016

Comment by Kostiantyn Koval (JIRA)

How about the "metadata" tag? Now SPM support it, should it be also included?
#64

public let version: (Int, Int, Int, String)

@mxcl
Copy link
Contributor Author

mxcl commented Jan 6, 2016

Good point. Probably `String?`. Matching the `Version` initializer.

@mxcl
Copy link
Contributor Author

mxcl commented Jan 8, 2016

Worth considering: adding the SHA too.

@ankitspd
Copy link
Member

ankitspd commented Jan 8, 2016

what should be the name of the generated swift file? <packagename>.swift can clash

some of the name spacing implications :

if a global/local is defined with name `url` or `version` it'll take precedence
if no global/local is defined and only one module is imported then `url` or `version` will default to that module
if two modules are imported then `url` or `version` will not work and <modulename>.url can be used.

@swift-ci
Copy link
Contributor

Comment by Kostiantyn Koval (JIRA)

To generate this file a package must be a git repo. How about local packages?
Does this file should be generated for a root package too, or only for dependencies packages that we fetch?

@mxcl
Copy link
Contributor Author

mxcl commented Jan 27, 2016

For the root package we can generate it if there is a Git repo there, otherwise, not.

@swift-ci
Copy link
Contributor

swift-ci commented Feb 3, 2016

Comment by Kostiantyn Koval (JIRA)

I've started initial work on it [PR-122 | #122]

@ddunbar
Copy link
Member

ddunbar commented Feb 3, 2016

Can you clarify the intent of this work?

Some projects might not want dependency version information embedded inside them. And using the embedded version information for runtime compatibility checks may not be something we really want to encourage (vs. a more explicit mechanism, e.g., real language support for it).

@mxcl
Copy link
Contributor Author

mxcl commented Feb 3, 2016

For example:

A web server product provides diagnostics when it fails to connect to its port, part of this diagnostics is a dump of the version information for the socket library it uses.

@ddunbar
Copy link
Member

ddunbar commented Apr 30, 2016

What is left here?

@swift-ci
Copy link
Contributor

Comment by Kostiantyn Koval (JIRA)

I think first would be nice to find a use-case and tune this functionality for it.

@mxcl
Copy link
Contributor Author

mxcl commented May 2, 2016

It is not yet possible to use the version constants, they are generated, but not importable.

@abertelrud
Copy link
Contributor

We need to revisit this and consider the generated version symbols to be part of the SwiftPM API (since we won't easily be able to change them in the future without breaking anything).

@swift-ci
Copy link
Contributor

Comment by Eric Blachère (JIRA)

Sorry for reviving this old topic, but is there any plan for this to happen ? Or is there currently already a way to access the version of an SPM module from the code ? We use to access the info.plist but it's not here anymore 😉 Thanks !

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants