Skip to content

Commit 5749d86

Browse files
authored
[Build] Adjust computeLLBuildTargetName to attempt host destinati… (#7619)
…on for test products ### Motivation: 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. ### Modifications: - Added a fallback lookup to `computeLLBuildTargetName` ### Result: `--test-product` now supports both `host` and `target` destination products.
1 parent 3a2d24b commit 5749d86

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 one of the test targets directly references
544+
// a macro then all if its targets and the product itself 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)