From 889bbe55d21d646d45c99208d595c7b9566ea662 Mon Sep 17 00:00:00 2001 From: ulfjack Date: Wed, 10 May 2017 06:52:23 -0400 Subject: Add a custom interface for cache hit processing in actions The new interface mirrors ActionExecutionContext, but is restricted to exactly the parts used right now. I did consider using ActionExecutionContext, but it contains some parts that we don't want to make available for cache hits. The end goal is to allow the build event stream access to artifact metadata, in particular for TestResult and TestSummary events, which in turn requires making artifact metadata available when the TestRunnerAction is a cache hit. PiperOrigin-RevId: 155612573 --- .../build/lib/actions/NotifyOnActionCacheHit.java | 34 ++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'src/main/java/com/google/devtools/build/lib/actions/NotifyOnActionCacheHit.java') diff --git a/src/main/java/com/google/devtools/build/lib/actions/NotifyOnActionCacheHit.java b/src/main/java/com/google/devtools/build/lib/actions/NotifyOnActionCacheHit.java index ac58b89f4a..89c9a20c2e 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/NotifyOnActionCacheHit.java +++ b/src/main/java/com/google/devtools/build/lib/actions/NotifyOnActionCacheHit.java @@ -14,17 +14,47 @@ package com.google.devtools.build.lib.actions; +import com.google.common.eventbus.EventBus; +import com.google.devtools.build.lib.actions.Executor.ActionContext; +import com.google.devtools.build.lib.events.EventHandler; +import com.google.devtools.build.lib.vfs.Path; + /** * An action which must know when it is skipped due to an action cache hit. * * Use should be rare, as the action graph is a functional model. */ public interface NotifyOnActionCacheHit extends Action { + /** + * A custom interface similar to {@link ActionExecutionContext}, but specific to cache hits. + */ + public interface ActionCachedContext { + /** + * An event listener to report messages to. Errors that signal a action failure should + * use ActionExecutionException. + */ + EventHandler getEventHandler(); + + /** The EventBus for the current build. */ + EventBus getEventBus(); + + /** + * Returns the execution root. This is the directory underneath which Blaze builds its entire + * output working tree, including the source symlink forest. All build actions are executed + * relative to this directory. + */ + Path getExecRoot(); + + /** + * Looks up and returns an action context implementation of the given interface type. + */ + T getContext(Class type); + } /** * Called when action has "cache hit", and therefore need not be executed. * - * @param executor the executor + * @param context the action context for a cache hit */ - void actionCacheHit(Executor executor); + void actionCacheHit(ActionCachedContext context); } -- cgit v1.2.3