From 812227f8733a2b6679cd9b06cea26fe238afb8dd Mon Sep 17 00:00:00 2001 From: Ulf Adams Date: Mon, 18 Apr 2016 13:22:27 +0000 Subject: Update the documentation for the Action class. -- MOS_MIGRATED_REVID=120117310 --- .../devtools/build/lib/actions/AbstractAction.java | 6 +-- .../google/devtools/build/lib/actions/Action.java | 53 ++++++++++++++++++++-- 2 files changed, 53 insertions(+), 6 deletions(-) (limited to 'src/main/java/com/google/devtools/build/lib/actions') diff --git a/src/main/java/com/google/devtools/build/lib/actions/AbstractAction.java b/src/main/java/com/google/devtools/build/lib/actions/AbstractAction.java index 70dac58587..d34fc3c60d 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/AbstractAction.java +++ b/src/main/java/com/google/devtools/build/lib/actions/AbstractAction.java @@ -40,9 +40,9 @@ import java.util.Collection; import javax.annotation.Nullable; /** - * Abstract implementation of Action which implements basic functionality: the - * inputs, outputs, and toString method. Both input and output sets are - * immutable. + * Abstract implementation of Action which implements basic functionality: the inputs, outputs, and + * toString method. Both input and output sets are immutable. Subclasses must be generally + * immutable - see the documentation on {@link Action}. */ @Immutable @ThreadSafe public abstract class AbstractAction implements Action, SkylarkValue { diff --git a/src/main/java/com/google/devtools/build/lib/actions/Action.java b/src/main/java/com/google/devtools/build/lib/actions/Action.java index e93b37aab1..51514af534 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/Action.java +++ b/src/main/java/com/google/devtools/build/lib/actions/Action.java @@ -26,9 +26,56 @@ import java.util.Collection; import javax.annotation.Nullable; /** - * An Action represents a function from Artifacts to Artifacts executed as an - * atomic build step. Examples include compilation of a single C++ source - * file, or linking a single library. + * An Action represents a function from Artifacts to Artifacts executed as an atomic build step. + * Examples include compilation of a single C++ source file, or linking a single library. + * + *

All subclasses of Action need to follow a strict set of invariants to ensure correctness on + * incremental builds. In our experience, getting this wrong is a lot more expensive than any + * benefits it might entail. + * + *

Use {@link com.google.devtools.build.lib.analysis.actions.SpawnAction} or {@link + * com.google.devtools.build.lib.analysis.actions.FileWriteAction} where possible, and avoid writing + * a new custom subclass. + * + *

These are the most important requirements for subclasses: + *

+ * + *

These constraints are not easily enforced or tested for (e.g., ActionTester only checks that a + * known set of fields is covered, not that all fields are covered), so carefully check all changes + * to action subclasses. */ public interface Action extends ActionMetadata, Describable { -- cgit v1.2.3