diff options
author | cpeyser <cpeyser@google.com> | 2018-03-02 10:20:15 -0800 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-03-02 10:22:30 -0800 |
commit | eee53d3a33dde441f7e7adaecde81ef2d3db7c1b (patch) | |
tree | 0c6ddd2c54993b9b919e2e59faa0ddd1de117bb0 /src/main/java/com/google/devtools/build/lib/rules | |
parent | d1201c8e61ee77feabeb83da88e0eae049087a09 (diff) |
@AutoCodec ConfiguredTargetValue.
PiperOrigin-RevId: 187635570
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules')
3 files changed, 27 insertions, 6 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/AliasConfiguredTarget.java b/src/main/java/com/google/devtools/build/lib/rules/AliasConfiguredTarget.java index d591aa2dc1..41558655f3 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/AliasConfiguredTarget.java +++ b/src/main/java/com/google/devtools/build/lib/rules/AliasConfiguredTarget.java @@ -27,6 +27,8 @@ import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable; import com.google.devtools.build.lib.events.Location; import com.google.devtools.build.lib.packages.Info; import com.google.devtools.build.lib.packages.Provider; +import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec; +import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec.VisibleForSerialization; import com.google.devtools.build.lib.skylarkinterface.SkylarkPrinter; import com.google.devtools.build.lib.syntax.ClassObject; import com.google.devtools.build.lib.syntax.EvalException; @@ -39,6 +41,7 @@ import javax.annotation.Nullable; * * <p>Transitive info providers can also be overridden. */ +@AutoCodec @Immutable public final class AliasConfiguredTarget implements ConfiguredTarget, ClassObject { private final Label label; @@ -51,10 +54,24 @@ public final class AliasConfiguredTarget implements ConfiguredTarget, ClassObjec RuleContext ruleContext, ConfiguredTarget actual, ImmutableMap<Class<? extends TransitiveInfoProvider>, TransitiveInfoProvider> overrides) { - this.label = ruleContext.getLabel(); - this.configuration = Preconditions.checkNotNull(ruleContext.getConfiguration()); - this.actual = Preconditions.checkNotNull(actual); - this.overrides = Preconditions.checkNotNull(overrides); + this( + ruleContext.getLabel(), + Preconditions.checkNotNull(ruleContext.getConfiguration()), + Preconditions.checkNotNull(actual), + Preconditions.checkNotNull(overrides)); + } + + @AutoCodec.Instantiator + @VisibleForSerialization + AliasConfiguredTarget( + Label label, + BuildConfiguration configuration, + ConfiguredTarget actual, + ImmutableMap<Class<? extends TransitiveInfoProvider>, TransitiveInfoProvider> overrides) { + this.label = label; + this.configuration = configuration; + this.actual = actual; + this.overrides = overrides; } @Override diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLinkParams.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLinkParams.java index 731357c4cd..a842b86be9 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLinkParams.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLinkParams.java @@ -47,15 +47,17 @@ public final class CcLinkParams { /** * A list of link options contributed by a single configured target. * - * <b>WARNING:</b> Do not implement {@code #equals()} in the obvious way. This class must be + * <p><b>WARNING:</b> Do not implement {@code #equals()} in the obvious way. This class must be * checked for equality by object identity because otherwise if two configured targets contribute * the same link options, they will be de-duplicated, which is not the desirable behavior. */ + @AutoCodec @Immutable public static final class LinkOptions { private final ImmutableList<String> linkOptions; - private LinkOptions(Iterable<String> linkOptions) { + @VisibleForSerialization + LinkOptions(Iterable<String> linkOptions) { this.linkOptions = ImmutableList.copyOf(linkOptions); } diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcSkylarkApiProvider.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcSkylarkApiProvider.java index 4c327cb993..95a5a9436a 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcSkylarkApiProvider.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcSkylarkApiProvider.java @@ -19,6 +19,7 @@ import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.analysis.skylark.SkylarkApiProvider; import com.google.devtools.build.lib.collect.nestedset.NestedSet; import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder; +import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec; import com.google.devtools.build.lib.skylarkinterface.SkylarkCallable; import com.google.devtools.build.lib.skylarkinterface.SkylarkModule; import com.google.devtools.build.lib.skylarkinterface.SkylarkModuleCategory; @@ -36,6 +37,7 @@ import com.google.devtools.build.lib.vfs.PathFragment; + "Every C++-related target provides this struct, accessible as a <code>cc</code> field " + "on <a href=\"Target.html\">target</a>." ) +@AutoCodec public final class CcSkylarkApiProvider extends SkylarkApiProvider { /** The name of the field in Skylark used to access this class. */ public static final String NAME = "cc"; |