Skip to content

Commit

Permalink
Remove ctx.host_configuration.
Browse files Browse the repository at this point in the history
The host configuration is no longer used. All targets that used to be in the
host configuration are now in an exec configuration.

RELNOTES: removed outdated ctx.host_configuration
PiperOrigin-RevId: 495887606
Change-Id: I89c4233c100d27c10215ff23594bd4eb82579e52
  • Loading branch information
gregestren authored and copybara-github committed Dec 16, 2022
1 parent 100463e commit 51e1da9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,14 +210,6 @@ public interface StarlarkRuleContextApi<ConstraintValueT extends ConstraintValue
+ "configuration</a> type for more details.")
BuildConfigurationApi getConfiguration() throws EvalException;

@StarlarkMethod(
name = "host_configuration",
structField = true,
doc =
"The host configuration. See the <a href=\"configuration.html\">"
+ "configuration</a> type for more details.")
BuildConfigurationApi getHostConfiguration() throws EvalException;

@StarlarkMethod(
name = "build_setting_value",
structField = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -2875,7 +2867,6 @@ public void testCoverageInstrumentedMatchesFilterNonDefaultLabel() throws Except
"label",
"fragments",
"configuration",
"host_configuration",
"coverage_instrumented(dep)",
"features",
"bin_dir",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand All @@ -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");
}
}

0 comments on commit 51e1da9

Please sign in to comment.