-
Notifications
You must be signed in to change notification settings - Fork 440
Reference swift-syntax from CodeGeneration using path instead of HEAD checkout #1897
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
Conversation
@swift-ci Please test |
CodeGeneration/Package.swift
Outdated
.package(url: "..", revision: "HEAD") | ||
.package(path: "..") |
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.
My preference would be to move this out and then have an environment variable to control it. Then the README can just have something like "Run `SOME_ENV_VAR=1 swift ..." rather than the "change the dependency from...".
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.
The problem with environment variables is that you can’t control them when opening the project in Xcode.
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.
Maybe this is a stupid idea, but how about leaving a documentation comment in the Package.swift
file that carries the same information as the README? We could leave commented code with a dependency to the remote repository, something like this:
dependencies: [
.package(path: "..")
// .package(url: "https://github.com/apple/swift-syntax", branch: "main")
],
Yes, it's not the most elegant solution, but it's practical. Developers wouldn't have to repeatedly visit the README to copy and paste this code. Considering this is just for CodeGeneration
SwiftPM, maybe we don't need anything fancy, just something that aids in accelerating development?"
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.
Yes, I think leaving that information in CodeGeneration/Package.swift makes sense to me.
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 if we would prefer to avoid commenting code we could use an enum.
fileprivate enum SwiftSyntaxDependency {
case local
case remote
fileprivate var package: Package.Dependency {
switch self {
case .local:
return .package(url: "..", revision: "HEAD")
case .remote:
return .package(url: "https://github.com/apple/swift-syntax", branch: "main")
}
}
}
(...)
products: [
.executable(name: "generate-swiftsyntax", targets: ["generate-swiftsyntax"])
],
dependencies: [
SwiftSyntaxDependency.local.package
],
targets: [
.executableTarget(
name: "generate-swiftsyntax",
(...)
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.
The problem with environment variables is that you can’t control them when opening the project in Xcode.
That's true, but also in that case you can still edit the package directly. So I'd still prefer it, even if we keep that in the README. I like @Matejkob suggestions, but I would still control it with an environment variable rather than hardcode to local/remote.
… checkout The HEAD checkout has been causing more issues than it solved recently. I think it’s better to define `CodeGeneration` to directly reference the parent swift-syntax package and encourage developers of `CodeGeneration` to modify their local `Package.swift` to pull a version of swift-syntax from GitHub when making significant changes.
a271c3a
to
d9f2f3a
Compare
@swift-ci Please test |
The
HEAD
checkout has been causing more issues than it solved recently. I think it’s better to defineCodeGeneration
to directly reference the parent swift-syntax package and encourage developers ofCodeGeneration
to modify their localPackage.swift
to pull a version of swift-syntax from GitHub when making significant changes.