diff options
author | 2017-07-14 17:06:05 +0200 | |
---|---|---|
committer | 2017-07-17 10:10:39 +0200 | |
commit | a76c94be7c56b93fc5a2f9ececfba7ac1f61f69c (patch) | |
tree | 09c1ab12473aa8ac6b453b24db098e8b347fe7a9 /src/main/java/com/google/devtools/build/lib/rules/objc/J2ObjcAspect.java | |
parent | 681b8174d5ae989cf9489716e4c15a54c2d36bc4 (diff) |
CustomCommandLine.Builder: clean up its interface
In this commit:
- remove unused methods and classes
- turn CustomCommandLine.ArgvFragment into an
interface
- remove the
CustomCommandLine.TreeFileArtifactArgvFragment
abstract class; it only had one remaining
subclass
- add @Nullable annotations where nulls are fine
- add Precondition checks for non-nullable args
- simplify the interface by removing add* methods
that can be composed of other add* methods; this
makes it easier to see what the callers do with
the Builder
- remove add* methods that add a single argument
followed by a list of other elements (or a
joined string of them); these had a bug in that
they didn't check if the collection was empty
(only that it was not null), and if it was empty
then the single argument was still added though
it was not followed by any value
- fix call sites of add* methods where we
previously could have added a flag with an empty
collection
- audit every affected call site
RELNOTES: none
PiperOrigin-RevId: 161957521
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/objc/J2ObjcAspect.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/objc/J2ObjcAspect.java | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/J2ObjcAspect.java b/src/main/java/com/google/devtools/build/lib/rules/objc/J2ObjcAspect.java index 60a24514e0..f2cf27fe0b 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/J2ObjcAspect.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/J2ObjcAspect.java @@ -492,8 +492,10 @@ public class J2ObjcAspect extends NativeAspectClass implements ConfiguredAspectF ImmutableList.Builder<Artifact> sourceJarOutputFiles = ImmutableList.builder(); if (!Iterables.isEmpty(sourceJars)) { sourceJarOutputFiles.addAll(sourceJarOutputs(ruleContext)); - argBuilder.addJoinExecPaths("--src_jars", ",", sourceJars); - argBuilder.add(sourceJarFlags(ruleContext)); + argBuilder + .add("--src_jars") + .addJoinExecPaths(",", sourceJars) + .add(sourceJarFlags(ruleContext)); } Iterable<String> translationFlags = ruleContext @@ -504,7 +506,7 @@ public class J2ObjcAspect extends NativeAspectClass implements ConfiguredAspectF NestedSet<Artifact> depsHeaderMappingFiles = depJ2ObjcMappingFileProvider.getHeaderMappingFiles(); if (!depsHeaderMappingFiles.isEmpty()) { - argBuilder.addJoinExecPaths("--header-mapping", ",", depsHeaderMappingFiles); + argBuilder.add("--header-mapping").addJoinExecPaths(",", depsHeaderMappingFiles); } boolean experimentalJ2ObjcHeaderMap = @@ -516,7 +518,7 @@ public class J2ObjcAspect extends NativeAspectClass implements ConfiguredAspectF NestedSet<Artifact> depsClassMappingFiles = depJ2ObjcMappingFileProvider.getClassMappingFiles(); if (!depsClassMappingFiles.isEmpty()) { - argBuilder.addJoinExecPaths("--mapping", ",", depsClassMappingFiles); + argBuilder.add("--mapping").addJoinExecPaths(",", depsClassMappingFiles); } Artifact archiveSourceMappingFile = j2ObjcOutputArchiveSourceMappingFile(ruleContext); @@ -538,7 +540,7 @@ public class J2ObjcAspect extends NativeAspectClass implements ConfiguredAspectF NestedSet<Artifact> compileTimeJars = compArgsProvider.getRecursiveJavaCompilationArgs().getCompileTimeJars(); if (!compileTimeJars.isEmpty()) { - argBuilder.addJoinExecPaths("-classpath", ":", compileTimeJars); + argBuilder.add("-classpath").addJoinExecPaths(":", compileTimeJars); } argBuilder.addExecPaths(sources); @@ -584,10 +586,10 @@ public class J2ObjcAspect extends NativeAspectClass implements ConfiguredAspectF if (experimentalJ2ObjcHeaderMap) { CustomCommandLine.Builder headerMapCommandLine = CustomCommandLine.builder(); if (!Iterables.isEmpty(sources)) { - headerMapCommandLine.addJoinExecPaths("--source_files", ",", sources); + headerMapCommandLine.add("--source_files").addJoinExecPaths(",", sources); } if (!Iterables.isEmpty(sourceJars)) { - headerMapCommandLine.addJoinExecPaths("--source_jars", ",", sourceJars); + headerMapCommandLine.add("--source_jars").addJoinExecPaths(",", sourceJars); } headerMapCommandLine.addExecPath("--output_mapping_file", outputHeaderMappingFile); ruleContext.registerAction(new SpawnAction.Builder() |