use of com.google.devtools.build.lib.actions.extra.SpawnInfo in project bazel by bazelbuild.
the class SpawnAction method getExtraActionSpawnInfo.
/**
* Returns information about this spawn action for use by the extra action mechanism.
*
* <p>Subclasses of SpawnAction may override this in order to provide action-specific behaviour.
* This can be necessary, for example, when the action discovers inputs.
*/
protected SpawnInfo getExtraActionSpawnInfo() {
SpawnInfo.Builder info = SpawnInfo.newBuilder();
Spawn spawn = getSpawn();
info.addAllArgument(spawn.getArguments());
for (Map.Entry<String, String> variable : spawn.getEnvironment().entrySet()) {
info.addVariable(EnvironmentVariable.newBuilder().setName(variable.getKey()).setValue(variable.getValue()).build());
}
for (ActionInput input : spawn.getInputFiles()) {
// Explicitly ignore middleman artifacts here.
if (!(input instanceof Artifact) || !((Artifact) input).isMiddlemanArtifact()) {
info.addInputFile(input.getExecPathString());
}
}
info.addAllOutputFile(ActionInputHelper.toExecPaths(spawn.getOutputFiles()));
return info.build();
}
use of com.google.devtools.build.lib.actions.extra.SpawnInfo in project bazel by bazelbuild.
the class SpawnActionTest method testExtraActionInfoEnvironmentVariables.
/**
* Test that environment variables are not escaped or quoted.
*/
@Test
public void testExtraActionInfoEnvironmentVariables() throws Exception {
Map<String, String> env = ImmutableMap.of("P1", "simple", "P2", "spaces are not escaped", "P3", ":", "P4", "", "NONSENSE VARIABLE", "value");
SpawnInfo spawnInfo = createCopyFromWelcomeToDestination(env).getExtraActionInfo().build().getExtension(SpawnInfo.spawnInfo);
assertThat(env).hasSize(spawnInfo.getVariableCount());
for (EnvironmentVariable variable : spawnInfo.getVariableList()) {
assertThat(env).containsEntry(variable.getName(), variable.getValue());
}
}
use of com.google.devtools.build.lib.actions.extra.SpawnInfo in project bazel by bazelbuild.
the class SpawnActionTest method testExtraActionInfo.
@Test
public void testExtraActionInfo() throws Exception {
SpawnAction action = createCopyFromWelcomeToDestination(ImmutableMap.<String, String>of());
ExtraActionInfo info = action.getExtraActionInfo().build();
assertEquals("Dummy", info.getMnemonic());
SpawnInfo spawnInfo = info.getExtension(SpawnInfo.spawnInfo);
assertNotNull(spawnInfo);
assertThat(spawnInfo.getArgumentList()).containsExactlyElementsIn(action.getArguments());
Iterable<String> inputPaths = Artifact.toExecPaths(action.getInputs());
Iterable<String> outputPaths = Artifact.toExecPaths(action.getOutputs());
assertThat(spawnInfo.getInputFileList()).containsExactlyElementsIn(inputPaths);
assertThat(spawnInfo.getOutputFileList()).containsExactlyElementsIn(outputPaths);
Map<String, String> environment = action.getEnvironment();
assertEquals(environment.size(), spawnInfo.getVariableCount());
for (EnvironmentVariable variable : spawnInfo.getVariableList()) {
assertThat(environment).containsEntry(variable.getName(), variable.getValue());
}
}
use of com.google.devtools.build.lib.actions.extra.SpawnInfo in project heron by twitter.
the class PythonCheckstyle method getSourceFiles.
@SuppressWarnings("unchecked")
private static Collection<String> getSourceFiles(String extraActionFile) {
ExtraActionInfo info = ExtraActionUtils.getExtraActionInfo(extraActionFile);
SpawnInfo spawnInfo = info.getExtension(SpawnInfo.spawnInfo);
return Collections2.filter(spawnInfo.getInputFileList(), Predicates.and(Predicates.containsPattern(".*/src/.+\\.py[c]{0,1}$"), Predicates.not(Predicates.containsPattern("third_party/"))));
}
Aggregations