aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Kristina Chodorow <kchodorow@google.com>2016-09-09 14:09:51 +0000
committerGravatar Kristina Chodorow <kchodorow@google.com>2016-09-09 14:18:10 +0000
commitd07177d0e628bd86a212eb6b68da2de2b02572fa (patch)
treea2a4a34c2de7ff3639896649180a9f09b96e5896
parent8d2dd4b0e4d73af878eeba80fc8db7fb292bfc35 (diff)
Add repository parameter to source artifact resolver
Needed for #1262. Doesn't do anything, yet, other than make the CL smaller. -- MOS_MIGRATED_REVID=132671036
-rw-r--r--src/main/java/com/google/devtools/build/lib/actions/ArtifactFactory.java3
-rw-r--r--src/main/java/com/google/devtools/build/lib/actions/ArtifactResolver.java4
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/HeaderDiscovery.java3
-rw-r--r--src/test/java/com/google/devtools/build/lib/actions/ArtifactFactoryTest.java21
4 files changed, 19 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 973e95de5e..bba49288b0 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
@@ -348,7 +348,8 @@ public class ArtifactFactory implements ArtifactResolver, ArtifactSerializer, Ar
}
@Override
- public Artifact resolveSourceArtifact(PathFragment execPath) {
+ public Artifact resolveSourceArtifact(PathFragment execPath,
+ @SuppressWarnings("unused") RepositoryName repositoryName) {
return resolveSourceArtifactWithAncestor(execPath, null, null);
}
diff --git a/src/main/java/com/google/devtools/build/lib/actions/ArtifactResolver.java b/src/main/java/com/google/devtools/build/lib/actions/ArtifactResolver.java
index 58b36c9371..7bb3b01139 100644
--- a/src/main/java/com/google/devtools/build/lib/actions/ArtifactResolver.java
+++ b/src/main/java/com/google/devtools/build/lib/actions/ArtifactResolver.java
@@ -14,6 +14,7 @@
package com.google.devtools.build.lib.actions;
+import com.google.devtools.build.lib.cmdline.RepositoryName;
import com.google.devtools.build.lib.vfs.PathFragment;
import java.util.Map;
import javax.annotation.Nullable;
@@ -51,10 +52,11 @@ public interface ArtifactResolver {
* post-compile .d or manifest scanning methods.
*
* @param execPath the exec path of the artifact to resolve
+ * @param repositoryName the name of repository this artifact belongs to
* @return an existing or new source Artifact for the given execPath. Returns null if
* the root can not be determined and the artifact did not exist before.
*/
- Artifact resolveSourceArtifact(PathFragment execPath);
+ Artifact resolveSourceArtifact(PathFragment execPath, RepositoryName repositoryName);
/**
* Resolves source Artifacts given execRoot-relative paths.
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/HeaderDiscovery.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/HeaderDiscovery.java
index 96c7b816b5..512281ad93 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/HeaderDiscovery.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/HeaderDiscovery.java
@@ -20,6 +20,7 @@ import com.google.devtools.build.lib.actions.Action;
import com.google.devtools.build.lib.actions.ActionExecutionException;
import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.actions.ArtifactResolver;
+import com.google.devtools.build.lib.cmdline.RepositoryName;
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
import com.google.devtools.build.lib.concurrent.ThreadSafety.ThreadCompatible;
@@ -119,7 +120,7 @@ public class HeaderDiscovery {
}
Artifact artifact = allowedDerivedInputsMap.get(execPathFragment);
if (artifact == null) {
- artifact = artifactResolver.resolveSourceArtifact(execPathFragment);
+ artifact = artifactResolver.resolveSourceArtifact(execPathFragment, RepositoryName.MAIN);
}
if (artifact != null) {
inputs.add(artifact);
diff --git a/src/test/java/com/google/devtools/build/lib/actions/ArtifactFactoryTest.java b/src/test/java/com/google/devtools/build/lib/actions/ArtifactFactoryTest.java
index cfdeef4797..c0bec56609 100644
--- a/src/test/java/com/google/devtools/build/lib/actions/ArtifactFactoryTest.java
+++ b/src/test/java/com/google/devtools/build/lib/actions/ArtifactFactoryTest.java
@@ -28,6 +28,7 @@ import com.google.common.collect.Maps;
import com.google.devtools.build.lib.actions.MutableActionGraph.ActionConflictException;
import com.google.devtools.build.lib.actions.util.ActionsTestUtil;
import com.google.devtools.build.lib.cmdline.PackageIdentifier;
+import com.google.devtools.build.lib.cmdline.RepositoryName;
import com.google.devtools.build.lib.testutil.Scratch;
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.PathFragment;
@@ -50,6 +51,8 @@ import javax.annotation.Nullable;
@RunWith(JUnit4.class)
public class ArtifactFactoryTest {
+ private static final RepositoryName MAIN = RepositoryName.MAIN;
+
private Scratch scratch = new Scratch();
private Path execRoot;
@@ -120,31 +123,31 @@ public class ArtifactFactoryTest {
@Test
public void testResolveArtifact_noDerived_simpleSource() throws Exception {
assertSame(artifactFactory.getSourceArtifact(fooRelative, clientRoot),
- artifactFactory.resolveSourceArtifact(fooRelative));
+ artifactFactory.resolveSourceArtifact(fooRelative, MAIN));
assertSame(artifactFactory.getSourceArtifact(barRelative, clientRoRoot),
- artifactFactory.resolveSourceArtifact(barRelative));
+ artifactFactory.resolveSourceArtifact(barRelative, MAIN));
}
@Test
public void testResolveArtifact_inExternalRepo() throws Exception {
assertSame(
artifactFactory.getSourceArtifact(alienRelative, alienRoot),
- artifactFactory.resolveSourceArtifact(alienRelative));
+ artifactFactory.resolveSourceArtifact(alienRelative, MAIN));
}
@Test
public void testResolveArtifact_noDerived_derivedRoot() throws Exception {
assertNull(artifactFactory.resolveSourceArtifact(
- outRoot.getPath().getRelative(fooRelative).relativeTo(execRoot)));
+ outRoot.getPath().getRelative(fooRelative).relativeTo(execRoot), MAIN));
assertNull(artifactFactory.resolveSourceArtifact(
- outRoot.getPath().getRelative(barRelative).relativeTo(execRoot)));
+ outRoot.getPath().getRelative(barRelative).relativeTo(execRoot), MAIN));
}
@Test
public void testResolveArtifact_noDerived_simpleSource_other() throws Exception {
- Artifact actual = artifactFactory.resolveSourceArtifact(fooRelative);
+ Artifact actual = artifactFactory.resolveSourceArtifact(fooRelative, MAIN);
assertSame(artifactFactory.getSourceArtifact(fooRelative, clientRoot), actual);
- actual = artifactFactory.resolveSourceArtifact(barRelative);
+ actual = artifactFactory.resolveSourceArtifact(barRelative, MAIN);
assertSame(artifactFactory.getSourceArtifact(barRelative, clientRoRoot), actual);
}
@@ -158,9 +161,9 @@ public class ArtifactFactoryTest {
PathFragment outsideWorkspace = new PathFragment("../foo");
PathFragment insideWorkspace =
new PathFragment("../" + clientRoot.getPath().getBaseName() + "/foo");
- assertNull(artifactFactory.resolveSourceArtifact(outsideWorkspace));
+ assertNull(artifactFactory.resolveSourceArtifact(outsideWorkspace, MAIN));
assertNull("Up-level-containing paths that descend into the right workspace aren't allowed",
- artifactFactory.resolveSourceArtifact(insideWorkspace));
+ artifactFactory.resolveSourceArtifact(insideWorkspace, MAIN));
MockPackageRootResolver packageRootResolver = new MockPackageRootResolver();
packageRootResolver.setPackageRoots(packageRoots);
Map<PathFragment, Artifact> result = new HashMap<>();