diff --git a/src/main/java/com/google/devtools/build/lib/analysis/starlark/StarlarkRuleContext.java b/src/main/java/com/google/devtools/build/lib/analysis/starlark/StarlarkRuleContext.java index a05c662657065b..feae9d05050a0c 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/starlark/StarlarkRuleContext.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/starlark/StarlarkRuleContext.java @@ -613,12 +613,6 @@ public BuildConfigurationValue getConfiguration() throws EvalException { return ruleContext.getConfiguration(); } - @Override - public BuildConfigurationValue getHostConfiguration() throws EvalException { - checkMutable("host_configuration"); - return ruleContext.getHostConfiguration(); - } - @Override @Nullable public Object getBuildSettingValue() throws EvalException { diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/StarlarkRuleContextApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/StarlarkRuleContextApi.java index 7f6096befeaf78..3919ecd8a69fe2 100644 --- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/StarlarkRuleContextApi.java +++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/StarlarkRuleContextApi.java @@ -210,14 +210,6 @@ public interface StarlarkRuleContextApi type for more details.") BuildConfigurationApi getConfiguration() throws EvalException; - @StarlarkMethod( - name = "host_configuration", - structField = true, - doc = - "The host configuration. See the " - + "configuration type for more details.") - BuildConfigurationApi getHostConfiguration() throws EvalException; - @StarlarkMethod( name = "build_setting_value", structField = true, diff --git a/src/test/java/com/google/devtools/build/lib/starlark/StarlarkRuleContextTest.java b/src/test/java/com/google/devtools/build/lib/starlark/StarlarkRuleContextTest.java index c451fe1c16cc84..da356aed57e613 100644 --- a/src/test/java/com/google/devtools/build/lib/starlark/StarlarkRuleContextTest.java +++ b/src/test/java/com/google/devtools/build/lib/starlark/StarlarkRuleContextTest.java @@ -1018,14 +1018,6 @@ public void testDisabledFeatures() throws Exception { assertThat((Sequence) result).containsExactly("f3"); } - @Test - public void testHostConfiguration() throws Exception { - StarlarkRuleContext ruleContext = createRuleContext("//foo:foo"); - setRuleContext(ruleContext); - Object result = ev.eval("ruleContext.host_configuration"); - assertThat(ruleContext.getRuleContext().getHostConfiguration()).isSameInstanceAs(result); - } - @Test public void testWorkspaceName() throws Exception { assertThat(ruleClassProvider.getRunfilesPrefix()).isNotNull(); @@ -2875,7 +2867,6 @@ public void testCoverageInstrumentedMatchesFilterNonDefaultLabel() throws Except "label", "fragments", "configuration", - "host_configuration", "coverage_instrumented(dep)", "features", "bin_dir", diff --git a/src/test/java/com/google/devtools/build/lib/starlark/StarlarkRuleImplementationFunctionsTest.java b/src/test/java/com/google/devtools/build/lib/starlark/StarlarkRuleImplementationFunctionsTest.java index 0a3083955bfe8c..7b61daf2495385 100644 --- a/src/test/java/com/google/devtools/build/lib/starlark/StarlarkRuleImplementationFunctionsTest.java +++ b/src/test/java/com/google/devtools/build/lib/starlark/StarlarkRuleImplementationFunctionsTest.java @@ -3339,18 +3339,29 @@ public void testDeclareSharedArtifactIsPrivateAPI() throws Exception { public void testDeclareSharedArtifact_differentFileRoot() throws Exception { scratch.file( "test/rule.bzl", + "RootProvider = provider(fields = ['root'])", "def _impl(ctx):", + " if not ctx.attr.dep:", + " return [RootProvider(root = ctx.configuration.bin_dir)]", // This is the child. + " exec_config_root = ctx.attr.dep[RootProvider].root", " a1 = ctx.actions.declare_shareable_artifact(ctx.label.name + '1.so')", " ctx.actions.write(a1, '')", " a2 = ctx.actions.declare_shareable_artifact(", " ctx.label.name + '2.so',", - " ctx.host_configuration.bin_dir", + " exec_config_root", " )", " ctx.actions.write(a2, '')", " return [DefaultInfo(files = depset([a1, a2]))]", "", - "r = rule(implementation = _impl)"); - scratch.file("test/BUILD", "load(':rule.bzl', 'r')", "r(name = 'foo')"); + "r = rule(", + " implementation = _impl,", + " attrs = {'dep': attr.label(cfg = 'exec')},", + ")"); + scratch.file( + "test/BUILD", + "load(':rule.bzl', 'r')", + "r(name = 'foo', dep = ':exec_configured_child')", + "r(name = 'exec_configured_child')"); ConfiguredTarget target = getConfiguredTarget("//test:foo"); @@ -3369,6 +3380,7 @@ public void testDeclareSharedArtifact_differentFileRoot() throws Exception { .findFirst() .orElse(null); assertThat(a2).isNotNull(); - assertThat(a2.getRoot().getExecPathString()).isEqualTo(getRelativeOutputPath() + "/host/bin"); + assertThat(a2.getRoot().getExecPathString()) + .matches(getRelativeOutputPath() + "/[\\w\\-]+\\-exec\\-[\\w\\-]+/bin"); } }