aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules/proto/ProtoCompileActionBuilder.java
diff options
context:
space:
mode:
authorGravatar Carmi Grushko <carmi@google.com>2016-11-22 20:26:32 +0000
committerGravatar Dmitry Lomov <dslomov@google.com>2016-11-23 08:50:59 +0000
commitc944c4d9fc5cbad830b69383a76ffff463088c7e (patch)
treef82e66e9b269272e53bd8ade0f75f3f19ec7db16 /src/main/java/com/google/devtools/build/lib/rules/proto/ProtoCompileActionBuilder.java
parent0aac8f7d4f2cea1834df4aaf4cad35d3425d874b (diff)
Alias proto_library's produce a descriptor set that contains all srcs of its dependencies.
(alias proto_library's are those with a deps attribute but no srcs attribute) RELNOTES: Alias proto_library's produce a descriptor set that contains all srcs of its dependencies. -- MOS_MIGRATED_REVID=139940475
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/proto/ProtoCompileActionBuilder.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/proto/ProtoCompileActionBuilder.java35
1 files changed, 21 insertions, 14 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/proto/ProtoCompileActionBuilder.java b/src/main/java/com/google/devtools/build/lib/rules/proto/ProtoCompileActionBuilder.java
index 51d86fe7d9..233a28d1b4 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/proto/ProtoCompileActionBuilder.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/proto/ProtoCompileActionBuilder.java
@@ -35,6 +35,7 @@ import com.google.devtools.build.lib.analysis.RuleConfiguredTarget;
import com.google.devtools.build.lib.analysis.RuleContext;
import com.google.devtools.build.lib.analysis.actions.CustomCommandLine;
import com.google.devtools.build.lib.analysis.actions.SpawnAction;
+import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
import com.google.devtools.build.lib.util.LazyString;
import java.util.ArrayList;
@@ -345,13 +346,17 @@ public class ProtoCompileActionBuilder {
public static void writeDescriptorSet(
RuleContext ruleContext,
final CharSequence outReplacement,
- SupportData supportData,
+ Iterable<Artifact> protosToCompile,
+ NestedSet<Artifact> transitiveSources,
+ NestedSet<Artifact> protosInDirectDeps,
Iterable<Artifact> outputs,
boolean allowServices) {
registerActions(
ruleContext,
ImmutableList.of(createDescriptorSetToolchain(outReplacement)),
- supportData,
+ protosToCompile,
+ transitiveSources,
+ protosInDirectDeps,
outputs,
"Descriptor Set",
allowServices);
@@ -378,12 +383,13 @@ public class ProtoCompileActionBuilder {
* @param outputs The artifacts that the resulting action must create.
* @param flavorName e.g., "Java (Immutable)"
* @param allowServices If false, the compilation will break if any .proto file has service
- * definitions.
*/
public static void registerActions(
RuleContext ruleContext,
List<ToolchainInvocation> toolchainInvocations,
- SupportData supportData,
+ Iterable<Artifact> protosToCompile,
+ NestedSet<Artifact> transitiveSources,
+ NestedSet<Artifact> protosInDirectDeps,
Iterable<Artifact> outputs,
String flavorName,
boolean allowServices) {
@@ -391,8 +397,7 @@ public class ProtoCompileActionBuilder {
return;
}
- SpawnAction.Builder result =
- new SpawnAction.Builder().addTransitiveInputs(supportData.getTransitiveImports());
+ SpawnAction.Builder result = new SpawnAction.Builder().addTransitiveInputs(transitiveSources);
for (ToolchainInvocation invocation : toolchainInvocations) {
ProtoLangToolchainProvider toolchain = invocation.toolchain;
@@ -416,7 +421,9 @@ public class ProtoCompileActionBuilder {
.setCommandLine(
createCommandLineFromToolchains(
toolchainInvocations,
- supportData,
+ protosToCompile,
+ transitiveSources,
+ protosInDirectDeps,
allowServices,
ruleContext.getFragment(ProtoConfiguration.class).protocOpts()))
.setProgressMessage("Generating " + flavorName + " proto_library " + ruleContext.getLabel())
@@ -441,13 +448,15 @@ public class ProtoCompileActionBuilder {
* called. As some plugins rely on output from other plugins, their order matters.
*
* @param toolchainInvocations See {@link #createCommandLineFromToolchains}.
- * @param allowServices If false, the compilation will break if any .proto file has service
- * @return a command-line to pass to proto-compiler.
+ * @param allowServices If false, the compilation will break if any .proto file has
+ * service @return a command-line to pass to proto-compiler.
*/
@VisibleForTesting
static CustomCommandLine createCommandLineFromToolchains(
List<ToolchainInvocation> toolchainInvocations,
- SupportData supportData,
+ Iterable<Artifact> protosToCompile,
+ NestedSet<Artifact> transitiveSources,
+ NestedSet<Artifact> protosInDirectDeps,
boolean allowServices,
ImmutableList<String> protocOpts) {
CustomCommandLine.Builder cmdLine = CustomCommandLine.builder();
@@ -487,11 +496,9 @@ public class ProtoCompileActionBuilder {
cmdLine.add(protocOpts);
// Add include maps
- cmdLine.add(
- new ProtoCommandLineArgv(
- supportData.getProtosInDirectDeps(), supportData.getTransitiveImports()));
+ cmdLine.add(new ProtoCommandLineArgv(protosInDirectDeps, transitiveSources));
- for (Artifact src : supportData.getDirectProtoSources()) {
+ for (Artifact src : protosToCompile) {
cmdLine.addPath(src.getRootRelativePath());
}