Skip to content

Update Package.swift dependency #8802

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
merged 1 commit into from
Jun 12, 2025

Conversation

bkhouri
Copy link
Contributor

@bkhouri bkhouri commented Jun 11, 2025

We should avoid adding a dependency on Swift Tools Support Core in SwiftPM. If we need to, we ought to use the swiftTSCBasicsDeps and swiftToolsCoreSupportAutoDeps variables.

@bkhouri
Copy link
Contributor Author

bkhouri commented Jun 11, 2025

@swift-ci test

@bkhouri bkhouri enabled auto-merge (rebase) June 11, 2025 00:49
Copy link
Contributor

@jakepetroules jakepetroules left a comment

Choose a reason for hiding this comment

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

Oh, actually it looks like we need to conditionalize the TSC dependency in _InternalTestSupport as well.

Try these changes as well:

diff --git a/Package.swift b/Package.swift
--- a/Package.swift
+++ b/Package.swift
@@ -100,33 +100,38 @@
  automatic linking type with `-auto` suffix appended to product's name.
  */
 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]
+let swiftTSCTestSupportDeps: [Target.Dependency]
 
 if shoudUseSwiftBuildFramework {
     swiftDriverDeps = []
     swiftTSCBasicsDeps = []
     swiftToolsCoreSupportAutoDeps = []
+    swiftTSCTestSupportDeps = []
 } 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")
     ]
+    swiftTSCTestSupportDeps = [
+        .product(name: "TSCTestSupport", package: "swift-tools-support-core"),
+    ]
 }
 let package = Package(
     name: "SwiftPM",
     platforms: [
         .macOS(.v13),
         .iOS(.v17),
         .macCatalyst(.v17),
     ],
     products:
@@ -338,20 +343,19 @@
                 .unsafeFlags(["-static"]),
             ]
         ),
 
         .target(
             /** API for inspecting symbols defined in binaries */
             name: "BinarySymbols",
             dependencies: [
                 "Basics",
-                .product(name: "TSCBasic", package: "swift-tools-support-core"),
-            ],
+            ] + swiftTSCBasicsDeps,
             exclude: ["CMakeLists.txt"],
             swiftSettings: commonExperimentalFeatures + [
                 .unsafeFlags(["-static"]),
             ]
         ),
 
         // MARK: Project Model
 
         .target(
@@ -813,22 +817,21 @@
             name: "_InternalTestSupport",
             dependencies: [
                 "Basics",
                 "PackageFingerprint",
                 "PackageGraph",
                 "PackageLoading",
                 "PackageRegistry",
                 "PackageSigning",
                 "SourceControl",
-                .product(name: "TSCTestSupport", package: "swift-tools-support-core"),
                 .product(name: "OrderedCollections", package: "swift-collections"),
                 "Workspace",
-            ],
+            ] + swiftTSCTestSupportDeps,
             swiftSettings: [
                 .unsafeFlags(["-static"]),
             ]
         ),
 
         .target(
             /** Test for thread-sanitizer. */
             name: "tsan_utils",
             dependencies: [],
@@ -1090,45 +1093,53 @@
         ]
     }
     package.targets.first(where: { $0.name == "SPMLLBuild" })!.dependencies += [
         .product(name: "llbuildSwift", package: "swift-llbuild"),
     ]
 }
 
 if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil {
     package.dependencies += [
-        .package(url: "https://github.com/swiftlang/swift-tools-support-core.git", branch: relatedDependenciesBranch),
         // The 'swift-argument-parser' version declared here must match that
         // used by 'swift-driver' and 'sourcekit-lsp'. Please coordinate
         // dependency version changes here with those projects.
         .package(url: "https://github.com/apple/swift-argument-parser.git", .upToNextMinor(from: "1.4.0")),
-        .package(url: "https://github.com/swiftlang/swift-driver.git", branch: relatedDependenciesBranch),
         .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"),
         // For use in previewing documentation
         .package(url: "https://github.com/swiftlang/swift-docc-plugin", from: "1.1.0"),
     ]
+    if !swiftDriverDeps.isEmpty {
+        package.dependencies += [
+            .package(url: "https://github.com/swiftlang/swift-tools-support-core.git", branch: relatedDependenciesBranch),
+            .package(url: "https://github.com/swiftlang/swift-driver.git", branch: relatedDependenciesBranch),
+        ]
+    }
 } else {
     package.dependencies += [
-        .package(path: "../swift-tools-support-core"),
         .package(path: "../swift-argument-parser"),
-        .package(path: "../swift-driver"),
         .package(path: "../swift-crypto"),
         .package(path: "../swift-syntax"),
         .package(path: "../swift-system"),
         .package(path: "../swift-collections"),
         .package(path: "../swift-certificates"),
         .package(path: "../swift-toolchain-sqlite"),
     ]
+    if !swiftDriverDeps.isEmpty {
+        package.dependencies += [
+            .package(path: "../swift-tools-support-core"),
+            .package(path: "../swift-driver"),
+        ]
+    }
 }
 
 /// If ENABLE_APPLE_PRODUCT_TYPES is set in the environment, then also define ENABLE_APPLE_PRODUCT_TYPES in each of the regular targets and test targets.
 if ProcessInfo.processInfo.environment["ENABLE_APPLE_PRODUCT_TYPES"] == "1" {
     for target in package.targets.filter({ $0.type == .regular || $0.type == .test }) {
         target.swiftSettings = (target.swiftSettings ?? []) + [ .define("ENABLE_APPLE_PRODUCT_TYPES") ]
     }
 }

We should avoid adding a dependency on Swift Tools Support Core in
SwiftPM.  If we need to, we ought to use the `swiftTSCBasicsDeps` and
`swiftToolsCoreSupportAutoDeps` variables.
@bkhouri bkhouri force-pushed the t/main/update-stsc_dependency branch from 775cbd7 to e997fab Compare June 11, 2025 18:19
@bkhouri
Copy link
Contributor Author

bkhouri commented Jun 11, 2025

@swift-ci test

@bkhouri bkhouri requested a review from jakepetroules June 11, 2025 18:19
@bkhouri
Copy link
Contributor Author

bkhouri commented Jun 11, 2025

@swift-ci test windows

@bkhouri bkhouri merged commit 20826c2 into swiftlang:main Jun 12, 2025
6 checks passed
@bkhouri bkhouri deleted the t/main/update-stsc_dependency branch June 12, 2025 00:55
bkhouri added a commit that referenced this pull request Jul 9, 2025
When the Integration Tests were merged with the Tests (#8223), the
`Package.swift` added dependencies on Swift Tools Support Core. However,
the declaration did not take into account when the
SWIFTPM_SWBUILD_FRAMEWORK environment variable was defined, which was
updated in #8442 and #8802.

Update the declaration of any Swift Tools Support Core dependencies to
use the respective local variables.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants