Skip to content

Commit 7c1cbeb

Browse files
authored
Partially revert #6726 (#6954)
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
1 parent ae7f863 commit 7c1cbeb

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
@@ -700,11 +700,11 @@ public class BuildPlan: SPMBuildCore.BuildPlan {
700700
) {
701701
/* Prior to tools-version 5.9, we used to errorneously recursively traverse executable/plugin dependencies and statically include their
702702
targets. For compatibility reasons, we preserve that behavior for older tools-versions. */
703-
let shouldExcludeExecutablesAndPlugins: Bool
703+
let shouldExcludePlugins: Bool
704704
if let toolsVersion = self.graph.package(for: product)?.manifest.toolsVersion {
705-
shouldExcludeExecutablesAndPlugins = toolsVersion >= .v5_9
705+
shouldExcludePlugins = toolsVersion >= .v5_9
706706
} else {
707-
shouldExcludeExecutablesAndPlugins = false
707+
shouldExcludePlugins = false
708708
}
709709

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

737736
if !topLevelIsMacro && !topLevelIsTest && target.type == .macro {
738737
return []
739738
}
740-
if shouldExcludeExecutablesAndPlugins, !topLevelIsPlugin && !topLevelIsTest && target.type == .plugin {
741-
return []
742-
}
743-
if shouldExcludeExecutablesAndPlugins, !topLevelIsExecutable && topLevelIsTest && target.type == .executable {
739+
if shouldExcludePlugins, !topLevelIsPlugin && !topLevelIsTest && target.type == .plugin {
744740
return []
745741
}
746742
return target.dependencies.filter { $0.satisfies(self.buildEnvironment) }
@@ -757,7 +753,7 @@ public class BuildPlan: SPMBuildCore.BuildPlan {
757753
case .library(.automatic), .library(.static):
758754
return productDependencies
759755
case .plugin:
760-
return shouldExcludeExecutablesAndPlugins ? [] : productDependencies
756+
return shouldExcludePlugins ? [] : productDependencies
761757
case .library(.dynamic), .test, .executable, .snippet, .macro:
762758
return []
763759
}

0 commit comments

Comments
 (0)