Make Artifact an abstract class, and break out a DerivedArtifact subclass. This will facilitate future refactorings in which a DerivedArtifact will have an ActionLookupData "owner", while a SourceArtifact will have a Label owner (or an ArtifactOwner, depending on how lazy I am).
I verified using the test in ArtifactTest, modified to use dummy classes, that derived artifacts don't use any more memory with this refactoring than they did before.
PiperOrigin-RevId: 249535371
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/ArtifactFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/ArtifactFunctionTest.java
index 7b25f59..f6f8a8b 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/ArtifactFunctionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/ArtifactFunctionTest.java
@@ -322,19 +322,15 @@
}
private Artifact createSourceArtifact(String path) {
- return new Artifact.SourceArtifact(
- ArtifactRoot.asSourceRoot(Root.fromPath(root)),
- PathFragment.create(path),
- ArtifactOwner.NullArtifactOwner.INSTANCE);
+ return ActionsTestUtil.createArtifactWithExecPath(
+ ArtifactRoot.asSourceRoot(Root.fromPath(root)), PathFragment.create(path));
}
private Artifact createDerivedArtifact(String path) {
PathFragment execPath = PathFragment.create("out").getRelative(path);
Artifact output =
- new Artifact(
- ArtifactRoot.asDerivedRoot(root, root.getRelative("out")),
- execPath,
- ALL_OWNER);
+ new Artifact.DerivedArtifact(
+ ArtifactRoot.asDerivedRoot(root, root.getRelative("out")), execPath, ALL_OWNER);
actions.add(new DummyAction(ImmutableList.<Artifact>of(), output));
return output;
}
@@ -342,7 +338,8 @@
private Artifact createMiddlemanArtifact(String path) {
ArtifactRoot middlemanRoot =
ArtifactRoot.middlemanRoot(middlemanPath, middlemanPath.getRelative("out"));
- return new Artifact(middlemanRoot, middlemanRoot.getExecPath().getRelative(path), ALL_OWNER);
+ return new Artifact.DerivedArtifact(
+ middlemanRoot, middlemanRoot.getExecPath().getRelative(path), ALL_OWNER);
}
private SpecialArtifact createDerivedTreeArtifactWithAction(String path) {