Skip to content

Sever TSC/Driver dependencies if using SwiftBuild Framework #8442

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

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 26 additions & 9 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,27 @@ if ProcessInfo.processInfo.environment["SWIFTCI_INSTALL_RPATH_OS"] == "android"
*/
let autoProducts = [swiftPMProduct, swiftPMDataModelProduct]

let shoudUseSwiftBuildFramework = (ProcessInfo.processInfo.environment["SWIFTPM_SWBUILD_FRAMEWORK"] != nil)

let swiftDriverDeps: [Target.Dependency]
let swiftTSCBasicsDeps: [Target.Dependency]
let swiftToolsCoreSupportAutoDeps: [Target.Dependency]

if shoudUseSwiftBuildFramework {
swiftDriverDeps = []
swiftTSCBasicsDeps = []
swiftToolsCoreSupportAutoDeps = []
} else {
swiftDriverDeps = [
.product(name: "SwiftDriver", package: "swift-driver")
]
swiftTSCBasicsDeps = [
.product(name: "TSCBasic", package: "swift-tools-support-core"),
]
swiftToolsCoreSupportAutoDeps = [
.product(name: "SwiftToolsSupport-auto", package: "swift-tools-support-core")
]
}
let package = Package(
name: "SwiftPM",
platforms: [
Expand Down Expand Up @@ -244,9 +265,8 @@ let package = Package(
.product(name: "SwiftToolchainCSQLite", package: "swift-toolchain-sqlite", condition: .when(platforms: [.windows, .android])),
.product(name: "DequeModule", package: "swift-collections"),
.product(name: "OrderedCollections", package: "swift-collections"),
.product(name: "SwiftToolsSupport-auto", package: "swift-tools-support-core"),
.product(name: "SystemPackage", package: "swift-system"),
],
] + swiftToolsCoreSupportAutoDeps,
exclude: ["CMakeLists.txt", "Vendor/README.md"],
swiftSettings: swift6CompatibleExperimentalFeatures + [
.enableExperimentalFeature("StrictConcurrency"),
Expand Down Expand Up @@ -309,8 +329,7 @@ let package = Package(
name: "SwiftFixIt",
dependencies: [
"Basics",
.product(name: "TSCBasic", package: "swift-tools-support-core"),
] + swiftSyntaxDependencies(
] + swiftTSCBasicsDeps + swiftSyntaxDependencies(
["SwiftDiagnostics", "SwiftIDEUtils", "SwiftParser", "SwiftSyntax"]
),
exclude: ["CMakeLists.txt"],
Expand Down Expand Up @@ -474,10 +493,9 @@ let package = Package(
"PackageGraph",
"SPMBuildCore",
"SPMLLBuild",
.product(name: "SwiftDriver", package: "swift-driver"),
.product(name: "OrderedCollections", package: "swift-collections"),
"DriverSupport",
],
] + swiftDriverDeps,
exclude: ["CMakeLists.txt"],
swiftSettings: commonExperimentalFeatures + [
.unsafeFlags(["-static"]),
Expand All @@ -488,8 +506,7 @@ let package = Package(
dependencies: [
"Basics",
"PackageModel",
.product(name: "SwiftDriver", package: "swift-driver"),
],
] + swiftDriverDeps,
exclude: ["CMakeLists.txt"],
swiftSettings: commonExperimentalFeatures + [
.unsafeFlags(["-static"]),
Expand Down Expand Up @@ -1095,7 +1112,7 @@ if ProcessInfo.processInfo.environment["ENABLE_APPLE_PRODUCT_TYPES"] == "1" {
}
}

if ProcessInfo.processInfo.environment["SWIFTPM_SWBUILD_FRAMEWORK"] == nil {
if !shoudUseSwiftBuildFramework {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recovering && ProcessInfo.processInfo.environment["SWIFTPM_NO_SWBUILD_DEPENDENCY"] == nil seems to allow the previous behaviour of disabling swift-build completely from SwiftPM.

Copy link
Contributor Author

@bkhouri bkhouri Apr 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SWIFTPM_NO_SWBUILD_DEPENDENCY was a temporary workaround until we were able to properly integrate SwiftBuild in the toolchain build. I don't believe it's required anymore since #8373 was merged

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's unfortunate. It was really helpful for workflows that did not want to use SwiftBuild just yet until all the dust settled. The SwiftPM code seems prepared to work without it, and as the small modification proves, it doesn't seem really necessary for SPM to work.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That code should be dormant until we make it the default build system and that will likely take quite a while yet.


let swiftbuildsupport: Target = package.targets.first(where: { $0.name == "SwiftBuildSupport" } )!
swiftbuildsupport.dependencies += [
Expand Down