diff options
author | tomlu <tomlu@google.com> | 2017-08-15 23:21:25 +0200 |
---|---|---|
committer | Irina Iancu <elenairina@google.com> | 2017-08-16 11:06:03 +0200 |
commit | 59f1d889f71d6d203ca061787d4ea16465df1916 (patch) | |
tree | d0e52ac5be0fe8eed9c0e6886127919e156a2c85 /src/main/java/com/google/devtools/build/lib/rules/proto/ProtoCompileActionBuilder.java | |
parent | ff746b4aaa5bb7109ff543a72c165fa6e785916f (diff) |
Add more type safety to CustomCommandLine.
Allowing add(Object) is too loose and can easily lead to programmer mistakes.
Because of type erasure, we can't use the same overload name for (eg.) add(NestedSet<String>) and add(NestedSet<Artifact>). The API is overhauled to use the same terms everywhere, eg. "add", "addPaths", "addExecPaths". This is similar to how it used to be a few CLs ago.
The API is overhauled to make sure it's consistent for all types. While tedious, the facade methods immediately dispatch to internal helpers, so implementation wise it's not too heavy.
While large, this CL is almost entirely an automated refactor.
PiperOrigin-RevId: 165358287
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.java | 12 |
1 files changed, 6 insertions, 6 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 f7e934a1dd..86415309d5 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 @@ -298,7 +298,7 @@ public class ProtoCompileActionBuilder { // and thus we have to deal with "$xx_plugin" and "xx_plugin". result.addFormatted( "--plugin=protoc-gen-%s=%s", langPrefix, langPluginTarget.getExecutable().getExecPath()); - result.add(new LazyLangPluginFlag(langPrefix, langPluginParameter1)); + result.addLazyString(new LazyLangPluginFlag(langPrefix, langPluginParameter1)); } result.add(ruleContext.getFragment(ProtoConfiguration.class).protocOpts()); @@ -306,7 +306,7 @@ public class ProtoCompileActionBuilder { boolean areDepsStrict = areDepsStrict(ruleContext); // Add include maps - result.add( + result.addCustomMultiArgv( new ProtoCommandLineArgv( areDepsStrict ? supportData.getProtosInDirectDeps() : null, supportData.getTransitiveImports())); @@ -318,7 +318,7 @@ public class ProtoCompileActionBuilder { } for (Artifact src : supportData.getDirectProtoSources()) { - result.add(src.getRootRelativePath()); + result.addPath(src.getRootRelativePath()); } if (!hasServices) { @@ -570,7 +570,7 @@ public class ProtoCompileActionBuilder { ProtoLangToolchainProvider toolchain = invocation.toolchain; - cmdLine.add( + cmdLine.addLazyString( new LazyCommandLineExpansion( toolchain.commandLine(), ImmutableMap.of( @@ -589,14 +589,14 @@ public class ProtoCompileActionBuilder { cmdLine.add(protocOpts); // Add include maps - cmdLine.add(new ProtoCommandLineArgv(protosInDirectDeps, transitiveSources)); + cmdLine.addCustomMultiArgv(new ProtoCommandLineArgv(protosInDirectDeps, transitiveSources)); if (protosInDirectDeps != null) { cmdLine.addFormatted(STRICT_DEPS_FLAG_TEMPLATE, ruleLabel); } for (Artifact src : protosToCompile) { - cmdLine.add(src.getExecPath()); + cmdLine.addPath(src.getExecPath()); } if (!allowServices) { |