-
Notifications
You must be signed in to change notification settings - Fork 2
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
Allow conversion of dependencies to binary targets #9
base: main
Are you sure you want to change the base?
Conversation
109439d
to
c344094
Compare
78c7c4c
to
8300885
Compare
5c3ec2e
to
c72c9ab
Compare
Sources/Core/DTOLoader.swift
Outdated
import Foundation | ||
import Yams | ||
|
||
final class DTOLoader { |
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.
or even enum
as it's only namespace
final class DTOLoader { | |
struct DTOLoader { |
) | ||
) | ||
} | ||
|
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.
both if and else has similar code
result.append(
PackageDependency(
name: dependency.name,
type: .remote(tag: dependency.version)
)
)
I would suggest to simplify:
let type = if ... {
.local(hash: versionRef)
} else {
.remote(tag: dependency.version)
}
result.append(
PackageDependency(
name: dependency.name,
type: type
)
)
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.
There is a guard in the way. This is meant to stay like this for readability.
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.
guard
I think can stay in place
let type: Type
if ... {
guard ... { throw .... }
type = .local(hash: versionRef)
} else {
type = .remote(tag: dependency.version)
}
result.append(
PackageDependency(
name: dependency.name,
type: type
)
)
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.
Pushed ac64d1d
Sources/Core/DependencyFinder.swift
Outdated
// MARK: - Helper Functions | ||
|
||
private func parseDependencies(_ dependencies: [DependencySpec], versionRefsPath: String) throws -> [PackageDependency] { | ||
var result = [PackageDependency]() |
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.
var result = [PackageDependency]() | |
var result = Set<PackageDependency>() |
and you don't need to convert it below to Set
Sources/Core/Generator.swift
Outdated
) | ||
} | ||
|
||
private var specUrl: URL |
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.
let
for properties
Sources/Core/PackageConvertor.swift
Outdated
if exclusions.contains(dependency.name) { return nil } | ||
return Spec.LocalBinaryTarget( | ||
name: dependency.name, | ||
path: "\(relativeDependenciesPath)/\(dependency.name)/\(dependency.revision)/\(dependency.name).xcframework" |
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.
you can use join
- [relativeDependenciesPath, dependency.name, ...].join()
|
||
func cachableSpec(additionalLocalBinaryTargets: [LocalBinaryTarget], exclusions: [String]) -> Spec { | ||
let products = products.map { product in | ||
if product.productType == .library { |
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.
guard?
|
||
extension URL: @retroactive Comparable { | ||
|
||
public static func < ( |
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.
imho, such a comparison is not quite unclear. would remove/replace to more descriptive sortByLenght
.... because URL("-1.0") URL("10") what do we compare here?
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 a leftover. I'll remove it.
This PR allows the creation of
Package.swift
files using binary targets instead of local or remote dependencies.This can be particularly useful when relying on cached dependencies in the form of XCFrameworks.
Quite a few changes were needed and I recommend reviewing the commit history.
PackageGenerator can now be called with a new
--dependencies-as-binary-targets
flag and some related options: