Skip to content

Partially revert #6726 #6954

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
Sep 29, 2023
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
14 changes: 5 additions & 9 deletions Sources/Build/BuildPlan.swift
Original file line number Diff line number Diff line change
Expand Up @@ -700,11 +700,11 @@ public class BuildPlan: SPMBuildCore.BuildPlan {
) {
/* Prior to tools-version 5.9, we used to errorneously recursively traverse executable/plugin dependencies and statically include their
targets. For compatibility reasons, we preserve that behavior for older tools-versions. */
let shouldExcludeExecutablesAndPlugins: Bool
let shouldExcludePlugins: Bool
if let toolsVersion = self.graph.package(for: product)?.manifest.toolsVersion {
shouldExcludeExecutablesAndPlugins = toolsVersion >= .v5_9
shouldExcludePlugins = toolsVersion >= .v5_9
} else {
shouldExcludeExecutablesAndPlugins = false
shouldExcludePlugins = false
}

// For test targets, we need to consider the first level of transitive dependencies since the first level is always test targets.
Expand All @@ -729,18 +729,14 @@ public class BuildPlan: SPMBuildCore.BuildPlan {
// Include all the dependencies of a target.
case .target(let target, _):
let isTopLevel = topLevelDependencies.contains(target.underlyingTarget) || product.targets.contains(target)
let topLevelIsExecutable = isTopLevel && product.type == .executable
let topLevelIsMacro = isTopLevel && product.type == .macro
let topLevelIsPlugin = isTopLevel && product.type == .plugin
let topLevelIsTest = isTopLevel && product.type == .test

if !topLevelIsMacro && !topLevelIsTest && target.type == .macro {
return []
}
if shouldExcludeExecutablesAndPlugins, !topLevelIsPlugin && !topLevelIsTest && target.type == .plugin {
return []
}
if shouldExcludeExecutablesAndPlugins, !topLevelIsExecutable && topLevelIsTest && target.type == .executable {
if shouldExcludePlugins, !topLevelIsPlugin && !topLevelIsTest && target.type == .plugin {
return []
}
return target.dependencies.filter { $0.satisfies(self.buildEnvironment) }
Expand All @@ -757,7 +753,7 @@ public class BuildPlan: SPMBuildCore.BuildPlan {
case .library(.automatic), .library(.static):
return productDependencies
case .plugin:
return shouldExcludeExecutablesAndPlugins ? [] : productDependencies
return shouldExcludePlugins ? [] : productDependencies
case .library(.dynamic), .test, .executable, .snippet, .macro:
return []
}
Expand Down