From 8cb336ac3dc4d95005ab5b5243b51bf88cd6fdfe Mon Sep 17 00:00:00 2001 From: laurentlb Date: Wed, 15 Jan 2020 02:36:38 -0800 Subject: [PATCH] Delete the flag --incompatible_remap_main_repo https://github.com/bazelbuild/bazel/issues/7130 RELNOTES: The flag --incompatible_remap_main_repo is removed. PiperOrigin-RevId: 289822459 --- .../packages/StarlarkSemanticsOptions.java | 14 ------ .../lib/packages/WorkspaceFactoryHelper.java | 12 ++--- .../build/lib/packages/WorkspaceGlobals.java | 10 ++-- .../build/lib/syntax/StarlarkSemantics.java | 5 -- .../SkylarkSemanticsConsistencyTest.java | 2 - .../lib/packages/WorkspaceFactoryTest.java | 10 ---- .../RepositoryMappingFunctionTest.java | 2 - src/test/shell/bazel/workspace_test.sh | 46 ++++--------------- 8 files changed, 17 insertions(+), 84 deletions(-) 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 e169b024a6eebc..38fbe5959bb4ba 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 @@ -499,19 +499,6 @@ public class StarlarkSemanticsOptions extends OptionsBase implements Serializabl help = "If set to true, disables the output_group field of the 'Target' Starlark type.") public boolean incompatibleNoTargetOutputGroup; - @Option( - name = "incompatible_remap_main_repo", - defaultValue = "true", - documentationCategory = OptionDocumentationCategory.STARLARK_SEMANTICS, - effectTags = OptionEffectTag.LOADING_AND_ANALYSIS, - metadataTags = { - OptionMetadataTag.INCOMPATIBLE_CHANGE, - OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES - }, - oldName = "experimental_remap_main_repo", - help = "If set to true, will treat references to '@
' the same as '@'.") - public boolean incompatibleRemapMainRepo; - @Option( name = "incompatible_remove_enabled_toolchain_types", defaultValue = "false", @@ -664,7 +651,6 @@ public StarlarkSemantics toSkylarkSemantics() { .incompatibleNoRuleOutputsParam(incompatibleNoRuleOutputsParam) .incompatibleNoSupportToolsInActionInputs(incompatibleNoSupportToolsInActionInputs) .incompatibleNoTargetOutputGroup(incompatibleNoTargetOutputGroup) - .incompatibleRemapMainRepo(incompatibleRemapMainRepo) .incompatibleRemoveEnabledToolchainTypes(incompatibleRemoveEnabledToolchainTypes) .incompatibleRestrictNamedParams(incompatibleRestrictNamedParams) .incompatibleRunShellCommandString(incompatibleRunShellCommandString) diff --git a/src/main/java/com/google/devtools/build/lib/packages/WorkspaceFactoryHelper.java b/src/main/java/com/google/devtools/build/lib/packages/WorkspaceFactoryHelper.java index 3eb40ed4afa9fa..e442e8f5ec41f9 100644 --- a/src/main/java/com/google/devtools/build/lib/packages/WorkspaceFactoryHelper.java +++ b/src/main/java/com/google/devtools/build/lib/packages/WorkspaceFactoryHelper.java @@ -110,13 +110,11 @@ public static Map getFinalKwargs(Map kwargs) { */ public static void addMainRepoEntry( Package.Builder builder, String externalRepoName, StarlarkSemantics semantics) { - if (semantics.incompatibleRemapMainRepo()) { - if (!Strings.isNullOrEmpty(builder.getPackageWorkspaceName())) { - builder.addRepositoryMappingEntry( - RepositoryName.createFromValidStrippedName(externalRepoName), - RepositoryName.createFromValidStrippedName(builder.getPackageWorkspaceName()), - RepositoryName.MAIN); - } + if (!Strings.isNullOrEmpty(builder.getPackageWorkspaceName())) { + builder.addRepositoryMappingEntry( + RepositoryName.createFromValidStrippedName(externalRepoName), + RepositoryName.createFromValidStrippedName(builder.getPackageWorkspaceName()), + RepositoryName.MAIN); } } diff --git a/src/main/java/com/google/devtools/build/lib/packages/WorkspaceGlobals.java b/src/main/java/com/google/devtools/build/lib/packages/WorkspaceGlobals.java index 66bd25745ca7ad..d4f4b0ebf4fe6b 100644 --- a/src/main/java/com/google/devtools/build/lib/packages/WorkspaceGlobals.java +++ b/src/main/java/com/google/devtools/build/lib/packages/WorkspaceGlobals.java @@ -90,12 +90,10 @@ public NoneType workspace( } // Add entry in repository map from "@name" --> "@" to avoid issue where bazel // treats references to @name as a separate external repo - if (thread.getSemantics().incompatibleRemapMainRepo()) { - builder.addRepositoryMappingEntry( - RepositoryName.MAIN, - RepositoryName.createFromValidStrippedName(name), - RepositoryName.MAIN); - } + builder.addRepositoryMappingEntry( + RepositoryName.MAIN, + RepositoryName.createFromValidStrippedName(name), + RepositoryName.MAIN); parseManagedDirectories( managedDirectories.getContents(String.class, Object.class, "managed_directories"), loc); return NONE; 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 a64d52f3b066fa..5c21a2f0123b15 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 @@ -194,8 +194,6 @@ public boolean flagValue(FlagIdentifier flagIdentifier) { public abstract boolean incompatibleNoTargetOutputGroup(); - public abstract boolean incompatibleRemapMainRepo(); - public abstract boolean incompatibleRemoveEnabledToolchainTypes(); public abstract boolean incompatibleRestrictNamedParams(); @@ -281,7 +279,6 @@ public static Builder builderWithDefaults() { .incompatibleNoRuleOutputsParam(false) .incompatibleNoSupportToolsInActionInputs(true) .incompatibleNoTargetOutputGroup(true) - .incompatibleRemapMainRepo(true) .incompatibleRemoveEnabledToolchainTypes(false) .incompatibleRunShellCommandString(false) .incompatibleRestrictNamedParams(true) @@ -362,8 +359,6 @@ public abstract static class Builder { public abstract Builder incompatibleNoTargetOutputGroup(boolean value); - public abstract Builder incompatibleRemapMainRepo(boolean value); - public abstract Builder incompatibleRemoveEnabledToolchainTypes(boolean value); public abstract Builder incompatibleRestrictNamedParams(boolean value); diff --git a/src/test/java/com/google/devtools/build/lib/packages/SkylarkSemanticsConsistencyTest.java b/src/test/java/com/google/devtools/build/lib/packages/SkylarkSemanticsConsistencyTest.java index 7e8f5049edb60c..798e410a730364 100644 --- a/src/test/java/com/google/devtools/build/lib/packages/SkylarkSemanticsConsistencyTest.java +++ b/src/test/java/com/google/devtools/build/lib/packages/SkylarkSemanticsConsistencyTest.java @@ -156,7 +156,6 @@ private static StarlarkSemanticsOptions buildRandomOptions(Random rand) throws E "--incompatible_no_rule_outputs_param=" + rand.nextBoolean(), "--incompatible_no_support_tools_in_action_inputs=" + rand.nextBoolean(), "--incompatible_no_target_output_group=" + rand.nextBoolean(), - "--incompatible_remap_main_repo=" + rand.nextBoolean(), "--incompatible_remove_enabled_toolchain_types=" + rand.nextBoolean(), "--incompatible_restrict_named_params=" + rand.nextBoolean(), "--incompatible_run_shell_command_string=" + rand.nextBoolean(), @@ -208,7 +207,6 @@ private static StarlarkSemantics buildRandomSemantics(Random rand) { .incompatibleNoRuleOutputsParam(rand.nextBoolean()) .incompatibleNoSupportToolsInActionInputs(rand.nextBoolean()) .incompatibleNoTargetOutputGroup(rand.nextBoolean()) - .incompatibleRemapMainRepo(rand.nextBoolean()) .incompatibleRemoveEnabledToolchainTypes(rand.nextBoolean()) .incompatibleRestrictNamedParams(rand.nextBoolean()) .incompatibleRunShellCommandString(rand.nextBoolean()) 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 a345925d69857c..7cdd3c8599a534 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 @@ -195,20 +195,10 @@ public void testMappingsNotAMap() throws Exception { @Test public void testImplicitMainRepoRename() throws Exception { - helper.setSkylarkSemantics("--incompatible_remap_main_repo"); helper.parse("workspace(name = 'foo')"); assertMapping(helper, "@", "@foo", "@"); } - @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("@"))) - .doesNotContainEntry(foo, RepositoryName.MAIN); - } - @Test public void testEmptyRepositoryHasEmptyMap() throws Exception { helper.parse(""); 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 b42d1012c9a23b..31e746a1f19359 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 @@ -162,7 +162,6 @@ public void testErrorWithMapping() throws Exception { @Test public void testDefaultMainRepoNameInMapping() throws Exception { - setSkylarkSemanticsOptions("--incompatible_remap_main_repo"); scratch.overwriteFile( "WORKSPACE", "local_repository(", @@ -184,7 +183,6 @@ public void testDefaultMainRepoNameInMapping() throws Exception { @Test public void testExplicitMainRepoNameInMapping() throws Exception { - setSkylarkSemanticsOptions("--incompatible_remap_main_repo"); scratch.overwriteFile( "WORKSPACE", "workspace(name = 'good')", diff --git a/src/test/shell/bazel/workspace_test.sh b/src/test/shell/bazel/workspace_test.sh index 46120eb89d8be8..3741027d8f2967 100755 --- a/src/test/shell/bazel/workspace_test.sh +++ b/src/test/shell/bazel/workspace_test.sh @@ -784,7 +784,7 @@ a = 1 EOF cd mainrepo - bazel query --incompatible_remap_main_repo //... &>"$TEST_log" \ + bazel query //... &>"$TEST_log" \ || fail "Expected query to succeed" expect_log "def.bzl loaded" expect_not_log "external" @@ -812,7 +812,7 @@ EOF # the bzl file should be loaded from the main workspace and # not as an external repository cd mainrepo - bazel query --incompatible_remap_main_repo @a//... &>"$TEST_log" \ + bazel query @a//... &>"$TEST_log" \ || fail "Expected query to succeed" expect_log "def.bzl loaded" expect_not_log "external" @@ -830,8 +830,7 @@ EOF # now that @mainrepo doesn't exist within workspace "a", # the query should fail cd mainrepo - bazel query --incompatible_remap_main_repo \ - @a//... &>"$TEST_log" \ + bazel query @a//... &>"$TEST_log" \ && fail "Failure expected" || true } @@ -926,7 +925,7 @@ EOF chmod u+x code/foo.sh - bazel build --incompatible_remap_main_repo=true //code/... \ + bazel build //code/... \ > "${TEST_log}" 2>&1 || fail "expected success" } @@ -981,17 +980,7 @@ testrule( ) EOF - bazel build --incompatible_remap_main_repo=true //toolchains/... \ - || fail "expected success" - - echo; echo Without remapping of main repo; echo - # Regression test for invalidation of `--incompabtile_remap_main_repo` - # (https://github.com/bazelbuild/bazel/issues/8937). As - # building without remapping works on a clean checkout, it should also work - # on a running bazel. - bazel build --incompatible_remap_main_repo=false //toolchains/... \ - || fail "expected success" - + bazel build //toolchains/... || fail "expected success" } test_remap_toolchains_from_qualified_load() { @@ -1042,16 +1031,7 @@ testrule( ) EOF - bazel build --incompatible_remap_main_repo=true @my_ws//toolchains/... \ - || fail "expected success" - - # Additionally check, that nothing goes wrong flipping the remapping - # off and on again. - bazel build --incompatible_remap_main_repo=false @my_ws//toolchains/... \ - || fail "expected success" - - bazel build --incompatible_remap_main_repo=true @my_ws//toolchains/... \ - || fail "expected success" + bazel build @my_ws//toolchains/... || fail "expected success" } @@ -1153,13 +1133,8 @@ genrule( outs = ["y.txt"], ) EOF - echo; echo not remapping main repo; echo - bazel build --incompatible_remap_main_repo=false @foo//:y \ - || fail "Expected success" - echo; echo remapping main repo; echo - bazel build --incompatible_remap_main_repo=true @foo//:y \ - || fail "Expected success" + bazel build @foo//:y || fail "Expected success" } @@ -1215,13 +1190,8 @@ EOF load("//:datarule.bzl", "data") data(name="it") EOF - echo; echo not remapping main repo; echo - bazel build --incompatible_remap_main_repo=false @foo//:it \ - || fail "Expected success" - echo; echo remapping main repo; echo - bazel build --incompatible_remap_main_repo=true @foo//:it \ - || fail "Expected success" + bazel build @foo//:it || fail "Expected success" } run_suite "workspace tests"