Skip to content

Commit e874cef

Browse files
authored
Partially revert #6726 (#6958)
In #6726, I discovered that an issue I was fixing for macros and plugins could also apply to executables. That fix was incorrect and would drop legitimate linkage of transitive dependencies when testing executables. The logic here is pretty gnarly, so the most reasonable cause of action seems to be to revert that part of the change. resolves #6940 (cherry picked from commit 7c1cbeb)
1 parent 5d6c0cb commit e874cef

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

Sources/Build/BuildPlan.swift

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -709,11 +709,11 @@ public class BuildPlan: SPMBuildCore.BuildPlan {
709709
) {
710710
/* Prior to tools-version 5.9, we used to errorneously recursively traverse executable/plugin dependencies and statically include their
711711
targets. For compatibility reasons, we preserve that behavior for older tools-versions. */
712-
let shouldExcludeExecutablesAndPlugins: Bool
712+
let shouldExcludePlugins: Bool
713713
if let toolsVersion = self.graph.package(for: product)?.manifest.toolsVersion {
714-
shouldExcludeExecutablesAndPlugins = toolsVersion >= .v5_9
714+
shouldExcludePlugins = toolsVersion >= .v5_9
715715
} else {
716-
shouldExcludeExecutablesAndPlugins = false
716+
shouldExcludePlugins = false
717717
}
718718

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

746745
if !topLevelIsMacro && !topLevelIsTest && target.type == .macro {
747746
return []
748747
}
749-
if shouldExcludeExecutablesAndPlugins, !topLevelIsPlugin && !topLevelIsTest && target.type == .plugin {
750-
return []
751-
}
752-
if shouldExcludeExecutablesAndPlugins, !topLevelIsExecutable && topLevelIsTest && target.type == .executable {
748+
if shouldExcludePlugins, !topLevelIsPlugin && !topLevelIsTest && target.type == .plugin {
753749
return []
754750
}
755751
return target.dependencies.filter { $0.satisfies(self.buildEnvironment) }
@@ -766,7 +762,7 @@ public class BuildPlan: SPMBuildCore.BuildPlan {
766762
case .library(.automatic), .library(.static):
767763
return productDependencies
768764
case .plugin:
769-
return shouldExcludeExecutablesAndPlugins ? [] : productDependencies
765+
return shouldExcludePlugins ? [] : productDependencies
770766
case .library(.dynamic), .test, .executable, .snippet, .macro:
771767
return []
772768
}

0 commit comments

Comments
 (0)