Enable --incompatible_merge_genfiles_directory by default.
Tested: https://buildkite.com/bazel/bazelisk-plus-incompatible-flags/builds/48
Fixes https://github.com/bazelbuild/bazel/issues/6761
RELNOTES:
Flag --incompatible_merge_genfiles_directory is flipped. This removes the directory `bazel-genfiles` in favor of `bazel-bin`.
PiperOrigin-RevId: 240168524
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfiguration.java b/src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfiguration.java
index 06513ac..5f1bf47 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfiguration.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfiguration.java
@@ -308,7 +308,7 @@
@Option(
name = "incompatible_merge_genfiles_directory",
- defaultValue = "false",
+ defaultValue = "true",
documentationCategory = OptionDocumentationCategory.OUTPUT_PARAMETERS,
effectTags = {OptionEffectTag.AFFECTS_OUTPUTS},
metadataTags = {
@@ -1417,6 +1417,10 @@
/** Returns the genfiles directory for this build configuration. */
public ArtifactRoot getGenfilesDirectory() {
+ if (mergeGenfilesDirectory) {
+ return getBinDirectory();
+ }
+
return getGenfilesDirectory(RepositoryName.MAIN);
}
diff --git a/src/test/java/com/google/devtools/build/lib/query2/ActionGraphProtoOutputFormatterCallbackTest.java b/src/test/java/com/google/devtools/build/lib/query2/ActionGraphProtoOutputFormatterCallbackTest.java
index b7b0d2e..4867a3a 100644
--- a/src/test/java/com/google/devtools/build/lib/query2/ActionGraphProtoOutputFormatterCallbackTest.java
+++ b/src/test/java/com/google/devtools/build/lib/query2/ActionGraphProtoOutputFormatterCallbackTest.java
@@ -199,7 +199,7 @@
"genrule(name='wrong_outputs', srcs=['matching_in'], outs=['wrong_out'],",
" cmd='cat $(SRCS) > $(OUTS)')");
- String outputs = ".*/genfiles/test/foo_matching_out";
+ String outputs = ".*/bin/test/foo_matching_out";
AqueryActionFilter actionFilters = constructActionFilter(ImmutableMap.of("outputs", outputs));
ActionGraphContainer actionGraphContainer =
@@ -921,10 +921,7 @@
private void assertMatchingOnlyActionFromFoo(ActionGraphContainer actionGraphContainer) {
assertMatchingOnlyAction(
- actionGraphContainer,
- "Genrule",
- "test/foo_matching_in.java",
- "/genfiles/test/foo_matching_out");
+ actionGraphContainer, "Genrule", "test/foo_matching_in.java", "/bin/test/foo_matching_out");
}
private void assertMatchingOnlyAction(
diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcCommonTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcCommonTest.java
index 65fb24c..8994736 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcCommonTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcCommonTest.java
@@ -496,7 +496,7 @@
@Test
public void testUseIsystemForIncludes() throws Exception {
// Tests the effect of --use_isystem_for_includes.
-
+ useConfiguration("--incompatible_merge_genfiles_directory=false");
scratch.file(
"no_includes/BUILD",
"cc_library(name = 'no_includes',",
diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcLibraryConfiguredTargetTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcLibraryConfiguredTargetTest.java
index 102d12e..a4a2823 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcLibraryConfiguredTargetTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcLibraryConfiguredTargetTest.java
@@ -1118,6 +1118,7 @@
@Test
public void testIncludePathOrder() throws Exception {
+ useConfiguration("--incompatible_merge_genfiles_directory=false");
scratch.file("foo/BUILD",
"cc_library(",
" name = 'bar',",
diff --git a/src/test/shell/bazel/bazel_rules_test.sh b/src/test/shell/bazel/bazel_rules_test.sh
index 0676d27..a129030 100755
--- a/src/test/shell/bazel/bazel_rules_test.sh
+++ b/src/test/shell/bazel/bazel_rules_test.sh
@@ -309,18 +309,18 @@
# Test that Bazel respects the client environment's TMP.
# new_tmpdir is based on $TEST_TMPDIR which is not Unix-style -- convert it.
- assert_contains "TMP=$(cygpath -u "${new_tmpdir}")" bazel-genfiles/pkg/test.out
+ assert_contains "TMP=$(cygpath -u "${new_tmpdir}")" bazel-bin/pkg/test.out
else
PATH="/random/path:$PATH" TMPDIR="${new_tmpdir}" \
bazel build //pkg:test --spawn_strategy=standalone --action_env=PATH \
&> $TEST_log || fail "Failed to build //pkg:test"
# Test that Bazel respects the client environment's TMPDIR.
- assert_contains "TMPDIR=${new_tmpdir}" bazel-genfiles/pkg/test.out
+ assert_contains "TMPDIR=${new_tmpdir}" bazel-bin/pkg/test.out
fi
# Test that Bazel passed through the PATH from --action_env.
- assert_contains "PATH=/random/path" bazel-genfiles/pkg/test.out
+ assert_contains "PATH=/random/path" bazel-bin/pkg/test.out
}
function test_genrule_remote() {
@@ -374,8 +374,8 @@
EOF
bazel build @r//package:hi >$TEST_log 2>&1 || fail "Should build"
- expect_log "bazel-.*genfiles/external/r/package/a/b"
- expect_log "bazel-.*genfiles/external/r/package/c/d"
+ expect_log "bazel-.*bin/external/r/package/a/b"
+ expect_log "bazel-.*bin/external/r/package/c/d"
}
function test_genrule_toolchain_dependency {
@@ -389,7 +389,7 @@
)
EOF
bazel build //t:toolchain_check >$TEST_log 2>&1 || fail "Should build"
- expect_log "bazel-.*genfiles/t/version"
+ expect_log "bazel-.*bin/t/version"
expect_not_log "ls: cannot access"
}