From fbf9f9d7d3228c2b7ddb1ff87605e90d8b56a3a9 Mon Sep 17 00:00:00 2001 From: John Cater Date: Thu, 11 Mar 2021 17:22:48 -0800 Subject: [PATCH] =?UTF-8?q?Convert=20--toolchain=5Fresolution=5Fdebug=20to?= =?UTF-8?q?=20take=20a=20regex=20of=20toolchain=20typ=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit …es to debug Work towards #12110. Fixes #7713. RELNOTES: The flag `--toolchain_resolution_debug` now takes a regex argument, which is used to check which toolchain types should have debug info printed. You may use `.*` as an argument to keep the current behavior of debugging every toolchain type. Closes #13207. PiperOrigin-RevId: 362413466 --- site/docs/toolchains.md | 9 +++-- site/docs/user-manual.html | 9 +++-- .../lib/analysis/PlatformConfiguration.java | 22 ++++++++++ .../build/lib/analysis/PlatformOptions.java | 10 +++-- .../SingleToolchainResolutionFunction.java | 7 +++- .../skyframe/ToolchainResolutionFunction.java | 5 ++- .../android/AndroidBuildViewTestCase.java | 2 +- src/test/shell/bazel/bazel_java_test.sh | 6 ++- src/test/shell/bazel/bazel_with_jdk_test.sh | 40 +++++++++++++------ src/test/shell/bazel/platforms_test.sh | 6 ++- src/test/shell/bazel/toolchain_test.sh | 12 +++--- 11 files changed, 90 insertions(+), 38 deletions(-) diff --git a/site/docs/toolchains.md b/site/docs/toolchains.md index 9a767ee5a4e6ef..740c4f7a7a2116 100644 --- a/site/docs/toolchains.md +++ b/site/docs/toolchains.md @@ -431,7 +431,8 @@ independently to each version of the target. ## Debugging toolchains -When adding toolchain support to an existing rule, use the -`--toolchain_resolution_debug` flag to make toolchain resolution verbose. Bazel -will output names of toolchains it is checking and skipping during the -resolution process. +If you are adding toolchain support to an existing rule, use the +`--toolchain_resolution_debug=regex` flag. During toolchain resolution, the flag +provides verbose output for toolchain types that match the regex variable. You +can use `.*` to output all information. Bazel will output names of toolchains it +checks and skips during the resolution process. diff --git a/site/docs/user-manual.html b/site/docs/user-manual.html index a348edf2818917..21c69a7e01261e 100644 --- a/site/docs/user-manual.html +++ b/site/docs/user-manual.html @@ -1627,11 +1627,12 @@

--extra_toolchains=label register_toolchains().

-

--toolchain_resolution_debug=false

+

--toolchain_resolution_debug=regex

- Print debug information while finding toolchains for a rule. This might help - developers of Bazel or Starlark rules with debugging failures due to missing - toolchains. + Print debug information while finding toolchains if the toolchain type matches + the regex. Multiple regexes can be separated by commas. The regex can be + negated by using a - at the beginning. This might help developers + of Bazel or Starlark rules with debugging failures due to missing toolchains.

Miscellaneous

diff --git a/src/main/java/com/google/devtools/build/lib/analysis/PlatformConfiguration.java b/src/main/java/com/google/devtools/build/lib/analysis/PlatformConfiguration.java index f95800df796803..24b1483b028bde 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/PlatformConfiguration.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/PlatformConfiguration.java @@ -24,6 +24,7 @@ import com.google.devtools.build.lib.events.EventHandler; import com.google.devtools.build.lib.starlarkbuildapi.platform.PlatformConfigurationApi; import com.google.devtools.build.lib.util.RegexFilter; +import java.util.Collection; import java.util.List; import java.util.Map; @@ -36,6 +37,7 @@ public class PlatformConfiguration extends Fragment implements PlatformConfigura private final Label targetPlatform; private final ImmutableList extraToolchains; private final List>> targetFilterToAdditionalExecConstraints; + private final RegexFilter toolchainResolutionDebugRegexFilter; public PlatformConfiguration(BuildOptions buildOptions) { PlatformOptions platformOptions = buildOptions.get(PlatformOptions.class); @@ -46,6 +48,7 @@ public PlatformConfiguration(BuildOptions buildOptions) { this.extraToolchains = ImmutableList.copyOf(platformOptions.extraToolchains); this.targetFilterToAdditionalExecConstraints = platformOptions.targetFilterToAdditionalExecConstraints; + this.toolchainResolutionDebugRegexFilter = platformOptions.toolchainResolutionDebug; } @Override @@ -111,4 +114,23 @@ public List