Skip to content

Commit

Permalink
Remove attribute read checks expecting a DATA transition.
Browse files Browse the repository at this point in the history
This is a precursor to removing the DATA transition outright.

While we could also have changed the Mode.DATA instances to
Mode.TARGET (which would declare that we expect the attribute not
to apply any transition), that would break existing definitions and
make depot cleanup more delicate. Plus, these checks weren't being
consistently applied across attributes anyway so they don't really
offer much. A lot of this logic is really just leftover legacy
from the pre-dynamic configuration days.

PiperOrigin-RevId: 198085059
  • Loading branch information
gregestren authored and Copybara-Service committed May 25, 2018
1 parent 2897a1d commit 475d91a
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ static Map<Label, Collection<Artifact>> buildLocationMap(
if (allowDataAttributeEntriesInLabel
&& ruleContext.getRule().isAttrDefined("data", BuildType.LABEL_LIST)) {
Iterables.addAll(depsDataAndTools,
ruleContext.getPrerequisitesIf("data", Mode.DATA, FilesToRunProvider.class));
ruleContext.getPrerequisitesIf("data", Mode.DONT_CHECK, FilesToRunProvider.class));
}
if (ruleContext.getRule().isAttrDefined("tools", BuildType.LABEL_LIST)) {
Iterables.addAll(depsDataAndTools,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1108,11 +1108,9 @@ private void checkAttribute(String attributeName, Mode mode) {
+ " is not configured for the target configuration");
}
} else if (mode == Mode.DATA) {
if (transition != disableLipoTransition) {
throw new IllegalStateException(getRule().getLocation() + ": "
+ getRuleClassNameForLogging() + " attribute " + attributeName
+ " is not configured for the data configuration");
}
throw new IllegalStateException(getRule().getLocation() + ": "
+ getRuleClassNameForLogging() + " attribute " + attributeName
+ ": DATA transition no longer supported"); // See b/80157700.
} else if (mode == Mode.SPLIT) {
if (!(attributeDefinition.hasSplitConfigurationTransition())) {
throw new IllegalStateException(getRule().getLocation() + ": "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1002,7 +1002,8 @@ public Builder add(RuleContext ruleContext,
* Collects runfiles from data dependencies of a target.
*/
public Builder addDataDeps(RuleContext ruleContext) {
addTargets(getPrerequisites(ruleContext, "data", Mode.DATA), RunfilesProvider.DATA_RUNFILES);
addTargets(getPrerequisites(ruleContext, "data", Mode.DONT_CHECK),
RunfilesProvider.DATA_RUNFILES);
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ private static RunfilesSupport create(
if (runUnder != null && runUnder.getLabel() != null
&& TargetUtils.isTestRule(ruleContext.getRule())) {
TransitiveInfoCollection runUnderTarget =
ruleContext.getPrerequisite(":run_under", Mode.DATA);
ruleContext.getPrerequisite(":run_under", Mode.DONT_CHECK);
runfiles = new Runfiles.Builder(
ruleContext.getWorkspaceName(), ruleContext.getConfiguration().legacyExternalRunfiles())
.merge(getRunfiles(runUnderTarget, ruleContext.getWorkspaceName()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public final class TestTargetExecutionSettings {

private static Artifact getRunUnderExecutable(RuleContext ruleContext) {
TransitiveInfoCollection runUnderTarget = ruleContext
.getPrerequisite(":run_under", Mode.DATA);
.getPrerequisite(":run_under", Mode.DONT_CHECK);
return runUnderTarget == null
? null
: runUnderTarget.getProvider(FilesToRunProvider.class).getExecutable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public ConfiguredTarget create(RuleContext ruleContext)
NestedSet<Artifact> filesToBuild = NestedSetBuilder.<Artifact>stableOrder()
.addAll(ruleContext.getPrerequisiteArtifacts("srcs", Mode.TARGET).list())
.addAll(ruleContext.getPrerequisiteArtifacts("deps", Mode.TARGET).list())
.addAll(ruleContext.getPrerequisiteArtifacts("data", Mode.DATA).list())
.addAll(ruleContext.getPrerequisiteArtifacts("data", Mode.DONT_CHECK).list())
.build();
Runfiles runfiles = new Runfiles.Builder(
ruleContext.getWorkspaceName(), ruleContext.getConfiguration().legacyExternalRunfiles())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ private static FilesToRunProvider getAapt(RuleContext ruleContext) {
}

private static ImmutableList<Artifact> getDataDeps(RuleContext ruleContext) {
return ruleContext.getPrerequisiteArtifacts("data", Mode.DATA).list();
return ruleContext.getPrerequisiteArtifacts("data", Mode.DONT_CHECK).list();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public ConfiguredTarget create(RuleContext context)
CommandHelper commandHelper =
new CommandHelper(context, tools, ImmutableMap.<Label, Iterable<Artifact>>of());

resolvedData.addAll(context.getPrerequisiteArtifacts("data", Mode.DATA).list());
resolvedData.addAll(context.getPrerequisiteArtifacts("data", Mode.DONT_CHECK).list());
List<String>outputTemplates =
context.attributes().get("out_templates", Type.STRING_LIST);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ protected NestedSet<LinkerInput> collectTransitiveJavaNativeLibraries() {
builder.addJavaTargets(targetsTreatedAsDeps(ClasspathType.BOTH));

if (ruleContext.getRule().isAttrDefined("data", BuildType.LABEL_LIST)) {
builder.addJavaTargets(ruleContext.getPrerequisites("data", Mode.DATA));
builder.addJavaTargets(ruleContext.getPrerequisites("data", Mode.DONT_CHECK));
}
return builder.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ public boolean usesSharedLibraries() {
try {
return checkForSharedLibraries(Iterables.concat(
ruleContext.getPrerequisites("deps", Mode.TARGET),
ruleContext.getPrerequisites("data", Mode.DATA)));
ruleContext.getPrerequisites("data", Mode.DONT_CHECK)));
} catch (EvalException e) {
ruleContext.ruleError(e.getMessage());
return false;
Expand Down

0 comments on commit 475d91a

Please sign in to comment.