Follow-up changes suggested in internal review of
@@ -307,20 +307,20 @@ public class RunCommand implements BlazeCommand {
// and that it is executable.
// These checks should only fail if keepGoing is true, because we already did
// validation before the build began. See {@link #validateTargets()}.
- Collection<ConfiguredTarget> targetsBuilt = result.getSuccessfulTargets();
+ Collection<ConfiguredTarget> topLevelTargets = result.getSuccessfulTargets();
ConfiguredTarget targetToRun = null;
ConfiguredTarget runUnderTarget = null;
- if (targetsBuilt != null) {
+ if (topLevelTargets != null) {
int maxTargets = runUnder != null && runUnder.getLabel() != null ? 2 : 1;
- if (targetsBuilt.size() > maxTargets) {
+ if (topLevelTargets.size() > maxTargets) {
return reportAndCreateFailureResult(
env,
makeErrorMessageForNotHavingASingleTarget(
- targetString, Iterables.transform(targetsBuilt, ct -> ct.getLabel().toString())),
+ targetString, Iterables.transform(topLevelTargets, ct -> ct.getLabel().toString())),
Code.TOO_MANY_TARGETS_SPECIFIED);
}
- for (ConfiguredTarget target : targetsBuilt) {
+ for (ConfiguredTarget target : topLevelTargets) {
BlazeCommandResult targetValidation = fullyValidateTarget(env, target);
if (!targetValidation.isSuccess()) {
return targetValidation;
@@ -339,7 +339,8 @@ public class RunCommand implements BlazeCommand {
return reportAndCreateFailureResult(
env,
makeErrorMessageForNotHavingASingleTarget(
- targetString, Iterables.transform(targetsBuilt, ct -> ct.getLabel().toString())),
+ targetString,
+ Iterables.transform(topLevelTargets, ct -> ct.getLabel().toString())),
Code.TOO_MANY_TARGETS_SPECIFIED);
}
}
@@ -375,11 +376,13 @@ public class RunCommand implements BlazeCommand {
// target to run needs to be preserved, as it acts as the working directory.
Path targetToRunRunfilesDir = null;
RunfilesSupport targetToRunRunfilesSupport = null;
- for (ConfiguredTarget target : targetsBuilt) {
+ for (ConfiguredTarget target : topLevelTargets) {
FilesToRunProvider provider = target.getProvider(FilesToRunProvider.class);
RunfilesSupport runfilesSupport = provider == null ? null : provider.getRunfilesSupport();
- if (runfilesSupport != null) {
+ if (runfilesSupport == null) {
+ continue;
+ }
try {
Path runfilesDir =
ensureRunfilesBuilt(
@@ -402,7 +405,6 @@ public class RunCommand implements BlazeCommand {
.build());
}
}
- }
Map<String, String> runEnvironment = new TreeMap<>();
List<String> cmdLine = new ArrayList<>();
