aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main
diff options
context:
space:
mode:
authorGravatar janakr <janakr@google.com>2018-02-27 12:55:05 -0800
committerGravatar Copybara-Service <copybara-piper@google.com>2018-02-27 12:57:50 -0800
commit678f5a0299d2ea5cdd25740f58571bd43f27e1e2 (patch)
tree70bfc468b564ba03b99274d6652ec2b365fb241f /src/main
parent1cfaaff54eaa2e506a1f7f7032db1af70c4e6b35 (diff)
@AutoCodec WriteBuildInfoHeaderAction.
PiperOrigin-RevId: 187218309
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/WriteBuildInfoHeaderAction.java44
1 files changed, 23 insertions, 21 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/WriteBuildInfoHeaderAction.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/WriteBuildInfoHeaderAction.java
index 03a3594086..e75153a1b5 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/WriteBuildInfoHeaderAction.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/WriteBuildInfoHeaderAction.java
@@ -17,7 +17,6 @@ package com.google.devtools.build.lib.rules.cpp;
import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.common.base.Preconditions;
-import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
import com.google.devtools.build.lib.actions.ActionExecutionContext;
import com.google.devtools.build.lib.actions.ActionKeyContext;
@@ -26,6 +25,7 @@ import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.analysis.WorkspaceStatusAction;
import com.google.devtools.build.lib.analysis.actions.AbstractFileWriteAction;
import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable;
+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;
@@ -36,45 +36,47 @@ import java.util.LinkedHashMap;
import java.util.Map;
/**
- * An action that creates a C++ header containing the build information in the
- * form of #define directives.
+ * An action that creates a C++ header containing the build information in the form of #define
+ * directives.
*/
@Immutable
+@AutoCodec
public final class WriteBuildInfoHeaderAction extends AbstractFileWriteAction {
private static final String GUID = "62be38ad-1243-46b9-9948-9bdfa81f8918";
- private final ImmutableList<Artifact> valueArtifacts;
-
private final boolean writeVolatileInfo;
private final boolean writeStableInfo;
/**
* Creates an action that writes a C++ header with the build information.
*
- * <p>It reads the set of build info keys from an action context that is usually contributed
- * to Bazel by the workspace status module, and the value associated with said keys from the
+ * <p>It reads the set of build info keys from an action context that is usually contributed to
+ * Bazel by the workspace status module, and the value associated with said keys from the
* workspace status files (stable and volatile) written by the workspace status action.
*
* <p>Without input artifacts this action uses redacted build information.
- * @param inputs Artifacts that contain build information, or an empty
- * collection to use redacted build information
- * @param output the C++ header Artifact created by this action
- * @param writeVolatileInfo whether to write the volatile part of the build
- * information to the generated header
- * @param writeStableInfo whether to write the non-volatile part of the
- * build information to the generated header
+ *
+ * @param inputs Artifacts that contain build information, or an empty collection to use redacted
+ * build information
+ * @param primaryOutput the C++ header Artifact created by this action
+ * @param writeVolatileInfo whether to write the volatile part of the build information to the
+ * generated header
+ * @param writeStableInfo whether to write the non-volatile part of the build information to the
+ * generated header
*/
- public WriteBuildInfoHeaderAction(Collection<Artifact> inputs,
- Artifact output, boolean writeVolatileInfo, boolean writeStableInfo) {
- super(ActionOwner.SYSTEM_ACTION_OWNER, inputs, output, /*makeExecutable=*/ false);
- valueArtifacts = ImmutableList.copyOf(inputs);
+ public WriteBuildInfoHeaderAction(
+ Collection<Artifact> inputs,
+ Artifact primaryOutput,
+ boolean writeVolatileInfo,
+ boolean writeStableInfo) {
+ super(ActionOwner.SYSTEM_ACTION_OWNER, inputs, primaryOutput, /*makeExecutable=*/ false);
if (!inputs.isEmpty()) {
// With non-empty inputs we should not generate both volatile and non-volatile data
// in the same header file.
Preconditions.checkState(writeVolatileInfo ^ writeStableInfo);
}
Preconditions.checkState(
- output.isConstantMetadata() == (writeVolatileInfo && !inputs.isEmpty()));
+ primaryOutput.isConstantMetadata() == (writeVolatileInfo && !inputs.isEmpty()));
this.writeVolatileInfo = writeVolatileInfo;
this.writeStableInfo = writeStableInfo;
@@ -95,11 +97,11 @@ public final class WriteBuildInfoHeaderAction extends AbstractFileWriteAction {
}
final Map<String, String> values = new LinkedHashMap<>();
- for (Artifact valueFile : valueArtifacts) {
+ for (Artifact valueFile : getInputs()) {
values.putAll(WorkspaceStatusAction.parseValues(valueFile.getPath()));
}
- final boolean redacted = valueArtifacts.isEmpty();
+ final boolean redacted = Iterables.isEmpty(getInputs());
return new DeterministicWriter() {
@Override