Search in sources :

Example 16 with ActionExecutionException

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();
}
Also used : Path(com.google.devtools.build.lib.vfs.Path) LabelSyntaxException(com.google.devtools.build.lib.cmdline.LabelSyntaxException) PathFragment(com.google.devtools.build.lib.vfs.PathFragment) RepositoryName(com.google.devtools.build.lib.cmdline.RepositoryName) ActionExecutionException(com.google.devtools.build.lib.actions.ActionExecutionException) Artifact(com.google.devtools.build.lib.actions.Artifact) VisibleForTesting(com.google.common.annotations.VisibleForTesting) ThreadCompatible(com.google.devtools.build.lib.concurrent.ThreadSafety.ThreadCompatible)

Example 17 with ActionExecutionException

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;
}
Also used : PathFragment(com.google.devtools.build.lib.vfs.PathFragment) ActionExecutionException(com.google.devtools.build.lib.actions.ActionExecutionException) IOException(java.io.IOException) Artifact(com.google.devtools.build.lib.actions.Artifact) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) Nullable(javax.annotation.Nullable)

Example 18 with ActionExecutionException

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);
    }
}
Also used : Path(com.google.devtools.build.lib.vfs.Path) IOException(java.io.IOException) ActionExecutionException(com.google.devtools.build.lib.actions.ActionExecutionException)

Example 19 with ActionExecutionException

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);
    }
}
Also used : Path(com.google.devtools.build.lib.vfs.Path) IOException(java.io.IOException) ActionExecutionException(com.google.devtools.build.lib.actions.ActionExecutionException) Map(java.util.Map) ImmutableSortedMap(com.google.common.collect.ImmutableSortedMap) SortedMap(java.util.SortedMap) Artifact(com.google.devtools.build.lib.actions.Artifact)

Example 20 with ActionExecutionException

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);
    }
}
Also used : Executor(com.google.devtools.build.lib.actions.Executor) ExecException(com.google.devtools.build.lib.actions.ExecException) IOException(java.io.IOException) ActionExecutionException(com.google.devtools.build.lib.actions.ActionExecutionException)

Aggregations

ActionExecutionException (com.google.devtools.build.lib.actions.ActionExecutionException)26 Artifact (com.google.devtools.build.lib.actions.Artifact)15 IOException (java.io.IOException)14 ActionExecutionContext (com.google.devtools.build.lib.actions.ActionExecutionContext)6 AlreadyReportedActionExecutionException (com.google.devtools.build.lib.actions.AlreadyReportedActionExecutionException)6 Path (com.google.devtools.build.lib.vfs.Path)5 Map (java.util.Map)5 Test (org.junit.Test)5 Action (com.google.devtools.build.lib.actions.Action)4 BuildFailedException (com.google.devtools.build.lib.actions.BuildFailedException)4 Executor (com.google.devtools.build.lib.actions.Executor)4 MissingInputFileException (com.google.devtools.build.lib.actions.MissingInputFileException)4 SkyKey (com.google.devtools.build.skyframe.SkyKey)4 TreeFileArtifact (com.google.devtools.build.lib.actions.Artifact.TreeFileArtifact)3 ExecException (com.google.devtools.build.lib.actions.ExecException)3 ThreadCompatible (com.google.devtools.build.lib.concurrent.ThreadSafety.ThreadCompatible)3 ValueOrException2 (com.google.devtools.build.skyframe.ValueOrException2)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 SpecialArtifact (com.google.devtools.build.lib.actions.Artifact.SpecialArtifact)2 ArtifactPrefixConflictException (com.google.devtools.build.lib.actions.ArtifactPrefixConflictException)2