use of com.google.devtools.build.lib.actions.ActionExecutionException in project bazel by bazelbuild.
the class HeaderDiscovery method discoverInputsFromDotdFiles.
/**
* Returns a collection with additional input artifacts relevant to the action by reading the
* dynamically-discovered dependency information from the .d file after the action has run.
*
* <p>Artifacts are considered inputs but not "mandatory" inputs.
*
* @throws ActionExecutionException iff the .d is missing (when required), malformed, or has
* unresolvable included artifacts.
*/
@VisibleForTesting
@ThreadCompatible
public NestedSet<Artifact> discoverInputsFromDotdFiles(Path execRoot, ArtifactResolver artifactResolver) throws ActionExecutionException {
NestedSetBuilder<Artifact> inputs = NestedSetBuilder.stableOrder();
if (dotdFile == null) {
return inputs.build();
}
List<Path> systemIncludePrefixes = permittedSystemIncludePrefixes;
// Check inclusions.
IncludeProblems problems = new IncludeProblems();
for (Path execPath : depSet.getDependencies()) {
PathFragment execPathFragment = execPath.asFragment();
if (execPathFragment.isAbsolute()) {
// Absolute includes from system paths are ignored.
if (FileSystemUtils.startsWithAny(execPath, systemIncludePrefixes)) {
continue;
}
// the build with an error.
if (execPath.startsWith(execRoot)) {
// funky but tolerable path
execPathFragment = execPath.relativeTo(execRoot);
} else {
problems.add(execPathFragment.getPathString());
continue;
}
}
Artifact artifact = allowedDerivedInputsMap.get(execPathFragment);
if (artifact == null) {
try {
RepositoryName repository = PackageIdentifier.discoverFromExecPath(execPathFragment, false).getRepository();
artifact = artifactResolver.resolveSourceArtifact(execPathFragment, repository);
} catch (LabelSyntaxException e) {
throw new ActionExecutionException(String.format("Could not find the external repository for %s", execPathFragment), e, action, false);
}
}
if (artifact != null) {
inputs.add(artifact);
// to the set of actual inputs.
if (specialInputsHandler != null) {
inputs.addAll(specialInputsHandler.getInputsForIncludedFile(artifact, artifactResolver));
}
} else {
// Abort if we see files that we can't resolve, likely caused by
// undeclared includes or illegal include constructs.
problems.add(execPathFragment.getPathString());
}
}
if (shouldValidateInclusions) {
problems.assertProblemFree(action, sourceFile);
}
return inputs.build();
}
use of com.google.devtools.build.lib.actions.ActionExecutionException in project bazel by bazelbuild.
the class LTOBackendAction method discoverInputs.
@Nullable
@Override
public Iterable<Artifact> discoverInputs(ActionExecutionContext actionExecutionContext) throws ActionExecutionException, InterruptedException {
// Build set of files this LTO backend artifact will import from.
HashSet<PathFragment> importSet = new HashSet<>();
try {
for (String line : FileSystemUtils.iterateLinesAsLatin1(imports.getPath())) {
if (!line.isEmpty()) {
PathFragment execPath = new PathFragment(line);
if (execPath.isAbsolute()) {
throw new ActionExecutionException("Absolute paths not allowed in imports file " + imports.getPath() + ": " + execPath, this, false);
}
importSet.add(new PathFragment(line));
}
}
} catch (IOException e) {
throw new ActionExecutionException("error iterating imports file " + imports.getPath(), e, this, false);
}
// Convert the import set of paths to the set of bitcode file artifacts.
Set<Artifact> bitcodeInputSet = computeBitcodeInputs(importSet);
if (bitcodeInputSet.size() != importSet.size()) {
throw new ActionExecutionException("error computing inputs from imports file " + imports.getPath(), this, false);
}
updateInputs(createInputs(bitcodeInputSet, getMandatoryInputs()));
return bitcodeInputSet;
}
use of com.google.devtools.build.lib.actions.ActionExecutionException in project bazel by bazelbuild.
the class SolibSymlinkAction method execute.
@Override
public void execute(ActionExecutionContext actionExecutionContext) throws ActionExecutionException {
Path mangledPath = symlink.getPath();
try {
FileSystemUtils.createDirectoryAndParents(mangledPath.getParentDirectory());
mangledPath.createSymbolicLink(target);
} catch (IOException e) {
throw new ActionExecutionException("failed to create _solib symbolic link '" + symlink.prettyPrint() + "' to target '" + target + "'", e, this, false);
}
}
use of com.google.devtools.build.lib.actions.ActionExecutionException in project bazel by bazelbuild.
the class CreateIncSymlinkAction method execute.
@Override
public void execute(ActionExecutionContext actionExecutionContext) throws ActionExecutionException {
try {
for (Map.Entry<Artifact, Artifact> entry : symlinks.entrySet()) {
Path symlink = entry.getKey().getPath();
symlink.createSymbolicLink(entry.getValue().getPath());
}
} catch (IOException e) {
String message = "IO Error while creating symlink";
throw new ActionExecutionException(message, e, this, false);
}
}
use of com.google.devtools.build.lib.actions.ActionExecutionException in project bazel by bazelbuild.
the class ExtractInclusionAction method execute.
@Override
public void execute(ActionExecutionContext actionExecutionContext) throws ActionExecutionException, InterruptedException {
Executor executor = actionExecutionContext.getExecutor();
IncludeScanningContext context = executor.getContext(IncludeScanningContext.class);
try {
context.extractIncludes(actionExecutionContext, this, getPrimaryInput(), getPrimaryOutput());
} catch (IOException e) {
throw new ActionExecutionException(e, this, false);
} catch (ExecException e) {
throw e.toActionExecutionException(this);
}
}
Aggregations