-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Create an alternate SwiftPM build system called Swift Build #8271
Conversation
It was only active on macOS and Linux but not other platforms due to existing dependency complexities, and just isn't that useful overall. This will help unblock swiftlang/swift-package-manager#8271 without having to add new dependencies to the Swift Docker images.
Not a review comment, but I can't wait for this to land :D this is awesome! |
It was only active on macOS and Linux but not other platforms due to existing dependency complexities, and just isn't that useful overall. This will help unblock swiftlang/swift-package-manager#8271 without having to add new dependencies to the Swift Docker images.
It was only active on macOS and Linux but not other platforms due to existing dependency complexities, and just isn't that useful overall. This will help unblock swiftlang/swift-package-manager#8271 without having to add new dependencies to the Swift Docker images.
I just tried this out and get:
|
Never mind, had a really old version of the deps. Did a |
Build works on my Mac. A few weird warnings. Also looks like swift-test has hardcoded the location of the xctest bundle to the old scratch dir (.build) layout. Lots of work to do indeed :). Thanks @cmcgee1024. This is a great start! |
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.
I have not reviewed this extensively, however there are a few minor comments.
Xswiftc: Xswiftc, | ||
buildSystem: buildSystem | ||
) | ||
let buildArgs = getBuildSystemArgs(for: buildSystem) |
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.
issue (non-blocking): this call is not needed as the build system argument is handled in swiftArgs()
@@ -230,6 +230,8 @@ public final class XcodeBuildSystem: SPMBuildCore.BuildSystem { | |||
|
|||
throw Diagnostics.fatalError | |||
} | |||
|
|||
print("Build complete!") |
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.
question: are changes to this file necessary?
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.
Also, this should use existing logging facilities that respect -v
/-q
settings.
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.
I've converted this over to use an observability scope emit. One problem though, is that we probably want this output to be emitted in all log levels, but I don't want to indicate that it is an error.
if report { | ||
progressAnimation.complete(success: false) | ||
// FIXME: a whole range of pretty printed location, context, and fixups | ||
print("\(info.kind): \(info.location) \(info.message) \(info.fixIts)") |
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.
suggestion (possibly-blocking): Instead of a print
call, can we use the observabilityScope.emit(...)
calls?
This comment applies to everywhere we are using print
calls.
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.
I agree, we should avoid using print
and rely on existing logging facilities instead, especially since those can propagate diagnostic information like message level and location already.
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.
I've converted the print calls to observability scopes. See my note above about what to do about certain kinds of messages like "Build complete!"
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.
I am concerned by uses of print
here. We have commands like swift-run
that are supposed to only print freshly-built product's output. The rest of diagnostic messages even successful ones like "Build complete" should go to stderr, since there is an existing body of scripts and utilities that read from swift-run
invocations stdout via a pipe. Stray print
polluting such output with diagnostics will break those scripts.
@swift-ci please test |
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.
IMO removing existing expectations for cross-compilation for existing build systems is a significant regression in the test suite. I'm totally ok with merging Swift Build support if it can't cross-compile yet, but it shouldn't come at the expense of reducing the test coverage for other build systems.
This is an issue with the CI infrastructure using an old Xcode that can't handle Swift 6, which is required by the SwiftBuild code. I will ask about getting the CI updated with a newer version. |
Please test with following pull request: @swift-ci test windows |
There are a few places that check the BuildSystemProvider.Kind is Xcode to determine the build directory structure. With the upcoming Swift Build integration, which uses the "Xcode path" structure, we would need to update all instances to check the two build system provider kinds. Add an extension on the BuildSystemProvider.Kind that create a boolean variable `useXcodeBuildSystemPath`, which determines whether the build system should use the xcode path structure or not. In addition, update the code that requires a "isXcodeBuildSystemEnabled" to return this build system provider variable. This will hopefully help address swiftlang#8272 when swiftlang#8271, where it adds `case .swiftbuild: return true` to the `useXcodeBuildSystemPath`
There are a few places that check the BuildSystemProvider.Kind is Xcode to determine the build directory structure. With the upcoming Swift Build integration, which uses the "Xcode path" structure, we would need to update all instances to check the two build system provider kinds. Add an extension on the BuildSystemProvider.Kind that create a boolean variable `useXcodeBuildEngine`, which determines whether the build system should use the xcode path structure or not. In addition, update the code that requires a "isXcodeBuildSystemEnabled" to return this build system provider variable. This will hopefully help address swiftlang#8272 when swiftlang#8271, where it adds `case .swiftbuild: return true` to the `useXcodeBuildEngine`
Please test with following pull request: @swift-ci please test |
There are a few places that check the BuildSystemProvider.Kind is Xcode to determine the build directory structure. With the upcoming Swift Build integration, which uses the "Xcode path" structure, we would need to update all instances to check the two build system provider kinds. Add an extension on the BuildSystemProvider.Kind that create a boolean variable `useXcodeBuildEngine`, which determines whether the build system should use the xcode path structure or not. In addition, update the code that requires a "isXcodeBuildSystemEnabled" to return this build system provider variable. This will hopefully help address swiftlang#8272 when swiftlang#8271, where it adds `case .swiftbuild: return true` to the `useXcodeBuildEngine`
@swift-ci please test |
There are a few places that check the BuildSystemProvider.Kind is Xcode to determine the build directory structure. With the upcoming Swift Build integration, which uses the "Xcode path" structure, we would need to update all instances to check the two build system provider kinds. Add an extension on the BuildSystemProvider.Kind that create a boolean variable `useXcodeBuildEngine`, which determines whether the build system should use the xcode path structure or not. In addition, update the code that requires a "isXcodeBuildSystemEnabled" to return this build system provider variable. This will hopefully help address #8272 when #8271 is merged and added `case .swiftbuild: return true` to the `useXcodeBuildEngine ` Fixes #8272 rdar://144023142
DriverSupport needs swift-driver always independent of swift-build. |
@@ -560,7 +560,12 @@ extension ResolvedPackagesStore.ResolvedPackage { | |||
let location = mirrors.effective(for: pin.location) | |||
switch pin.kind { | |||
case .localSourceControl: | |||
packageRef = try .localSourceControl(identity: identity, path: AbsolutePath(validating: location)) | |||
// FIXME investigate why local source control packages resolve to a non-local URL location |
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.
Is this change intended to be part of the PR?
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.
This could be an artifact of one of the previous approaches to getting the CI working. I will try disable it and see if everything continues to succeed.
Package.swift
Outdated
.package(url: "https://github.com/apple/swift-crypto.git", .upToNextMinor(from: "3.0.0")), | ||
.package(url: "https://github.com/swiftlang/swift-syntax.git", branch: relatedDependenciesBranch), | ||
.package(url: "https://github.com/apple/swift-system.git", from: "1.1.1"), | ||
.package(url: "https://github.com/apple/swift-collections.git", "1.0.1" ..< "1.2.0"), | ||
.package(url: "https://github.com/apple/swift-certificates.git", "1.0.1" ..< "1.6.0"), | ||
.package(url: "https://github.com/swiftlang/swift-toolchain-sqlite.git", from: "1.0.0"), | ||
.package(url: "https://github.com/apple/swift-driver.git", branch: relatedDependenciesBranch), |
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.
This should come from swiftlang.
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.
I've basically undone this diff, so it is the same as what is currently in main
.
@swift-ci test windows |
@swift-ci test macOS |
@swift-ci build toolchain |
Add basic test coverage for the new build system for the supported platforms: Linux, macOS, and Windows. Provide basic progress reporting, and an option for "very verbose" mode so that that individual build tasks and the arguments can be inspected for correctness. Build a package with the new build system like this: swift build --build-system=swiftbuild Enable very verbose task outputs with their flags, options, and arguments: swift build --build-system=swiftbuild --vv
e069aa4
to
60b1702
Compare
@swift-ci please test |
@@ -138,6 +138,9 @@ def main() -> None: | |||
shlex.split("swift --version"), | |||
) | |||
|
|||
call( |
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.
Out of curiosity, why was this added it? Are previous CI builds impacting the current PR build?
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.
This was added because the package may have been built earlier using the bootstrap with the environment variable set to exclude swift-build as a dependency. This is one of the issues with using environment variables in packages. If you flip them then SwiftPM may not be aware of the change and produce inconsistent build results since its build graph is not obviously out of sync with the current package state.
I believe that adding this will force the package to be entirely reset, and cleaned before building it again with swift-build support.
…lang#8298) There are a few places that check the BuildSystemProvider.Kind is Xcode to determine the build directory structure. With the upcoming Swift Build integration, which uses the "Xcode path" structure, we would need to update all instances to check the two build system provider kinds. Add an extension on the BuildSystemProvider.Kind that create a boolean variable `useXcodeBuildEngine`, which determines whether the build system should use the xcode path structure or not. In addition, update the code that requires a "isXcodeBuildSystemEnabled" to return this build system provider variable. This will hopefully help address swiftlang#8272 when swiftlang#8271 is merged and added `case .swiftbuild: return true` to the `useXcodeBuildEngine ` Fixes swiftlang#8272 rdar://144023142
@swift-ci please test |
@swift-ci test Linux |
@swift-ci test Windows |
@@ -172,6 +173,7 @@ extension BuildSystemProvider.Kind { | |||
public var usesXcodeBuildEngine: Bool { | |||
switch self { | |||
case .native: return false | |||
case .swiftbuild: return false |
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.
Chore (blocking): this should return "true"
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.
SwiftBuild isn't using any Xcode or its build engine. It's unclear what this check is for.
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 variable name may be incorrect, but this is meant to determine if the underlying build engine uses the same "build output directory structure" as Xcode.
Setting this to true
will likely resolve #8272
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.
SwiftBuild doesn't use the same directory structure.
extension BuildConfiguration { | ||
public var swiftbuildName: String { | ||
switch self { | ||
case .debug: "Debug" |
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.
Question: can we have the build configuration confirm to "ConvertibleString" ?
We can fix the swift test
in a subsequent change
Add basic test coverage for the new build system for the supported platforms: Linux, macOS, and Windows. Provide basic progress reporting, and an option for "very verbose" mode so that that individual build tasks and the arguments can be inspected for correctness.
Build a package with the new build system like this:
Enable very verbose task outputs with their flags, options, and arguments: