From 25da70f321b7017c2c11e3c28fb9937617f6fbd0 Mon Sep 17 00:00:00 2001 From: Peter Ebden Date: Wed, 6 Nov 2024 11:00:32 +0000 Subject: [PATCH] Exclude test tools during build step (#3286) * Exclude test tools in the same way as normal tools * version --- ChangeLog | 4 ++++ VERSION | 2 +- src/core/build_target.go | 14 ++++++++++++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3c229cac2..ca100d059 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Version 17.12.2 +--------------- + * Exclude test_tools from dependencies in working dir during build. + Version 17.12.1 --------------- * Ensure build env is sorted on input to config hash (#3279) diff --git a/VERSION b/VERSION index 750bc49cc..b13f99e8b 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -17.12.1 +17.12.2 diff --git a/src/core/build_target.go b/src/core/build_target.go index 2b9ea38d3..927878e43 100644 --- a/src/core/build_target.go +++ b/src/core/build_target.go @@ -1659,12 +1659,22 @@ func (target *BuildTarget) AddMaybeExportedDependency(dep BuildLabel, exported, // IsTool returns true if the given build label is a tool used by this target. func (target *BuildTarget) IsTool(tool BuildLabel) bool { - for _, t := range target.Tools { + if target.isTool(tool, target.Tools, target.namedTools) { + return true + } else if target.Test != nil && target.isTool(tool, target.Test.tools, target.Test.namedTools) { + return true + } + return false +} + +// isTool returns true if the given build label is a named or unnamed tool in the given sets. +func (target *BuildTarget) isTool(tool BuildLabel, tools []BuildInput, namedTools map[string][]BuildInput) bool { + for _, t := range tools { if label, ok := t.Label(); ok && label == tool { return true } } - for _, tools := range target.namedTools { + for _, tools := range namedTools { for _, t := range tools { if label, ok := t.Label(); ok && label == tool { return true