Skip to content

Commit

Permalink
Make tree artifact directory creation ActionFS-aware.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 211471272
  • Loading branch information
ericfelly authored and Copybara-Service committed Sep 4, 2018
1 parent d8598b5 commit bb07aa9
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ void executeBuild(

ActionGraph actionGraph = analysisResult.getActionGraph();


OutputService outputService = env.getOutputService();
ModifiedFileSet modifiedOutputFiles = ModifiedFileSet.EVERYTHING_MODIFIED;
if (outputService != null) {
Expand All @@ -241,8 +240,10 @@ void executeBuild(
}
}

// Must be created after the output path is created above.
createActionLogDirectory();
if (outputService == null || !outputService.supportsActionFileSystem()) {
// Must be created after the output path is created above.
createActionLogDirectory();
}

// Create convenience symlinks from the configurations actually used by the requested targets.
// Symlinks will be created if all such configurations would point the symlink to the same path;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.google.common.base.Function;
import com.google.common.base.Preconditions;
import com.google.common.base.Predicate;
import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
Expand Down Expand Up @@ -51,6 +52,12 @@
/** A builder of values for {@link ArtifactSkyKey} keys. */
class ArtifactFunction implements SkyFunction {

private final Supplier<Boolean> usesActionFS;

public ArtifactFunction(Supplier<Boolean> usesActionFS) {
this.usesActionFS = usesActionFS;
}

@Override
public SkyValue compute(SkyKey skyKey, Environment env)
throws ArtifactFunctionException, InterruptedException {
Expand Down Expand Up @@ -87,16 +94,18 @@ public SkyValue compute(SkyKey skyKey, Environment env)
// actions, execute those actions in parallel and then aggregate the action execution results.
if (artifact.isTreeArtifact() && actionLookupValue.isActionTemplate(actionIndex)) {
// Create the directory structures for the output TreeArtifact first.
try {
artifact.getPath().createDirectoryAndParents();
} catch (IOException e) {
env.getListener()
.handle(
Event.error(
String.format(
"Failed to create output directory for TreeArtifact %s: %s",
artifact, e.getMessage())));
throw new ArtifactFunctionException(e, Transience.TRANSIENT);
if (!usesActionFS.get()) {
try {
artifact.getPath().createDirectoryAndParents();
} catch (IOException e) {
env.getListener()
.handle(
Event.error(
String.format(
"Failed to create output directory for TreeArtifact %s: %s",
artifact, e.getMessage())));
throw new ArtifactFunctionException(e, Transience.TRANSIENT);
}
}

return createTreeArtifactValueFromActionKey(actionLookupKey, actionIndex, artifact, env);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ private ImmutableMap<SkyFunctionName, SkyFunction> skyFunctions(
SkyFunctions.ASPECT_COMPLETION,
CompletionFunction.aspectCompletionFunction(pathResolverFactory));
map.put(SkyFunctions.TEST_COMPLETION, new TestCompletionFunction());
map.put(Artifact.ARTIFACT, new ArtifactFunction());
map.put(Artifact.ARTIFACT, new ArtifactFunction(skyframeActionExecutor::usesActionFileSystem));
map.put(
SkyFunctions.BUILD_INFO_COLLECTION,
new BuildInfoCollectionFunction(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.
package com.google.devtools.build.lib.skyframe;

import com.google.common.base.Suppliers;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.devtools.build.lib.actions.ActionAnalysisMetadata;
Expand Down Expand Up @@ -97,7 +98,7 @@ public void baseSetUp() throws Exception {
new FileStateFunction(
new AtomicReference<TimestampGranularityMonitor>(), externalFilesHelper))
.put(FileValue.FILE, new FileFunction(pkgLocator))
.put(Artifact.ARTIFACT, new ArtifactFunction())
.put(Artifact.ARTIFACT, new ArtifactFunction(Suppliers.ofInstance(false)))
.put(SkyFunctions.ACTION_EXECUTION, new SimpleActionExecutionFunction())
.put(
SkyFunctions.PACKAGE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.google.common.base.Preconditions;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import com.google.common.base.Suppliers;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
Expand Down Expand Up @@ -215,7 +216,7 @@ protected Builder createBuilder(
ImmutableMap.<SkyFunctionName, SkyFunction>builder()
.put(FileStateValue.FILE_STATE, new FileStateFunction(tsgmRef, externalFilesHelper))
.put(FileValue.FILE, new FileFunction(pkgLocator))
.put(Artifact.ARTIFACT, new ArtifactFunction())
.put(Artifact.ARTIFACT, new ArtifactFunction(Suppliers.ofInstance(false)))
.put(
SkyFunctions.ACTION_EXECUTION,
new ActionExecutionFunction(skyframeActionExecutor, directories, tsgmRef))
Expand Down

0 comments on commit bb07aa9

Please sign in to comment.