Skip to content

Commit 882d668

Browse files
cushoncopybara-github
authored andcommitted
In JavaHeaderCompileAction, pass -Aexperimental_turbine_hjar to all header compilation actions
This is currently being used by Dagger to optimize generated code for header compilation, this change is being done in preparation for similar optimizations in other annotation processors. PiperOrigin-RevId: 837823870 Change-Id: I4572af044da9e5eef1351c062bb8bd4aabdd78f9
1 parent 1f49ff5 commit 882d668

File tree

2 files changed

+7
-28
lines changed

2 files changed

+7
-28
lines changed

src/main/java/com/google/devtools/build/lib/rules/java/JavaCompilationHelper.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -446,13 +446,6 @@ public void createHeaderCompilationAction(
446446
builder.setHeaderCompilationOutputJar(headerCompilationOutputJar);
447447
builder.setOutputDepsProto(headerDeps);
448448
builder.setPlugins(plugins);
449-
if (plugins
450-
.processorClasses()
451-
.toList()
452-
.contains("dagger.internal.codegen.ComponentProcessor")) {
453-
// See b/31371210 and b/142059842.
454-
builder.addTurbineHjarJavacOpt();
455-
}
456449
builder.enableDirectClasspath(enableDirectClasspath);
457450
builder.build(javaToolchain);
458451
}

src/main/java/com/google/devtools/build/lib/rules/java/JavaHeaderCompileAction.java

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,6 @@ public static final class Builder {
199199
private NestedSet<Artifact> compileTimeDependencyArtifacts =
200200
NestedSetBuilder.emptySet(Order.STABLE_ORDER);
201201
private ImmutableList<String> javacOpts = ImmutableList.of();
202-
private boolean addTurbineHjarJavacOpt = false;
203202
private JavaPluginData plugins = JavaPluginData.empty();
204203

205204
private ImmutableList<Artifact> additionalInputs = ImmutableList.of();
@@ -272,16 +271,6 @@ public Builder setJavacOpts(ImmutableList<String> javacOpts) {
272271
return this;
273272
}
274273

275-
/**
276-
* Adds {@code -Aexperimental_turbine_hjar} to Java compiler flags without creating an entirely
277-
* new list.
278-
*/
279-
@CanIgnoreReturnValue
280-
public Builder addTurbineHjarJavacOpt() {
281-
this.addTurbineHjarJavacOpt = true;
282-
return this;
283-
}
284-
285274
/** Sets the output jar. */
286275
@CanIgnoreReturnValue
287276
public Builder setOutputJar(Artifact outputJar) {
@@ -505,17 +494,14 @@ public void build(JavaToolchainProvider javaToolchain)
505494
.addExecPaths("--source_jars", sourceJars)
506495
.add("--injecting_rule_kind", injectingRuleKind);
507496

508-
if (!javacOpts.isEmpty() || addTurbineHjarJavacOpt) {
509-
commandLine.add("--javacopts");
510-
if (!javacOpts.isEmpty()) {
511-
commandLine.addObject(javacOpts);
512-
}
513-
if (addTurbineHjarJavacOpt) {
514-
commandLine.add("-Aexperimental_turbine_hjar");
515-
}
516-
// terminate --javacopts with `--` to support javac flags that start with `--`
517-
commandLine.add("--");
497+
commandLine.add("--javacopts");
498+
if (!javacOpts.isEmpty()) {
499+
commandLine.addObject(javacOpts);
518500
}
501+
// See b/31371210, b/142059842, and b/464431616.
502+
commandLine.add("-Aexperimental_turbine_hjar");
503+
// terminate --javacopts with `--` to support javac flags that start with `--`
504+
commandLine.add("--");
519505

520506
if (targetLabel != null) {
521507
commandLine.add("--target_label");

0 commit comments

Comments
 (0)