Skip to content

Commit

Permalink
LocationExpander+GenruleBase: NestedSet not Iterable
Browse files Browse the repository at this point in the history
This is in preparation for making NestedSet not implement Iterable.

PiperOrigin-RevId: 289403912
  • Loading branch information
ulfjack authored and copybara-github committed Jan 13, 2020
1 parent 137e96e commit c035a25
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ public String expandAttribute(String attrName, String attrValue) {
private String expand(String value, ErrorReporter reporter) {
int restart = 0;

int attrLength = value.length();
StringBuilder result = new StringBuilder(value.length());

while (true) {
Expand Down Expand Up @@ -375,8 +374,8 @@ static Map<Label, Collection<Artifact>> buildLocationMap(
if (ruleContext.getRule().isAttrDefined("srcs", BuildType.LABEL_LIST)) {
for (TransitiveInfoCollection src : ruleContext
.getPrerequisitesIf("srcs", Mode.TARGET, FileProvider.class)) {
Iterables.addAll(mapGet(locationMap, AliasProvider.getDependencyLabel(src)),
src.getProvider(FileProvider.class).getFilesToBuild());
mapGet(locationMap, AliasProvider.getDependencyLabel(src))
.addAll(src.getProvider(FileProvider.class).getFilesToBuild().toList());
}
}

Expand Down Expand Up @@ -405,7 +404,7 @@ static Map<Label, Collection<Artifact>> buildLocationMap(
if (executableArtifact != null) {
mapGet(locationMap, label).add(executableArtifact);
} else {
Iterables.addAll(mapGet(locationMap, label), filesToRun.getFilesToRun());
mapGet(locationMap, label).addAll(filesToRun.getFilesToRun().toList());
}
}
return locationMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,17 @@ public ConfiguredTarget create(RuleContext ruleContext)

Pair<CommandType, String> cmdTypeAndAttr = determineCommandTypeAndAttribute(ruleContext);

ImmutableMap.Builder<Label, NestedSet<Artifact>> labelMap = ImmutableMap.builder();
ImmutableMap.Builder<Label, Iterable<Artifact>> labelMap = ImmutableMap.builder();
for (TransitiveInfoCollection dep : ruleContext.getPrerequisites("srcs", Mode.TARGET)) {
// This target provides specific types of files for genrules.
GenRuleSourcesProvider provider = dep.getProvider(GenRuleSourcesProvider.class);
NestedSet<Artifact> files = (provider != null)
? provider.getGenruleFiles()
: dep.getProvider(FileProvider.class).getFilesToBuild();
resolvedSrcsBuilder.addTransitive(files);
labelMap.put(AliasProvider.getDependencyLabel(dep), files);
// The CommandHelper class makes an explicit copy of this in the constructor, so flattening
// here should be benign.
labelMap.put(AliasProvider.getDependencyLabel(dep), files.toList());
}
NestedSet<Artifact> resolvedSrcs = resolvedSrcsBuilder.build();

Expand Down

0 comments on commit c035a25

Please sign in to comment.