Default GTEST_HAS_ABSL=1 since abseil is an unconditional dep (fixes #4953)#4970
Open
dokson wants to merge 1 commit into
Open
Default GTEST_HAS_ABSL=1 since abseil is an unconditional dep (fixes #4953)#4970dokson wants to merge 1 commit into
dokson wants to merge 1 commit into
Conversation
abseil-cpp is loaded unconditionally under bzlmod (via bazel_dep) and under WORKSPACE (via googletest_deps()), but GTEST_HAS_ABSL was only defined when the user passed --define absl=1. As a result, features gated on the macro (AbslStringify support, absl::flags parsing, the failure-signal handler) silently stayed off even though the abseil dependency was being pulled in. Flip the default: enable absl integration by default and let users opt out with --define absl=0. Existing scripts passing --define absl=1 keep working as a no-op. Also extract the absl deps list into a local variable to avoid duplication. Fixes google#4953
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #4953.
abseil-cppis loaded unconditionally both under bzlmod (viabazel_depinMODULE.bazel) and under WORKSPACE (viagoogletest_deps()ingoogletest_deps.bzl), butGTEST_HAS_ABSLwas only defined when the user passed--define absl=1. As a result, features gated on the macro —AbslStringifysupport ingtest-message.h/gtest-printers.h, abseil-based flag parsing, the failure-signal handler — silently stayed off even though the abseil dependency was already in the build graph.This flips the default: abseil integration is enabled by default; users can opt out with
--define absl=0.Changes (single file:
BUILD.bazel)config_setting(name = "has_absl", values = {"define": "absl=1"})withconfig_setting(name = "absl_disabled", values = {"define": "absl=0"}).select()callsites soGTEST_HAS_ABSL=1and the abseil deps are the default branch and the empty list is selected only whenabsl=0._ABSL_DEPSvariable.Backward compatibility
--define absl=1continues to be accepted (silent no-op now, since absl is enabled by default).--define absl=0is a new explicit opt-out for users who don't want the abseil integration even though the dependency is loaded.bazel_depis introduced.MODULE.bazelandgoogletest_deps.bzlare untouched.Validation
Tested locally on Windows / MSVC 14.44 with bazelisk + Bazel 9.1.0:
bazelisk build //:gtest→ success, abseil headers in inputs ofgtestcompile actions.#errorifGTEST_HAS_ABSL != 1: compiles by default → macro is set as expected.#errorifGTEST_HAS_ABSL == 1: compiles only with--define absl=0→ opt-out works.(Probe targets were used during validation only and are not part of this diff.)