aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build
diff options
context:
space:
mode:
authorGravatar tomlu <tomlu@google.com>2017-08-23 18:28:50 +0200
committerGravatar Damien Martin-Guillerez <dmarting@google.com>2017-08-24 13:58:44 +0200
commited52a4d11f08c2ce39cb9763e7ec3711a7359937 (patch)
treec9bf320bdaf63dd4b29e7d63afc6262811066c58 /src/main/java/com/google/devtools/build
parent2cd8ded32a57a0fcfdf3f9972ea722a9a9a44616 (diff)
Use CustomCommandLine directly instead of via SpawnAction.Builder.
This change forces use of CustomCommandLine.Builder, which has a richer interface for constructing memory-efficient command lines. It will also permit surveying the code base for inefficient patterns using an IDE. This change was done by hand and split using Rosie to assist with rollbacks in case of bugs. Reviewers, please pay particular attention to: * Each all to addInputArgument/addOutputArgument should come with a corresponding matching pair to SpawnAction.Builder#addInput and CustomCommandLine.Builder#addExecPath (eg.). * The commandLine must be set on the SpawnAction using SpawnAction.Builder#setCommandLine. Note that most calls to addPrefixed("arg=", val) should be more idiomatically expressed as add("arg", val), but this involves changing tests and making sure that the command line tools can accept the format. PiperOrigin-RevId: 166210952
Diffstat (limited to 'src/main/java/com/google/devtools/build')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchain.java20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchain.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchain.java
index 0a1f13f8b8..5d77cebdd4 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchain.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchain.java
@@ -35,6 +35,7 @@ import com.google.devtools.build.lib.analysis.RuleContext;
import com.google.devtools.build.lib.analysis.Runfiles;
import com.google.devtools.build.lib.analysis.RunfilesProvider;
import com.google.devtools.build.lib.analysis.TransitiveInfoCollection;
+import com.google.devtools.build.lib.analysis.actions.CustomCommandLine;
import com.google.devtools.build.lib.analysis.actions.SpawnAction;
import com.google.devtools.build.lib.analysis.actions.SymlinkAction;
import com.google.devtools.build.lib.analysis.config.CompilationMode;
@@ -145,12 +146,16 @@ public class CcToolchain implements RuleConfiguredTargetFactory {
.addOutput(rawProfileArtifact)
.useDefaultShellEnvironment()
.setExecutable(zipperBinaryArtifact)
- .addArguments("xf", zipProfileArtifact.getExecPathString())
- .addArguments(
- "-d", rawProfileArtifact.getExecPath().getParentDirectory().getSafePathString())
.setProgressMessage(
"LLVMUnzipProfileAction: Generating %s", rawProfileArtifact.prettyPrint())
.setMnemonic("LLVMUnzipProfileAction")
+ .setCommandLine(
+ CustomCommandLine.builder()
+ .addExecPath("xf", zipProfileArtifact)
+ .add(
+ "-d",
+ rawProfileArtifact.getExecPath().getParentDirectory().getSafePathString())
+ .build())
.build(ruleContext));
} else {
rawProfileArtifact =
@@ -180,10 +185,15 @@ public class CcToolchain implements RuleConfiguredTargetFactory {
.addOutput(profileArtifact)
.useDefaultShellEnvironment()
.setExecutable(cppConfiguration.getLLVMProfDataExecutable())
- .addArguments("merge", "-o", profileArtifact.getExecPathString())
- .addArgument(rawProfileArtifact.getExecPathString())
.setProgressMessage("LLVMProfDataAction: Generating %s", profileArtifact.prettyPrint())
.setMnemonic("LLVMProfDataAction")
+ .setCommandLine(
+ CustomCommandLine.builder()
+ .add("merge")
+ .add("-o")
+ .addExecPath(profileArtifact)
+ .addExecPath(rawProfileArtifact)
+ .build())
.build(ruleContext));
return profileArtifact;