use of com.google.devtools.build.lib.actions.SimpleSpawn in project bazel by bazelbuild.
the class CppLinkAction method execute.
@Override
@ThreadCompatible
public void execute(ActionExecutionContext actionExecutionContext) throws ActionExecutionException, InterruptedException {
if (fake) {
executeFake();
} else {
Executor executor = actionExecutionContext.getExecutor();
try {
// Collect input files
List<ActionInput> allInputs = new ArrayList<>();
Artifact.addExpandedArtifacts(getMandatoryInputs(), allInputs, actionExecutionContext.getArtifactExpander());
ImmutableMap<String, String> executionInfo = ImmutableMap.of();
if (needsToRunOnMac()) {
executionInfo = ImmutableMap.of(ExecutionRequirements.REQUIRES_DARWIN, "");
}
Spawn spawn = new SimpleSpawn(this, ImmutableList.copyOf(getCommandLine()), getEnvironment(), executionInfo, ImmutableList.copyOf(allInputs), getOutputs().asList(), estimateResourceConsumptionLocal());
executor.getSpawnActionContext(getMnemonic()).exec(spawn, actionExecutionContext);
} catch (ExecException e) {
throw e.toActionExecutionException("Linking of rule '" + getOwner().getLabel() + "'", executor.getVerboseFailures(), this);
}
}
}
use of com.google.devtools.build.lib.actions.SimpleSpawn in project bazel by bazelbuild.
the class StandaloneTestStrategy method exec.
@Override
public void exec(TestRunnerAction action, ActionExecutionContext actionExecutionContext) throws ExecException, InterruptedException {
Path execRoot = actionExecutionContext.getExecutor().getExecRoot();
Path coverageDir = execRoot.getRelative(action.getCoverageDirectory());
Path runfilesDir = getLocalRunfilesDirectory(action, actionExecutionContext, binTools, action.getLocalShellEnvironment(), action.isEnableRunfiles());
Path tmpDir = tmpDirRoot.getChild(getTmpDirName(action.getExecutionSettings().getExecutable().getExecPath()));
Map<String, String> env = setupEnvironment(action, execRoot, runfilesDir, tmpDir);
Path workingDirectory = runfilesDir.getRelative(action.getRunfilesPrefix());
ResolvedPaths resolvedPaths = action.resolve(execRoot);
Map<String, String> info = new HashMap<>();
// This key is only understood by StandaloneSpawnStrategy.
info.put("timeout", "" + getTimeout(action));
info.putAll(action.getTestProperties().getExecutionInfo());
Spawn spawn = new SimpleSpawn(action, getArgs(COLLECT_COVERAGE, action), ImmutableMap.copyOf(env), ImmutableMap.copyOf(info), new RunfilesSupplierImpl(runfilesDir.asFragment(), action.getExecutionSettings().getRunfiles()), /*inputs=*/
ImmutableList.copyOf(action.getInputs()), /*tools=*/
ImmutableList.<Artifact>of(), /*filesetManifests=*/
ImmutableList.<Artifact>of(), ImmutableList.copyOf(action.getSpawnOutputs()), action.getTestProperties().getLocalResourceUsage(executionOptions.usingLocalTestJobs()));
Executor executor = actionExecutionContext.getExecutor();
TestResultData.Builder dataBuilder = TestResultData.newBuilder();
try {
int maxAttempts = getTestAttempts(action);
TestResultData data = executeTestAttempt(action, spawn, actionExecutionContext, execRoot, coverageDir, tmpDir, workingDirectory);
int attempt;
for (attempt = 1; data.getStatus() != BlazeTestStatus.PASSED && attempt < maxAttempts; attempt++) {
processFailedTestAttempt(attempt, executor, action, dataBuilder, data, actionExecutionContext.getFileOutErr());
data = executeTestAttempt(action, spawn, actionExecutionContext, execRoot, coverageDir, tmpDir, workingDirectory);
}
processLastTestAttempt(attempt, dataBuilder, data);
ImmutableList.Builder<Pair<String, Path>> testOutputsBuilder = new ImmutableList.Builder<>();
if (action.getTestLog().getPath().exists()) {
testOutputsBuilder.add(Pair.of("test.log", action.getTestLog().getPath()));
}
if (resolvedPaths.getXmlOutputPath().exists()) {
testOutputsBuilder.add(Pair.of("test.xml", resolvedPaths.getXmlOutputPath()));
}
executor.getEventBus().post(new TestAttempt(action, attempt, data.getTestPassed(), data.getRunDurationMillis(), testOutputsBuilder.build(), true));
finalizeTest(actionExecutionContext, action, dataBuilder.build());
} catch (IOException e) {
executor.getEventHandler().handle(Event.error("Caught I/O exception: " + e));
throw new EnvironmentalExecException("unexpected I/O exception", e);
}
}
use of com.google.devtools.build.lib.actions.SimpleSpawn in project bazel by bazelbuild.
the class SpawnGccStrategy method execWithReply.
@Override
public CppCompileActionContext.Reply execWithReply(CppCompileAction action, ActionExecutionContext actionExecutionContext) throws ExecException, InterruptedException {
if (action.getDotdFile() != null && action.getDotdFile().artifact() == null) {
throw new UserExecException("cannot execute remotely or locally: " + action.getPrimaryInput().getExecPathString());
}
Iterable<Artifact> inputs = Iterables.concat(action.getInputs(), action.getAdditionalInputs());
Spawn spawn = new SimpleSpawn(action, ImmutableList.copyOf(action.getArgv()), ImmutableMap.copyOf(action.getEnvironment()), ImmutableMap.copyOf(action.getExecutionInfo()), EmptyRunfilesSupplier.INSTANCE, ImmutableList.<Artifact>copyOf(inputs), /*tools=*/
ImmutableList.<Artifact>of(), /*filesetManifests=*/
ImmutableList.<Artifact>of(), action.getOutputs().asList(), action.estimateResourceConsumptionLocal());
actionExecutionContext.getExecutor().getSpawnActionContext(action.getMnemonic()).exec(spawn, actionExecutionContext);
return null;
}
Aggregations