Skip to content

Commit

Permalink
Add NOOP __do_not_use_fail_with_incompatible_use_cc_configure_from_ru…
Browse files Browse the repository at this point in the history
…les_cc

Will be used when --incompatible_use_cc_configure_from_rules_cc is implemented.
I'm adding the empty implementation so Bazel release has the symbol so out
internal tests pass when the flag is not flipped.

Progress towards #10134.

PiperOrigin-RevId: 279756806
  • Loading branch information
hlopko authored and copybara-github committed Nov 11, 2019
1 parent ed528f3 commit c863974
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,10 @@ public Object call(
}
}
}

@Override
public void failWithIncompatibleUseCcConfigureFromRulesCc(
Location location, StarlarkThread thread) throws EvalException {
// Noop until --incompatible_use_cc_configure_from_rules_cc is implemented.
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

package com.google.devtools.build.lib.skylarkbuildapi.repository;

import com.google.devtools.build.lib.events.Location;
import com.google.devtools.build.lib.skylarkinterface.Param;
import com.google.devtools.build.lib.skylarkinterface.SkylarkCallable;
import com.google.devtools.build.lib.skylarkinterface.SkylarkGlobalLibrary;
Expand Down Expand Up @@ -108,4 +109,15 @@ public BaseFunction repositoryRule(
FuncallExpression ast,
StarlarkThread thread)
throws EvalException;

@SkylarkCallable(
name = "__do_not_use_fail_with_incompatible_use_cc_configure_from_rules_cc",
doc =
"When --incompatible_use_cc_configure_from_rules_cc is set to true, Bazel will "
+ "fail the build. Please see https://github.com/bazelbuild/bazel/issues/10134 for "
+ "details and migration instructions.",
useLocation = true,
useStarlarkThread = true)
public void failWithIncompatibleUseCcConfigureFromRulesCc(
Location location, StarlarkThread thread) throws EvalException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ java_library(
name = "repository",
srcs = glob(["*.java"]),
deps = [
"//src/main/java/com/google/devtools/build/lib:events",
"//src/main/java/com/google/devtools/build/lib:skylarkinterface",
"//src/main/java/com/google/devtools/build/lib:syntax",
"//src/main/java/com/google/devtools/build/lib/skylarkbuildapi/repository",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.devtools.build.lib.events.Location;
import com.google.devtools.build.lib.skylarkbuildapi.repository.RepositoryModuleApi;
import com.google.devtools.build.lib.syntax.BaseFunction;
import com.google.devtools.build.lib.syntax.EvalException;
Expand Down Expand Up @@ -98,4 +99,10 @@ public RepositoryRuleDefinitionIdentifier() {
super("RepositoryRuleDefinitionIdentifier" + idCounter++);
}
}

@Override
public void failWithIncompatibleUseCcConfigureFromRulesCc(
Location location, StarlarkThread thread) throws EvalException {
// Noop until --incompatible_use_cc_configure_from_rules_cc is implemented.
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,36 @@ public void testSkylarkLocalRepository() throws Exception {
assertThat(path).isEqualTo("foo");
}

@Test
public void testfailWithIncompatibleUseCcConfigureFromRulesCcDoesNothing() throws Exception {
// A simple test that recreates local_repository with Skylark.
scratch.file("/repo2/WORKSPACE");
scratch.file("/repo2/bar.txt");
scratch.file("/repo2/BUILD", "filegroup(name='bar', srcs=['bar.txt'], path='foo')");
scratch.file(
"def.bzl",
"__do_not_use_fail_with_incompatible_use_cc_configure_from_rules_cc()",
"def _impl(repository_ctx):",
" repository_ctx.symlink(repository_ctx.attr.path, '')",
"",
"repo = repository_rule(",
" implementation=_impl,",
" local=True,",
" attrs={'path': attr.string(mandatory=True)})");
scratch.file(rootDirectory.getRelative("BUILD").getPathString());
scratch.overwriteFile(
rootDirectory.getRelative("WORKSPACE").getPathString(),
new ImmutableList.Builder<String>()
.addAll(analysisMock.getWorkspaceContents(mockToolsConfig))
.add("load('//:def.bzl', 'repo')")
.add("repo(name='foo', path='/repo2')")
.build());
invalidatePackages();
ConfiguredTargetAndData target = getConfiguredTargetAndData("@foo//:bar");
Object path = target.getTarget().getAssociatedRule().getAttributeContainer().getAttr("path");
assertThat(path).isEqualTo("foo");
}

@Test
public void testSkylarkSymlinkFileFromRepository() throws Exception {
scratch.file("/repo2/bar.txt", "filegroup(name='bar', srcs=['foo.txt'], path='foo')");
Expand Down

0 comments on commit c863974

Please sign in to comment.