diff options
Diffstat (limited to 'src/main/java/com')
14 files changed, 111 insertions, 59 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/BUILD b/src/main/java/com/google/devtools/build/lib/BUILD index f1833dc226..af0b5edc2d 100644 --- a/src/main/java/com/google/devtools/build/lib/BUILD +++ b/src/main/java/com/google/devtools/build/lib/BUILD @@ -641,6 +641,7 @@ java_library( "//src/main/java/com/google/devtools/build/lib/remote", "//src/main/java/com/google/devtools/build/lib/sandbox", "//src/main/java/com/google/devtools/build/lib/shell", + "//src/main/java/com/google/devtools/build/lib/skyframe/serialization/autocodec", "//src/main/java/com/google/devtools/build/lib/ssd", "//src/main/java/com/google/devtools/build/lib/standalone", "//src/main/java/com/google/devtools/build/lib/vfs", diff --git a/src/main/java/com/google/devtools/build/lib/actions/ActionLookupValue.java b/src/main/java/com/google/devtools/build/lib/actions/ActionLookupValue.java index f02185ba2b..08b0c6d55d 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/ActionLookupValue.java +++ b/src/main/java/com/google/devtools/build/lib/actions/ActionLookupValue.java @@ -18,6 +18,7 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.concurrent.ThreadSafety.ThreadSafe; +import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec; import com.google.devtools.build.skyframe.SkyKey; import com.google.devtools.build.skyframe.SkyValue; import java.util.ArrayList; @@ -30,7 +31,7 @@ import javax.annotation.Nullable; */ public abstract class ActionLookupValue implements SkyValue { - private final boolean removeActionsAfterEvaluation; + @AutoCodec.VisibleForSerialization protected final boolean removeActionsAfterEvaluation; public ActionLookupValue(boolean removeActionsAfterEvaluation) { this.removeActionsAfterEvaluation = removeActionsAfterEvaluation; diff --git a/src/main/java/com/google/devtools/build/lib/analysis/AliasProvider.java b/src/main/java/com/google/devtools/build/lib/analysis/AliasProvider.java index ce3957e1d1..3633fd2190 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/AliasProvider.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/AliasProvider.java @@ -19,10 +19,10 @@ import com.google.common.collect.ImmutableList; import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable; import com.google.devtools.build.lib.skyframe.ConfiguredTargetAndData; +import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec; -/** - * A provider that gives information about the aliases a rule was resolved through. - */ +/** A provider that gives information about the aliases a rule was resolved through. */ +@AutoCodec @Immutable public final class AliasProvider implements TransitiveInfoProvider { // We don't expect long alias chains, so it's better to have a list instead of a nested set diff --git a/src/main/java/com/google/devtools/build/lib/analysis/WorkspaceStatusAction.java b/src/main/java/com/google/devtools/build/lib/analysis/WorkspaceStatusAction.java index ae70debbf6..547c6c7dfd 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/WorkspaceStatusAction.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/WorkspaceStatusAction.java @@ -23,6 +23,7 @@ import com.google.devtools.build.lib.actions.ActionOwner; import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.actions.ArtifactFactory; import com.google.devtools.build.lib.actions.ArtifactOwner; +import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec; import com.google.devtools.build.lib.util.OptionsUtils; import com.google.devtools.build.lib.vfs.FileSystemUtils; import com.google.devtools.build.lib.vfs.Path; @@ -53,9 +54,8 @@ import java.util.UUID; */ public abstract class WorkspaceStatusAction extends AbstractAction { - /** - * Options controlling the workspace status command. - */ + /** Options controlling the workspace status command. */ + @AutoCodec(strategy = AutoCodec.Strategy.PUBLIC_FIELDS) public static class Options extends OptionsBase { @Option( name = "embed_label", diff --git a/src/main/java/com/google/devtools/build/lib/analysis/buildinfo/BuildInfoCollection.java b/src/main/java/com/google/devtools/build/lib/analysis/buildinfo/BuildInfoCollection.java index 258c463784..a35e8841cc 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/buildinfo/BuildInfoCollection.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/buildinfo/BuildInfoCollection.java @@ -16,12 +16,11 @@ package com.google.devtools.build.lib.analysis.buildinfo; import com.google.common.collect.ImmutableList; import com.google.devtools.build.lib.actions.ActionAnalysisMetadata; import com.google.devtools.build.lib.actions.Artifact; - +import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec; import java.util.List; -/** - * A collection of build-info files for both stamped and unstamped modes. - */ +/** A collection of build-info files for both stamped and unstamped modes. */ +@AutoCodec public final class BuildInfoCollection { private final ImmutableList<ActionAnalysisMetadata> actions; private final ImmutableList<Artifact> stampedBuildInfo; @@ -29,9 +28,21 @@ public final class BuildInfoCollection { public BuildInfoCollection(List<? extends ActionAnalysisMetadata> actions, List<Artifact> stampedBuildInfo, List<Artifact> redactedBuildInfo) { - this.actions = ImmutableList.copyOf(actions); - this.stampedBuildInfo = ImmutableList.copyOf(stampedBuildInfo); - this.redactedBuildInfo = ImmutableList.copyOf(redactedBuildInfo); + this( + ImmutableList.copyOf(actions), + ImmutableList.copyOf(stampedBuildInfo), + ImmutableList.copyOf(redactedBuildInfo)); + } + + @AutoCodec.Instantiator + @AutoCodec.VisibleForSerialization + BuildInfoCollection( + ImmutableList<ActionAnalysisMetadata> actions, + ImmutableList<Artifact> stampedBuildInfo, + ImmutableList<Artifact> redactedBuildInfo) { + this.actions = actions; + this.stampedBuildInfo = stampedBuildInfo; + this.redactedBuildInfo = redactedBuildInfo; } public ImmutableList<ActionAnalysisMetadata> getActions() { diff --git a/src/main/java/com/google/devtools/build/lib/bazel/BazelWorkspaceStatusModule.java b/src/main/java/com/google/devtools/build/lib/bazel/BazelWorkspaceStatusModule.java index c3fc49979a..bf7d4b1d86 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/BazelWorkspaceStatusModule.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/BazelWorkspaceStatusModule.java @@ -50,6 +50,7 @@ import com.google.devtools.build.lib.runtime.WorkspaceBuilder; import com.google.devtools.build.lib.shell.BadExitStatusException; import com.google.devtools.build.lib.shell.CommandException; import com.google.devtools.build.lib.shell.CommandResult; +import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec; import com.google.devtools.build.lib.util.CommandBuilder; import com.google.devtools.build.lib.util.Fingerprint; import com.google.devtools.build.lib.util.NetUtil; @@ -73,18 +74,24 @@ import java.util.UUID; * invalidate the node representing the workspace status action. */ public class BazelWorkspaceStatusModule extends BlazeModule { - private static class BazelWorkspaceStatusAction extends WorkspaceStatusAction { + @AutoCodec + @AutoCodec.VisibleForSerialization + static class BazelWorkspaceStatusAction extends WorkspaceStatusAction { private final Artifact stableStatus; private final Artifact volatileStatus; private final Options options; private final String username; private final String hostname; private final com.google.devtools.build.lib.shell.Command getWorkspaceStatusCommand; - private final Map<String, String> clientEnv; + private final ImmutableMap<String, String> clientEnv; - private BazelWorkspaceStatusAction( + @SuppressWarnings("unused") // Read by serialization. + private final Path workspace; + + @AutoCodec.VisibleForSerialization + BazelWorkspaceStatusAction( WorkspaceStatusAction.Options options, - Map<String, String> clientEnv, + ImmutableMap<String, String> clientEnv, Path workspace, Artifact stableStatus, Artifact volatileStatus, @@ -111,6 +118,7 @@ public class BazelWorkspaceStatusModule extends BlazeModule { .setWorkingDir(workspace) .useShell(true) .build(); + this.workspace = workspace; } private String getAdditionalWorkspaceStatus(ActionExecutionContext actionExecutionContext) @@ -314,8 +322,13 @@ public class BazelWorkspaceStatusModule extends BlazeModule { Artifact volatileArtifact = factory.getConstantMetadataArtifact( PathFragment.create("volatile-status.txt"), root, artifactOwner); - return new BazelWorkspaceStatusAction(options, env.getClientEnv(), - env.getDirectories().getWorkspace(), stableArtifact, volatileArtifact, getHostname()); + return new BazelWorkspaceStatusAction( + options, + ImmutableMap.copyOf(env.getClientEnv()), + env.getDirectories().getWorkspace(), + stableArtifact, + volatileArtifact, + getHostname()); } /** diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaBuildInfoFactory.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaBuildInfoFactory.java index d7a3f4b56a..c6aef5db5e 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaBuildInfoFactory.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaBuildInfoFactory.java @@ -19,42 +19,47 @@ import com.google.devtools.build.lib.analysis.BuildInfo; import com.google.devtools.build.lib.rules.java.BuildInfoPropertiesTranslator; import com.google.devtools.build.lib.rules.java.GenericBuildInfoPropertiesTranslator; import com.google.devtools.build.lib.rules.java.JavaBuildInfoFactory; - +import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec; /** * BuildInfoFactory for Java. */ public class BazelJavaBuildInfoFactory extends JavaBuildInfoFactory { - private static final ImmutableMap<String, String> VOLATILE_KEYS = - ImmutableMap.<String, String>builder() - .put("build.time", "%BUILD_TIME%") - .put("build.timestamp.as.int", "%BUILD_TIMESTAMP%") - .put("build.timestamp", "%BUILD_TIMESTAMP%") - .build(); - - private static final ImmutableMap<String, String> NONVOLATILE_KEYS = - ImmutableMap.of("build.label", "%" + BuildInfo.BUILD_EMBED_LABEL + "|%"); - - private static final ImmutableMap<String, String> REDACTED_KEYS = - ImmutableMap.<String, String>builder() - .put("build.time", "Thu Jan 01 00:00:00 1970 (0)") - .put("build.timestamp.as.int", "0") - .put("build.timestamp", "Thu Jan 01 00:00:00 1970 (0)") - .build(); + @AutoCodec @AutoCodec.VisibleForSerialization + static final GenericBuildInfoPropertiesTranslator VOLATILE_KEYS = + new GenericBuildInfoPropertiesTranslator( + ImmutableMap.<String, String>builder() + .put("build.time", "%BUILD_TIME%") + .put("build.timestamp.as.int", "%BUILD_TIMESTAMP%") + .put("build.timestamp", "%BUILD_TIMESTAMP%") + .build()); + + @AutoCodec @AutoCodec.VisibleForSerialization + static final GenericBuildInfoPropertiesTranslator NONVOLATILE_KEYS = + new GenericBuildInfoPropertiesTranslator( + ImmutableMap.of("build.label", "%" + BuildInfo.BUILD_EMBED_LABEL + "|%")); + + @AutoCodec @AutoCodec.VisibleForSerialization + static final GenericBuildInfoPropertiesTranslator REDACTED_KEYS = + new GenericBuildInfoPropertiesTranslator( + ImmutableMap.<String, String>builder() + .put("build.time", "Thu Jan 01 00:00:00 1970 (0)") + .put("build.timestamp.as.int", "0") + .put("build.timestamp", "Thu Jan 01 00:00:00 1970 (0)") + .build()); @Override protected BuildInfoPropertiesTranslator createVolatileTranslator() { - return new GenericBuildInfoPropertiesTranslator(VOLATILE_KEYS); + return VOLATILE_KEYS; } @Override protected BuildInfoPropertiesTranslator createNonVolatileTranslator() { - return new GenericBuildInfoPropertiesTranslator(NONVOLATILE_KEYS); + return NONVOLATILE_KEYS; } @Override protected BuildInfoPropertiesTranslator createRedactedTranslator() { - return new GenericBuildInfoPropertiesTranslator(REDACTED_KEYS); + return REDACTED_KEYS; } - } diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/FdoSupport.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/FdoSupport.java index 439cbd59e4..c5a55f989d 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/FdoSupport.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/FdoSupport.java @@ -135,8 +135,6 @@ import java.util.zip.ZipFile; @Immutable @AutoCodec public class FdoSupport { - public static final ObjectCodec<FdoSupport> CODEC = new FdoSupport_AutoCodec(); - /** * The FDO mode we are operating in. * diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/FdoSupportValue.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/FdoSupportValue.java index 7938c99f62..1422cc5cdb 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/FdoSupportValue.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/FdoSupportValue.java @@ -35,6 +35,7 @@ import java.util.Objects; * <p>The eventual plan is to migrate FDO functionality to the execution phase once directory * artifacts work better, so this may not be worth it. */ +@AutoCodec @Immutable public class FdoSupportValue implements SkyValue { public static final SkyFunctionName SKYFUNCTION = SkyFunctionName.create("FDO_SUPPORT"); diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/WriteBuildInfoPropertiesAction.java b/src/main/java/com/google/devtools/build/lib/rules/java/WriteBuildInfoPropertiesAction.java index 62c4936a94..a346c26205 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/java/WriteBuildInfoPropertiesAction.java +++ b/src/main/java/com/google/devtools/build/lib/rules/java/WriteBuildInfoPropertiesAction.java @@ -26,20 +26,19 @@ import com.google.devtools.build.lib.analysis.BuildInfo; import com.google.devtools.build.lib.analysis.WorkspaceStatusAction; import com.google.devtools.build.lib.analysis.WorkspaceStatusAction.Key; import com.google.devtools.build.lib.analysis.actions.AbstractFileWriteAction; +import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec; import com.google.devtools.build.lib.util.Fingerprint; import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.Writer; -import java.util.Collection; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; import java.util.Properties; -/** - * An action that creates a Java properties file containing the build informations. - */ +/** An action that creates a Java properties file containing the build informations. */ +@AutoCodec public class WriteBuildInfoPropertiesAction extends AbstractFileWriteAction { private static final String GUID = "19e543c2-3ce4-4aef-80f5-4f8abf4b064f"; @@ -123,7 +122,7 @@ public class WriteBuildInfoPropertiesAction extends AbstractFileWriteAction { * @param timestampFormatter formats dates printed in the properties file */ public WriteBuildInfoPropertiesAction( - Collection<Artifact> inputs, + Iterable<Artifact> inputs, Artifact primaryOutput, BuildInfoPropertiesTranslator keyTranslations, boolean includeVolatile, @@ -135,13 +134,13 @@ public class WriteBuildInfoPropertiesAction extends AbstractFileWriteAction { this.includeNonVolatile = includeNonVolatile; this.timestampFormatter = timestampFormatter; - if (!inputs.isEmpty()) { + if (!Iterables.isEmpty(inputs)) { // With non-empty inputs we should not generate both volatile and non-volatile data // in the same properties file. Preconditions.checkState(includeVolatile ^ includeNonVolatile); } Preconditions.checkState( - primaryOutput.isConstantMetadata() == (includeVolatile && !inputs.isEmpty())); + primaryOutput.isConstantMetadata() == (includeVolatile && !Iterables.isEmpty(inputs))); } @Override diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/BuildInfoCollectionValue.java b/src/main/java/com/google/devtools/build/lib/skyframe/BuildInfoCollectionValue.java index 9232f7a5ba..fcaa762be7 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/BuildInfoCollectionValue.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/BuildInfoCollectionValue.java @@ -14,8 +14,11 @@ package com.google.devtools.build.lib.skyframe; import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.Interner; +import com.google.devtools.build.lib.actions.ActionAnalysisMetadata; import com.google.devtools.build.lib.actions.Actions.GeneratingActions; +import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.actions.BasicActionLookupValue; import com.google.devtools.build.lib.analysis.buildinfo.BuildInfoCollection; import com.google.devtools.build.lib.analysis.buildinfo.BuildInfoFactory; @@ -24,12 +27,14 @@ import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.concurrent.BlazeInterners; import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec; import com.google.devtools.build.skyframe.SkyFunctionName; +import java.util.ArrayList; import java.util.Objects; /** * Value that stores {@link BuildInfoCollection}s generated by {@link BuildInfoFactory} instances. * These collections are used during analysis (see {@code CachingAnalysisEnvironment}). */ +@AutoCodec public class BuildInfoCollectionValue extends BasicActionLookupValue { private final BuildInfoCollection collection; @@ -41,6 +46,17 @@ public class BuildInfoCollectionValue extends BasicActionLookupValue { this.collection = collection; } + @AutoCodec.Instantiator + @AutoCodec.VisibleForSerialization + BuildInfoCollectionValue( + ArrayList<ActionAnalysisMetadata> actions, + ImmutableMap<Artifact, Integer> generatingActionIndex, + BuildInfoCollection collection, + boolean removeActionsAfterEvaluation) { + super(actions, generatingActionIndex, removeActionsAfterEvaluation); + this.collection = collection; + } + public BuildInfoCollection getCollection() { return collection; } diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/RegisteredToolchainsValue.java b/src/main/java/com/google/devtools/build/lib/skyframe/RegisteredToolchainsValue.java index 1f6023d5dd..0796a56495 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/RegisteredToolchainsValue.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/RegisteredToolchainsValue.java @@ -28,6 +28,7 @@ import java.util.Objects; /** * A value which represents every toolchain known to Bazel and available for toolchain resolution. */ +@AutoCodec @AutoValue public abstract class RegisteredToolchainsValue implements SkyValue { @@ -77,9 +78,10 @@ public abstract class RegisteredToolchainsValue implements SkyValue { } } + @AutoCodec.Instantiator public static RegisteredToolchainsValue create( - Iterable<DeclaredToolchainInfo> registeredToolchains) { - return new AutoValue_RegisteredToolchainsValue(ImmutableList.copyOf(registeredToolchains)); + ImmutableList<DeclaredToolchainInfo> registeredToolchains) { + return new AutoValue_RegisteredToolchainsValue(registeredToolchains); } public abstract ImmutableList<DeclaredToolchainInfo> registeredToolchains(); diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ToolchainResolutionValue.java b/src/main/java/com/google/devtools/build/lib/skyframe/ToolchainResolutionValue.java index de8d329d79..abaa41f2bf 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/ToolchainResolutionValue.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/ToolchainResolutionValue.java @@ -30,6 +30,7 @@ import java.util.List; * type. Callers will need to consider all toolchain types that are required and merge the results * together appropriately. */ +@AutoCodec @AutoValue public abstract class ToolchainResolutionValue implements SkyValue { @@ -76,6 +77,7 @@ public abstract class ToolchainResolutionValue implements SkyValue { } } + @AutoCodec.Instantiator public static ToolchainResolutionValue create( ImmutableMap<ConfiguredTargetKey, Label> availableToolchainLabels) { return new AutoValue_ToolchainResolutionValue(availableToolchainLabels); diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/WorkspaceStatusValue.java b/src/main/java/com/google/devtools/build/lib/skyframe/WorkspaceStatusValue.java index 0a748f9ea2..20ef47d75b 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/WorkspaceStatusValue.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/WorkspaceStatusValue.java @@ -26,19 +26,20 @@ import com.google.devtools.build.skyframe.SkyKey; */ // TODO(bazel-team): This seems to be superfluous now, but it cannot be removed without making // PrecomputedValue public instead of package-private +@AutoCodec public class WorkspaceStatusValue extends BasicActionLookupValue { private final Artifact stableArtifact; private final Artifact volatileArtifact; // There should only ever be one BuildInfo value in the graph. - public static final BuildInfoKey BUILD_INFO_KEY = BuildInfoKey.INSTANCE; + @AutoCodec public static final BuildInfoKey BUILD_INFO_KEY = new BuildInfoKey(); WorkspaceStatusValue( Artifact stableArtifact, Artifact volatileArtifact, - WorkspaceStatusAction action, - boolean removeActionAfterEvaluation) { - super(action, removeActionAfterEvaluation); + WorkspaceStatusAction workspaceStatusAction, + boolean removeActionsAfterEvaluation) { + super(workspaceStatusAction, removeActionsAfterEvaluation); this.stableArtifact = stableArtifact; this.volatileArtifact = volatileArtifact; } @@ -51,11 +52,13 @@ public class WorkspaceStatusValue extends BasicActionLookupValue { return volatileArtifact; } + @AutoCodec.VisibleForSerialization + WorkspaceStatusAction getWorkspaceStatusAction() { + return (WorkspaceStatusAction) getAction(0); + } + /** {@link SkyKey} for {@link WorkspaceStatusValue}. */ public static class BuildInfoKey extends ActionLookupKey { - @AutoCodec @AutoCodec.VisibleForSerialization - static final BuildInfoKey INSTANCE = new BuildInfoKey(); - private BuildInfoKey() {} @Override |