diff options
author | 2017-09-29 21:11:53 +0200 | |
---|---|---|
committer | 2017-10-02 10:31:16 +0200 | |
commit | ae32398146a05ecbe60966b0fe16e409e7b3e3ae (patch) | |
tree | 46cd486fb8277c98cdc11a4f427dc370c58354a7 /src/main/java/com/google/devtools/build/lib/actions/ArtifactFactory.java | |
parent | 5cc6246d429f7d9119b97ce263b4fd6893222e92 (diff) |
Don't symlink into the execroot if possible in SymlinkAction: instead, symlink directly to the target artifact. Also offer the option to not provide the package roots to create the execroot: we would like to avoid the execroot if possible.
PiperOrigin-RevId: 170515263
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/actions/ArtifactFactory.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/actions/ArtifactFactory.java | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/actions/ArtifactFactory.java b/src/main/java/com/google/devtools/build/lib/actions/ArtifactFactory.java index 2a1f6634cc..dd7211e666 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/ArtifactFactory.java +++ b/src/main/java/com/google/devtools/build/lib/actions/ArtifactFactory.java @@ -15,7 +15,6 @@ package com.google.devtools.build.lib.actions; import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; import com.google.devtools.build.lib.actions.Artifact.SpecialArtifactType; import com.google.devtools.build.lib.cmdline.PackageIdentifier; import com.google.devtools.build.lib.cmdline.RepositoryName; @@ -45,10 +44,10 @@ public class ArtifactFactory implements ArtifactResolver, ArtifactSerializer, Ar private final SourceArtifactCache sourceArtifactCache = new SourceArtifactCache(); /** - * Map of package names to source root paths so that we can create source - * artifact paths given execPaths in the symlink forest. + * Map of package names to source root paths so that we can create source artifact paths given + * execPaths in the symlink forest. */ - private ImmutableMap<PackageIdentifier, Root> packageRoots; + private PackageRoots.PackageRootLookup packageRoots; private ArtifactIdRegistry artifactIdRegistry = new ArtifactIdRegistry(); @@ -140,14 +139,13 @@ public class ArtifactFactory implements ArtifactResolver, ArtifactSerializer, Ar } /** - * Set the set of known packages and their corresponding source artifact - * roots. Must be called exactly once after construction or clear(). + * Set the set of known packages and their corresponding source artifact roots. Must be called + * exactly once after construction or clear(). * - * @param packageRoots the map of package names to source artifact roots to - * use. + * @param packageRoots provider of a source root given a package identifier. */ - public synchronized void setPackageRoots(Map<PackageIdentifier, Root> packageRoots) { - this.packageRoots = ImmutableMap.copyOf(packageRoots); + public synchronized void setPackageRoots(PackageRoots.PackageRootLookup packageRoots) { + this.packageRoots = packageRoots; sourceArtifactCache.newBuild(); } @@ -312,7 +310,13 @@ public class ArtifactFactory implements ArtifactResolver, ArtifactSerializer, Ar Root sourceRoot = findSourceRoot(execPath, baseExecPath, baseRoot, repositoryName); Artifact artifact = sourceArtifactCache.getArtifactIfValid(execPath); if (artifact != null) { - Preconditions.checkState(sourceRoot == null || sourceRoot.equals(artifact.getRoot())); + Root artifactRoot = artifact.getRoot(); + Preconditions.checkState( + sourceRoot == null || sourceRoot.equals(artifactRoot), + "roots mismatch: %s %s %s", + sourceRoot, + artifactRoot, + artifact); return artifact; } return createArtifactIfNotValid(sourceRoot, execPath); @@ -338,7 +342,8 @@ public class ArtifactFactory implements ArtifactResolver, ArtifactSerializer, Ar } while (dir != null && !dir.equals(baseExecPath)) { - Root sourceRoot = packageRoots.get(PackageIdentifier.create(repositoryName, dir)); + Root sourceRoot = + packageRoots.getRootForPackage(PackageIdentifier.create(repositoryName, dir)); if (sourceRoot != null) { return sourceRoot; } |