diff --git a/src/main/java/com/google/devtools/build/lib/packages/StarlarkSemanticsOptions.java b/src/main/java/com/google/devtools/build/lib/packages/StarlarkSemanticsOptions.java index ead4ea6dee1bc8..7d621b0a3ed893 100644 --- a/src/main/java/com/google/devtools/build/lib/packages/StarlarkSemanticsOptions.java +++ b/src/main/java/com/google/devtools/build/lib/packages/StarlarkSemanticsOptions.java @@ -496,7 +496,7 @@ public class StarlarkSemanticsOptions extends OptionsBase implements Serializabl @Option( name = "incompatible_remap_main_repo", - defaultValue = "false", + defaultValue = "true", documentationCategory = OptionDocumentationCategory.STARLARK_SEMANTICS, effectTags = OptionEffectTag.LOADING_AND_ANALYSIS, metadataTags = { diff --git a/src/main/java/com/google/devtools/build/lib/syntax/StarlarkSemantics.java b/src/main/java/com/google/devtools/build/lib/syntax/StarlarkSemantics.java index dec278e0ea2db0..03927c0c2dce80 100644 --- a/src/main/java/com/google/devtools/build/lib/syntax/StarlarkSemantics.java +++ b/src/main/java/com/google/devtools/build/lib/syntax/StarlarkSemantics.java @@ -270,7 +270,7 @@ public static Builder builderWithDefaults() { .incompatibleNoRuleOutputsParam(false) .incompatibleNoSupportToolsInActionInputs(true) .incompatibleNoTargetOutputGroup(true) - .incompatibleRemapMainRepo(false) + .incompatibleRemapMainRepo(true) .incompatibleRemoveNativeMavenJar(false) .incompatibleRunShellCommandString(false) .incompatibleRestrictNamedParams(true) diff --git a/src/test/java/com/google/devtools/build/lib/packages/WorkspaceFactoryTest.java b/src/test/java/com/google/devtools/build/lib/packages/WorkspaceFactoryTest.java index 8ad5c3c3466a7f..a345925d69857c 100644 --- a/src/test/java/com/google/devtools/build/lib/packages/WorkspaceFactoryTest.java +++ b/src/test/java/com/google/devtools/build/lib/packages/WorkspaceFactoryTest.java @@ -202,6 +202,7 @@ public void testImplicitMainRepoRename() throws Exception { @Test public void testNoImplicitMainRepoRenameWithoutFlag() throws Exception { + helper.setSkylarkSemantics("--noincompatible_remap_main_repo"); helper.parse("workspace(name = 'foo')"); RepositoryName foo = RepositoryName.create("@foo"); assertThat(helper.getPackage().getRepositoryMapping(RepositoryName.create("@"))) diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/RepositoryMappingFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/RepositoryMappingFunctionTest.java index 7da92b62b7fd82..b42d1012c9a23b 100644 --- a/src/test/java/com/google/devtools/build/lib/skyframe/RepositoryMappingFunctionTest.java +++ b/src/test/java/com/google/devtools/build/lib/skyframe/RepositoryMappingFunctionTest.java @@ -66,7 +66,11 @@ public void testSimpleMapping() throws Exception { .hasEntryThat(skyKey) .isEqualTo( RepositoryMappingValue.withMapping( - ImmutableMap.of(RepositoryName.create("@a"), RepositoryName.create("@b")))); + ImmutableMap.of( + RepositoryName.create("@a"), + RepositoryName.create("@b"), + RepositoryName.create("@good"), + RepositoryName.create("@")))); } @Test @@ -93,12 +97,20 @@ public void testMultipleRepositoriesWithMapping() throws Exception { .hasEntryThat(skyKey1) .isEqualTo( RepositoryMappingValue.withMapping( - ImmutableMap.of(RepositoryName.create("@a"), RepositoryName.create("@b")))); + ImmutableMap.of( + RepositoryName.create("@a"), + RepositoryName.create("@b"), + RepositoryName.create("@good"), + RepositoryName.create("@")))); assertThatEvaluationResult(eval(skyKey2)) .hasEntryThat(skyKey2) .isEqualTo( RepositoryMappingValue.withMapping( - ImmutableMap.of(RepositoryName.create("@x"), RepositoryName.create("@y")))); + ImmutableMap.of( + RepositoryName.create("@x"), + RepositoryName.create("@y"), + RepositoryName.create("@good"), + RepositoryName.create("@")))); } @Test @@ -119,8 +131,12 @@ public void testRepositoryWithMultipleMappings() throws Exception { .isEqualTo( RepositoryMappingValue.withMapping( ImmutableMap.of( - RepositoryName.create("@a"), RepositoryName.create("@b"), - RepositoryName.create("@x"), RepositoryName.create("@y")))); + RepositoryName.create("@a"), + RepositoryName.create("@b"), + RepositoryName.create("@x"), + RepositoryName.create("@y"), + RepositoryName.create("@good"), + RepositoryName.create("@")))); } @Test diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/WorkspaceFileFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/WorkspaceFileFunctionTest.java index e6ef252d929d1c..f80fd99a3e9025 100644 --- a/src/test/java/com/google/devtools/build/lib/skyframe/WorkspaceFileFunctionTest.java +++ b/src/test/java/com/google/devtools/build/lib/skyframe/WorkspaceFileFunctionTest.java @@ -299,17 +299,19 @@ public void testRepositoryMappingInChunks() throws Exception { RepositoryName b = RepositoryName.create("@b"); RepositoryName x = RepositoryName.create("@x"); RepositoryName y = RepositoryName.create("@y"); + RepositoryName good = RepositoryName.create("@good"); + RepositoryName main = RepositoryName.create("@"); SkyKey key0 = WorkspaceFileValue.key(workspace, 0); EvaluationResult result0 = eval(key0); WorkspaceFileValue value0 = result0.get(key0); - assertThat(value0.getRepositoryMapping()).containsEntry(a, ImmutableMap.of(x, y)); + assertThat(value0.getRepositoryMapping()).containsEntry(a, ImmutableMap.of(x, y, good, main)); SkyKey key1 = WorkspaceFileValue.key(workspace, 1); EvaluationResult result1 = eval(key1); WorkspaceFileValue value1 = result1.get(key1); - assertThat(value1.getRepositoryMapping()).containsEntry(a, ImmutableMap.of(x, y)); - assertThat(value1.getRepositoryMapping()).containsEntry(b, ImmutableMap.of(x, y)); + assertThat(value1.getRepositoryMapping()).containsEntry(a, ImmutableMap.of(x, y, good, main)); + assertThat(value1.getRepositoryMapping()).containsEntry(b, ImmutableMap.of(x, y, good, main)); } @Test diff --git a/src/test/shell/integration/starlark_configurations_external_workspaces_test.sh b/src/test/shell/integration/starlark_configurations_external_workspaces_test.sh index dc4625fdc79c5d..52cb853cb03421 100755 --- a/src/test/shell/integration/starlark_configurations_external_workspaces_test.sh +++ b/src/test/shell/integration/starlark_configurations_external_workspaces_test.sh @@ -133,7 +133,7 @@ function test_set_flag_with_workspace_name() { write_build_setting_bzl "@${WORKSPACE_NAME}" - bazel build //$pkg:my_drink --@"${WORKSPACE_NAME}"//$pkg:type="coffee" \ + bazel build //$pkg:my_drink --@//$pkg:type="coffee" \ --experimental_build_setting_api > output 2>"$TEST_log" \ || fail "Expected success"