Skip to content

Commit 621a8dc

Browse files
committed
[Build] Adjust computeLLBuildTargetName to attempt host destination for test products
Just like macros and plugins, tests products can also be built for the host depending on their test target(s) destinations (which are inferred based on dependencies). In order to properly support `--test-product` option we need to fallback to `host` lookup for test products just like we do for macros and plugins.
1 parent 3a2d24b commit 621a8dc

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Sources/Build/BuildOperation.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,9 +539,12 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
539539

540540
// It's possible to request a build of a macro or a plugin via `swift build`
541541
// which won't have the right destination set because it's impossible to indicate it.
542+
//
543+
// Same happens with `--test-product` - if of of the test targets references
544+
// a macro directly product and all if its targets become `host`.
542545
if product == nil && destination == .target {
543546
if let toolsProduct = graph.product(for: productName, destination: .tools),
544-
toolsProduct.type == .macro || toolsProduct.type == .plugin
547+
toolsProduct.type == .macro || toolsProduct.type == .plugin || toolsProduct.type == .test
545548
{
546549
product = toolsProduct
547550
buildParameters = self.toolsBuildParameters

0 commit comments

Comments
 (0)