Skip to content

Commit b69620d

Browse files
fmeumcopybara-github
authored andcommitted
Fix truthiness of Sequence toolchain variables
The truthiness of sequence toolchain variables has been flipped for a long time. This became a problem in 1b7dfd8, which normalized `null`/`None` values to empty sequences and thus ended up flipping the truthiness (e.g., when consumed via `expand_if_false`). Closes #26568. PiperOrigin-RevId: 785412332 Change-Id: I12e6d668c77d9557bd5d3a07fc55646c799f5816
1 parent e2c5939 commit b69620d

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainVariables.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ public String getVariableTypeName() {
617617

618618
@Override
619619
public boolean isTruthy() {
620-
return values.isEmpty();
620+
return !values.isEmpty();
621621
}
622622

623623
@Override

src/test/java/com/google/devtools/build/lib/rules/cpp/LinkBuildVariablesTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,13 @@ public void testLibrarySearchDirectoriesAreExported() throws Exception {
115115

116116
ConfiguredTarget target = getConfiguredTarget("//x:bin");
117117
CcToolchainVariables variables = getLinkBuildVariables(target, Link.LinkTargetType.EXECUTABLE);
118+
assertThat(
119+
variables
120+
.getVariable(
121+
LinkBuildVariables.LIBRARY_SEARCH_DIRECTORIES.getVariableName(),
122+
PathMapper.NOOP)
123+
.isTruthy())
124+
.isTrue();
118125
List<String> variableValue =
119126
getSequenceVariableValue(
120127
getRuleContext(),

0 commit comments

Comments
 (0)