Skip to content

Commit

Permalink
fix(spm): Ensure identifiers of packages are unique
Browse files Browse the repository at this point in the history
Previously, tuples of the form `(VCS host organization name, package
name)` have been used. However, such tuples are not guaranteed to be
unique, because the name of the VCS host is not included.

Looking at how dependencies are defined for SPM packages [1], it
becomes clear that the repository URL is actually used as the key /
identifier, not the package name (plus maybe the organization name).
Note that [1] says that "Each dependency specifies a source URL and
version requirements. The source URL is a URL accessible to the current
user that resolves to a Git repository." Furthermore, SPM allows only
one package to be present per repository, which in fact makes the
repository URL a good candidate to be used as ID.

Note that the restriction to one package per repository used to be too
restrictive in some cases which is one reason why the concept of so
called targets [1] has been introduced. However, ORT's `Spm`
integration currently works on package granularity only and does not
look at the more fine grained targets.

The approach to specifying dependencies by their repository is very
similar to the approach Go modules has taken. So, using an analog
format for the IDs of packages seems to be a better fit, which also
ensures the uniqueness of the IDs.

Note also the discussion in [2].

[1] https://www.swift.org/package-manager/
[2] package-url/purl-spec#53

Signed-off-by: Frank Viernau <[email protected]>
  • Loading branch information
fviernau committed Jan 19, 2024
1 parent 5b87095 commit 814a298
Show file tree
Hide file tree
Showing 4 changed files with 224 additions and 196 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ project:
path: "<REPLACE_PATH>"
homepage_url: "<REPLACE_URL_PROCESSED>"
packages:
- id: "SPM:apple:llbuild:9.0.8"
purl: "pkg:swift/apple/[email protected]"
- id: "SPM::github.com/apple/swift-argument-parser:0.2.0"
purl: "pkg:swift/github.com%2Fapple%[email protected]"
declared_licenses: []
declared_licenses_processed: {}
description: ""
Expand All @@ -34,16 +34,16 @@ packages:
algorithm: ""
vcs:
type: "Git"
url: "https://github.com/apple/swift-llbuild.git"
revision: "9.0.8"
url: "https://github.com/apple/swift-argument-parser.git"
revision: "eb51f949cdd0c9d88abba9ce79d37eb7ea1231d0"
path: ""
vcs_processed:
type: "Git"
url: "https://github.com/apple/swift-llbuild.git"
revision: "9.0.8"
url: "https://github.com/apple/swift-argument-parser.git"
revision: "eb51f949cdd0c9d88abba9ce79d37eb7ea1231d0"
path: ""
- id: "SPM:apple:swift-argument-parser:0.2.0"
purl: "pkg:swift/apple/[email protected]"
- id: "SPM::github.com/apple/swift-crypto:"
purl: "pkg:swift/github.com%2Fapple%2Fswift-crypto@"
declared_licenses: []
declared_licenses_processed: {}
description: ""
Expand All @@ -60,16 +60,16 @@ packages:
algorithm: ""
vcs:
type: "Git"
url: "https://github.com/apple/swift-argument-parser.git"
revision: "eb51f949cdd0c9d88abba9ce79d37eb7ea1231d0"
url: "https://github.com/apple/swift-crypto.git"
revision: ""
path: ""
vcs_processed:
type: "Git"
url: "https://github.com/apple/swift-argument-parser.git"
revision: "eb51f949cdd0c9d88abba9ce79d37eb7ea1231d0"
url: "https://github.com/apple/swift-crypto.git"
revision: ""
path: ""
- id: "SPM:apple:swift-crypto:"
purl: "pkg:swift/apple/swift-crypto@"
- id: "SPM::github.com/apple/swift-llbuild:9.0.8"
purl: "pkg:swift/github.com%2Fapple%[email protected]"
declared_licenses: []
declared_licenses_processed: {}
description: ""
Expand All @@ -86,16 +86,16 @@ packages:
algorithm: ""
vcs:
type: "Git"
url: "https://github.com/apple/swift-crypto.git"
revision: ""
url: "https://github.com/apple/swift-llbuild.git"
revision: "9.0.8"
path: ""
vcs_processed:
type: "Git"
url: "https://github.com/apple/swift-crypto.git"
revision: ""
url: "https://github.com/apple/swift-llbuild.git"
revision: "9.0.8"
path: ""
- id: "SPM:braze-inc:Appboy_iOS_SDK:branch-master"
purl: "pkg:swift/braze-inc/Appboy_iOS_SDK@branch-master"
- id: "SPM::github.com/braze-inc/braze-ios-sdk:branch-master"
purl: "pkg:swift/github.com%2Fbraze-inc%2Fbraze-ios-sdk@branch-master"
declared_licenses: []
declared_licenses_processed: {}
description: ""
Expand All @@ -120,8 +120,8 @@ packages:
url: "https://github.com/braze-inc/braze-ios-sdk.git"
revision: ""
path: ""
- id: "SPM:grpc:grpc-swift:revision-efb67a324eaf1696b50e66bc471a53690e41fbf6"
purl: "pkg:swift/grpc/grpc-swift@revision-efb67a324eaf1696b50e66bc471a53690e41fbf6"
- id: "SPM::github.com/grpc/grpc-swift:revision-efb67a324eaf1696b50e66bc471a53690e41fbf6"
purl: "pkg:swift/github.com%2Fgrpc%2Fgrpc-swift@revision-efb67a324eaf1696b50e66bc471a53690e41fbf6"
declared_licenses: []
declared_licenses_processed: {}
description: ""
Expand Down
Loading

0 comments on commit 814a298

Please sign in to comment.