Search in sources :

Example 1 with BuildFileName

use of com.google.devtools.build.lib.skyframe.PackageLookupValue.BuildFileName in project bazel by bazelbuild.

the class PackageLookupFunction method computeExternalPackageLookupValue.

/**
   * Gets a PackageLookupValue from a different Bazel repository.
   *
   * <p>To do this, it looks up the "external" package and finds a path mapping for the repository
   * name.
   */
private PackageLookupValue computeExternalPackageLookupValue(SkyKey skyKey, Environment env, PackageIdentifier packageIdentifier) throws PackageLookupFunctionException, InterruptedException {
    PackageIdentifier id = (PackageIdentifier) skyKey.argument();
    SkyKey repositoryKey = RepositoryValue.key(id.getRepository());
    RepositoryValue repositoryValue;
    try {
        repositoryValue = (RepositoryValue) env.getValueOrThrow(repositoryKey, NoSuchPackageException.class, IOException.class, EvalException.class);
        if (repositoryValue == null) {
            return null;
        }
    } catch (NoSuchPackageException | IOException | EvalException e) {
        throw new PackageLookupFunctionException(new BuildFileNotFoundException(id, e.getMessage()), Transience.PERSISTENT);
    }
    // This checks for the build file names in the correct precedence order.
    for (BuildFileName buildFileName : buildFilesByPriority) {
        PathFragment buildFileFragment = id.getPackageFragment().getChild(buildFileName.getFilename());
        RootedPath buildFileRootedPath = RootedPath.toRootedPath(repositoryValue.getPath(), buildFileFragment);
        FileValue fileValue = getFileValue(buildFileRootedPath, env, packageIdentifier);
        if (fileValue == null) {
            return null;
        }
        if (fileValue.isFile()) {
            return PackageLookupValue.success(repositoryValue.getPath(), buildFileName);
        }
    }
    return PackageLookupValue.NO_BUILD_FILE_VALUE;
}
Also used : SkyKey(com.google.devtools.build.skyframe.SkyKey) BuildFileNotFoundException(com.google.devtools.build.lib.packages.BuildFileNotFoundException) PathFragment(com.google.devtools.build.lib.vfs.PathFragment) BuildFileName(com.google.devtools.build.lib.skyframe.PackageLookupValue.BuildFileName) IOException(java.io.IOException) EvalException(com.google.devtools.build.lib.syntax.EvalException) RootedPath(com.google.devtools.build.lib.vfs.RootedPath) PackageIdentifier(com.google.devtools.build.lib.cmdline.PackageIdentifier) NoSuchPackageException(com.google.devtools.build.lib.packages.NoSuchPackageException)

Aggregations

PackageIdentifier (com.google.devtools.build.lib.cmdline.PackageIdentifier)1 BuildFileNotFoundException (com.google.devtools.build.lib.packages.BuildFileNotFoundException)1 NoSuchPackageException (com.google.devtools.build.lib.packages.NoSuchPackageException)1 BuildFileName (com.google.devtools.build.lib.skyframe.PackageLookupValue.BuildFileName)1 EvalException (com.google.devtools.build.lib.syntax.EvalException)1 PathFragment (com.google.devtools.build.lib.vfs.PathFragment)1 RootedPath (com.google.devtools.build.lib.vfs.RootedPath)1 SkyKey (com.google.devtools.build.skyframe.SkyKey)1 IOException (java.io.IOException)1