@@ -34,8 +34,8 @@ public struct PackageReference {
3434 /// A package from a registry.
3535 case registry( PackageIdentity )
3636
37- /// A prebuilt library provided by a toolchain
38- case providedLibrary( AbsolutePath )
37+ /// A prebuilt library provided by a toolchain for a package identified by the given "origin" URL.
38+ case providedLibrary( SourceControlURL , AbsolutePath )
3939
4040 // FIXME: we should not need this once we migrate off URLs
4141 //@available(*, deprecated)
@@ -52,8 +52,8 @@ public struct PackageReference {
5252 case . registry( let identity) :
5353 // FIXME: this is a placeholder
5454 return identity. description
55- case . providedLibrary( let path ) :
56- return path . pathString
55+ case . providedLibrary( let url , _ ) :
56+ return url . absoluteString
5757 }
5858 }
5959
@@ -75,8 +75,8 @@ public struct PackageReference {
7575 return " remoteSourceControl \( url) "
7676 case . registry( let identity) :
7777 return " registry \( identity) "
78- case . providedLibrary( let path) :
79- return " library \( path) "
78+ case . providedLibrary( let url , let path) :
79+ return " provided library for \( url ) @ \( path) "
8080 }
8181 }
8282
@@ -131,8 +131,8 @@ public struct PackageReference {
131131 case . registry( let identity) :
132132 // FIXME: this is a placeholder
133133 self . deprecatedName = name ?? identity. description
134- case . providedLibrary( let path ) :
135- self . deprecatedName = name ?? PackageIdentityParser . computeDefaultName ( fromPath : path )
134+ case . providedLibrary( let url , _ ) :
135+ self . deprecatedName = name ?? PackageIdentityParser . computeDefaultName ( fromURL : url )
136136 }
137137 }
138138
@@ -161,8 +161,12 @@ public struct PackageReference {
161161 PackageReference ( identity: identity, kind: . registry( identity) )
162162 }
163163
164- public static func library( identity: PackageIdentity , path: AbsolutePath ) -> PackageReference {
165- PackageReference ( identity: identity, kind: . providedLibrary( path) )
164+ public static func providedLibrary(
165+ identity: PackageIdentity ,
166+ origin: SourceControlURL ,
167+ path: AbsolutePath
168+ ) -> PackageReference {
169+ PackageReference ( identity: identity, kind: . providedLibrary( origin, path) )
166170 }
167171}
168172
@@ -183,6 +187,11 @@ extension PackageReference: Equatable {
183187 switch ( self . kind, other. kind) {
184188 case ( . remoteSourceControl( let lurl) , . remoteSourceControl( let rurl) ) :
185189 return lurl. canonicalURL == rurl. canonicalURL
190+ case ( . remoteSourceControl( let lurl) , . providedLibrary( let rurl, _) ) ,
191+ ( . providedLibrary( let lurl, _) , . remoteSourceControl( let rurl) ) :
192+ return lurl. canonicalURL == rurl. canonicalURL
193+ case ( . providedLibrary( _, let lpath) , . providedLibrary( _, let rpath) ) :
194+ return lpath == rpath
186195 default :
187196 return true
188197 }
@@ -237,8 +246,9 @@ extension PackageReference.Kind: Encodable {
237246 case . registry:
238247 var unkeyedContainer = container. nestedUnkeyedContainer ( forKey: . registry)
239248 try unkeyedContainer. encode ( self . isRoot)
240- case . providedLibrary( let path) :
249+ case . providedLibrary( let url , let path) :
241250 var unkeyedContainer = container. nestedUnkeyedContainer ( forKey: . providedLibrary)
251+ try unkeyedContainer. encode ( url)
242252 try unkeyedContainer. encode ( path)
243253 }
244254 }
0 commit comments