Skip to content

Commit

Permalink
Delete the flag --incompatible_remap_main_repo
Browse files Browse the repository at this point in the history
#7130

RELNOTES: The flag --incompatible_remap_main_repo is removed.
PiperOrigin-RevId: 289822459
  • Loading branch information
laurentlb authored and copybara-github committed Jan 15, 2020
1 parent d2343d9 commit 8cb336a
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 84 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 '@<main repo name>' the same as '@'.")
public boolean incompatibleRemapMainRepo;

@Option(
name = "incompatible_remove_enabled_toolchain_types",
defaultValue = "false",
Expand Down Expand Up @@ -664,7 +651,6 @@ public StarlarkSemantics toSkylarkSemantics() {
.incompatibleNoRuleOutputsParam(incompatibleNoRuleOutputsParam)
.incompatibleNoSupportToolsInActionInputs(incompatibleNoSupportToolsInActionInputs)
.incompatibleNoTargetOutputGroup(incompatibleNoTargetOutputGroup)
.incompatibleRemapMainRepo(incompatibleRemapMainRepo)
.incompatibleRemoveEnabledToolchainTypes(incompatibleRemoveEnabledToolchainTypes)
.incompatibleRestrictNamedParams(incompatibleRestrictNamedParams)
.incompatibleRunShellCommandString(incompatibleRunShellCommandString)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,11 @@ public static Map<String, Object> getFinalKwargs(Map<String, Object> 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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -281,7 +279,6 @@ public static Builder builderWithDefaults() {
.incompatibleNoRuleOutputsParam(false)
.incompatibleNoSupportToolsInActionInputs(true)
.incompatibleNoTargetOutputGroup(true)
.incompatibleRemapMainRepo(true)
.incompatibleRemoveEnabledToolchainTypes(false)
.incompatibleRunShellCommandString(false)
.incompatibleRestrictNamedParams(true)
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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("");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(",
Expand All @@ -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')",
Expand Down
46 changes: 8 additions & 38 deletions src/test/shell/bazel/workspace_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand All @@ -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
}

Expand Down Expand Up @@ -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"
}

Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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"
}


Expand Down Expand Up @@ -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"

}

Expand Down Expand Up @@ -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"

1 comment on commit 8cb336a

@meteorcloudy
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://buildkite.com/bazel/bazel-at-head-plus-downstream/builds/1352#_
Some projects still have --incompatible_remap_main_repo in their build config, can you help clean them up?

Please sign in to comment.