Skip to content

Commit

Permalink
Restructure CommandHelper so that it's more obvious that the runfiles…
Browse files Browse the repository at this point in the history
… middleman and the runfiles supplier always go together.

RELNOTES: None.
PiperOrigin-RevId: 597831353
Change-Id: I7fbb086694d397a9066ab418acc49309d8ce81e4
  • Loading branch information
lberki authored and copybara-github committed Jan 12, 2024
1 parent c8c3878 commit ed1accb
Showing 1 changed file with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,24 +171,25 @@ private CommandHelper(
continue;
}

if (tool.getRunfilesSupport() != null) {
resolvedToolsBuilder.add(tool.getRunfilesSupport().getRunfilesMiddleman());

// It's that getExecutable() returns an artifact that is not in getFilesToBuild(). It is
// not nice, but it happens (see test_executable_without_default_files)
resolvedToolsBuilder.add(tool.getRunfilesSupport().getExecutable());
}

NestedSet<Artifact> filesToBuild = dep.getProvider(FileProvider.class).getFilesToBuild();
resolvedToolsBuilder.addTransitive(filesToBuild);

Label label = AliasProvider.getDependencyLabel(dep);
Artifact executableArtifact = tool.getExecutable();
Label label = AliasProvider.getDependencyLabel(dep);

// If the label has an executable artifact add that to the multimaps.
if (executableArtifact != null) {
mapGet(tempLabelMap, label).add(executableArtifact);
// Also send the runfiles when running remotely.
toolsRunfilesBuilder.add(tool.getRunfilesSupplier());
// Also send the runfiles if needed.
RunfilesSupport runfilesSupport = tool.getRunfilesSupport();
if (runfilesSupport != null) {
toolsRunfilesBuilder.add(runfilesSupport);
resolvedToolsBuilder.add(runfilesSupport.getRunfilesMiddleman());
// It's possible that getExecutable() returns an artifact that is not in
// getFilesToBuild(). It is not nice, but it happens
// (see test_executable_without_default_files)
resolvedToolsBuilder.add(tool.getRunfilesSupport().getExecutable());
}
} else {
// Map all depArtifacts to the respective label using the multimaps.
mapGet(tempLabelMap, label).addAll(filesToBuild.toList());
Expand Down

0 comments on commit ed1accb

Please sign in to comment.