Skip to content

Commit

Permalink
Allow turbine to parse JavaBuilder command lines
Browse files Browse the repository at this point in the history
Add a couple of aliases, and skip some flags that only apply to JavaBuilder.

PiperOrigin-RevId: 359809639
  • Loading branch information
cushon authored and Javac Team committed Feb 27, 2021
1 parent 27418aa commit 87cba24
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
10 changes: 10 additions & 0 deletions java/com/google/turbine/options/TurbineOptionsParser.java
Expand Up @@ -100,6 +100,7 @@ private static void parse(TurbineOptions.Builder builder, Deque<String> argument
case "--sources":
builder.setSources(readList(argumentDeque));
break;
case "--output_deps_proto":
case "--output_deps":
builder.setOutputDeps(readOne(argumentDeque));
break;
Expand Down Expand Up @@ -140,6 +141,7 @@ private static void parse(TurbineOptions.Builder builder, Deque<String> argument
case "--profile":
builder.setProfile(readOne(argumentDeque));
break;
case "--generated_sources_output":
case "--gensrc_output":
builder.setGensrcOutput(readOne(argumentDeque));
break;
Expand All @@ -149,6 +151,14 @@ private static void parse(TurbineOptions.Builder builder, Deque<String> argument
case "--help":
builder.setHelp(true);
break;
case "--experimental_fix_deps_tool":
case "--strict_java_deps":
case "--native_header_output":
case "--compress_jar":
// these flags don't apply to turbine, but are accepted (and ignored) for compatibility
// with JavaBuilder command lines
readOne(argumentDeque);
break;
default:
throw new IllegalArgumentException("unknown option: " + next);
}
Expand Down
23 changes: 23 additions & 0 deletions javatests/com/google/turbine/options/TurbineOptionsTest.java
Expand Up @@ -373,4 +373,27 @@ public void reducedClasspathMode() throws Exception {
assertThat(options.reducedClasspathMode()).isEqualTo(mode);
}
}

@Test
public void javaBuilderCompatibility() throws Exception {
TurbineOptions options =
TurbineOptionsParser.parse(
Iterables.concat(
BASE_ARGS,
ImmutableList.of(
"--output_deps_proto",
"output_deps.proto",
"--generated_sources_output",
"generated_sources.jar",
"--experimental_fix_deps_tool",
"ignored",
"--strict_java_deps",
"ignored",
"--native_header_output",
"ignored",
"--compress_jar",
"ignored")));
assertThat(options.outputDeps()).hasValue("output_deps.proto");
assertThat(options.gensrcOutput()).hasValue("generated_sources.jar");
}
}

0 comments on commit 87cba24

Please sign in to comment.