[swift-build-dev] SwiftPM PackageVersions
Kostiantyn Koval
konstantin.koval1 at gmail.com
Fri Jul 8 07:55:09 CDT 2016
> From what I understand, swiftpm will generate a module with structs of each dep with their version meta data, something like:
>
- Yes that’s right.
But there is a problem with this layout. App -> Dependency -> InnerDependency. If we generate PackageVersions as top level structs then App (a root package) would have access to an InnerDependency of its own dependency, but it shouldn’t
> And then somewhere in the package you can dump/use the version info like this:
>
- Yes, you will be able to import PackageVersions and use it.
print("\(PackageVersions.MyPackage)") // ok, own version data
But should you be able to use only your own VersionData or your dependencies as well?
If you will be able to access dependencies VersionData, then you could write code like that (which I think from Max’s comments is something we don’t want).
if PackageVersions.FirstDependency.version.major > 1 {
//do smt
}
- Kostiantyn
> On 08 Jul 2016, at 11:05, Ankit Agarwal <ankit at ankit.im> wrote:
>
> From what I understand, swiftpm will generate a module with structs of each dep with their version meta data, something like:
>
> // Module PackageVersions
>
> public struct FirstDependency {
> // meta data
> }
>
> public struct SecondDependency {
> // meta data
> }
>
> public struct MyPackage {
> // meta data
> }
> And then somewhere in the package you can dump/use the version info like this:
>
> // Somewhere in MyPackage
>
> import PackageVersions
> print("\(PackageVersions.FirstDependency)")
>
>
> Sounds good but if its only generated for root package what happens when that root package is being used as a dependency somewhere?
>
>
>
>
> On Mon, Jul 4, 2016 at 9:32 PM, Kostiantyn Koval via swift-build-dev <swift-build-dev at swift.org <mailto:swift-build-dev at swift.org>> wrote:
> Hello Swift Package Manager contributors
>
> We have been working on a PackageVersions feature and we would like to hear your feedback and ideas.
>
> Idea:
> We would like to generate Version information about package. The package would be able to import PackageVersions module and use that information.
>
> Use case:
> 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.
> Real uses case - https://github.com/IBM-Swift/Kitura/pull/352/files <https://github.com/IBM-Swift/Kitura/pull/352/files>
>
> Format:
> - url: a git origin of a package or local path if there is no git (package not published yet),
> - package version
> - version string representation
> - SHA of of a commit made after checked version
> - modified, are there any uncommitted changes to the package.
>
> public let url: String = "https://github.com/apple/swift-package-manager.git <https://github.com/apple/swift-package-manager.git>"
> public let version: (major: Int, minor: Int, patch: Int, prereleaseIdentifiers: [String], buildMetadata: String?) = (0, 2, 2, [], nil)
> public let versionString: String = "0.2.2"
> public let sha: String? = "154cf23f74efa6c596bd25f4caa5a3bd20c78c4f"
> public let modified: Bool = true
>
> Concerns and questions:
> - "We think that this should only be generated for the root-package, the rationale here is that we don't want packages writing code like if version.major > 2 as this should be a compile time language feature and Swift core are already on board with this idea.”
> - Should a package have access to own dependencies VersionData information ?
>
> You can find more information here.
> https://github.com/apple/swift-package-manager/pull/122 <https://github.com/apple/swift-package-manager/pull/122>
> https://bugs.swift.org/browse/SR-473 <https://bugs.swift.org/browse/SR-473>
>
> Looking forward for your feedback
> - Kostiantyn
>
>
>
>
>
> _______________________________________________
> swift-build-dev mailing list
> swift-build-dev at swift.org <mailto:swift-build-dev at swift.org>
> https://lists.swift.org/mailman/listinfo/swift-build-dev <https://lists.swift.org/mailman/listinfo/swift-build-dev>
>
>
>
>
> --
> Ankit
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-build-dev/attachments/20160708/04953468/attachment.html>
More information about the swift-build-dev
mailing list