Skip to content

Commit

Permalink
Update java_toolchain to properly declare config transitions.
Browse files Browse the repository at this point in the history
This is phase 1 of of the switch to toolchain transitions. See bazelbuild#11584 for details.

PiperOrigin-RevId: 316090981
Change-Id: I8e5afacf59389899587e75d8f7d82d5e5f99fd9f
  • Loading branch information
katre committed Sep 14, 2020
1 parent aa42a99 commit eee59fc
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 17 deletions.
2 changes: 2 additions & 0 deletions src/main/java/com/google/devtools/build/lib/rules/java/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,13 @@ java_library(
"//src/main/java/com/google/devtools/build/lib/analysis:config/build_options",
"//src/main/java/com/google/devtools/build/lib/analysis:config/compilation_mode",
"//src/main/java/com/google/devtools/build/lib/analysis:config/core_option_converters",
"//src/main/java/com/google/devtools/build/lib/analysis:config/execution_transition_factory",
"//src/main/java/com/google/devtools/build/lib/analysis:config/fragment",
"//src/main/java/com/google/devtools/build/lib/analysis:config/fragment_options",
"//src/main/java/com/google/devtools/build/lib/analysis:config/fragment_provider",
"//src/main/java/com/google/devtools/build/lib/analysis:config/host_transition",
"//src/main/java/com/google/devtools/build/lib/analysis:config/invalid_configuration_exception",
"//src/main/java/com/google/devtools/build/lib/analysis:config/transitions/no_transition",
"//src/main/java/com/google/devtools/build/lib/analysis:configured_target",
"//src/main/java/com/google/devtools/build/lib/analysis:file_provider",
"//src/main/java/com/google/devtools/build/lib/analysis:package_specification_provider",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
import com.google.devtools.build.lib.analysis.BaseRuleClasses;
import com.google.devtools.build.lib.analysis.RuleDefinition;
import com.google.devtools.build.lib.analysis.RuleDefinitionEnvironment;
import com.google.devtools.build.lib.analysis.config.HostTransition;
import com.google.devtools.build.lib.analysis.config.ExecutionTransitionFactory;
import com.google.devtools.build.lib.analysis.config.transitions.NoTransition;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.packages.RuleClass;
import com.google.devtools.build.lib.util.FileTypeSet;
Expand Down Expand Up @@ -72,12 +73,16 @@ The Java target version (e.g., '6' or '7'). It specifies for which Java runtime
.add(
attr("bootclasspath", LABEL_LIST)
.value(ImmutableList.of())
.allowedFileTypes(FileTypeSet.ANY_FILE))
.allowedFileTypes(FileTypeSet.ANY_FILE)
// This should be in the target configuration.
.cfg(NoTransition.createFactory()))
.add(
attr("extclasspath", LABEL_LIST)
.undocumented("internal")
.value(ImmutableList.of())
.allowedFileTypes(FileTypeSet.ANY_FILE))
.allowedFileTypes(FileTypeSet.ANY_FILE)
// This should be in the target configuration.
.cfg(NoTransition.createFactory()))
/* <!-- #BLAZE_RULE(java_toolchain).ATTRIBUTE(xlint) -->
The list of warning to add or removes from default list. Precedes it with a dash to
removes it. Please see the Javac documentation on the -Xlint options for more information.
Expand Down Expand Up @@ -118,23 +123,26 @@ The Java target version (e.g., '6' or '7'). It specifies for which Java runtime
<!-- #END_BLAZE_RULE.ATTRIBUTE --> */
.add(
attr("javac", LABEL_LIST)
.cfg(HostTransition.createFactory())
// This needs to be in the execution configuration.
.cfg(ExecutionTransitionFactory.create())
.singleArtifact()
.allowedFileTypes(FileTypeSet.ANY_FILE))
/* <!-- #BLAZE_RULE(java_toolchain).ATTRIBUTE(tools) -->
Labels of tools available for label-expansion in jvm_opts.
<!-- #END_BLAZE_RULE.ATTRIBUTE --> */
.add(
attr("tools", LABEL_LIST)
.cfg(HostTransition.createFactory())
// This needs to be in the execution configuration.
.cfg(ExecutionTransitionFactory.create())
.allowedFileTypes(FileTypeSet.ANY_FILE))
/* <!-- #BLAZE_RULE(java_toolchain).ATTRIBUTE(javabuilder) -->
Label of the JavaBuilder deploy jar.
<!-- #END_BLAZE_RULE.ATTRIBUTE --> */
.add(
attr("javabuilder", LABEL_LIST)
.mandatory()
.cfg(HostTransition.createFactory())
// This needs to be in the execution configuration.
.cfg(ExecutionTransitionFactory.create())
.allowedFileTypes(FileTypeSet.ANY_FILE)
.exec())
/* <!-- #BLAZE_RULE(java_toolchain).ATTRIBUTE(singlejar) -->
Expand All @@ -143,8 +151,9 @@ The Java target version (e.g., '6' or '7'). It specifies for which Java runtime
.add(
attr("singlejar", LABEL_LIST)
.mandatory()
.cfg(HostTransition.createFactory())
.singleArtifact()
// This needs to be in the execution configuration.
.cfg(ExecutionTransitionFactory.create())
.allowedFileTypes(FileTypeSet.ANY_FILE)
.exec())
/* <!-- #BLAZE_RULE(java_toolchain).ATTRIBUTE(genclass) -->
Expand All @@ -154,16 +163,18 @@ The Java target version (e.g., '6' or '7'). It specifies for which Java runtime
attr("genclass", LABEL_LIST)
.mandatory()
.singleArtifact()
.cfg(HostTransition.createFactory())
// This needs to be in the execution configuration.
.cfg(ExecutionTransitionFactory.create())
.allowedFileTypes(FileTypeSet.ANY_FILE)
.exec())
/* <!-- #BLAZE_RULE(java_toolchain).ATTRIBUTE(resourcejar) -->
Label of the resource jar builder executable.
<!-- #END_BLAZE_RULE.ATTRIBUTE --> */
.add(
attr("resourcejar", LABEL_LIST)
.cfg(HostTransition.createFactory())
.singleArtifact()
// This needs to be in the execution configuration.
.cfg(ExecutionTransitionFactory.create())
.allowedFileTypes(FileTypeSet.ANY_FILE)
.exec())
/* <!-- #BLAZE_RULE(java_toolchain).ATTRIBUTE(timezone_data) -->
Expand All @@ -172,8 +183,9 @@ The Java target version (e.g., '6' or '7'). It specifies for which Java runtime
<!-- #END_BLAZE_RULE.ATTRIBUTE --> */
.add(
attr("timezone_data", LABEL)
.cfg(HostTransition.createFactory())
.singleArtifact()
// This needs to be in the execution configuration.
.cfg(ExecutionTransitionFactory.create())
.allowedFileTypes(FileTypeSet.ANY_FILE)
.exec())
/* <!-- #BLAZE_RULE(java_toolchain).ATTRIBUTE(ijar) -->
Expand All @@ -182,16 +194,18 @@ The Java target version (e.g., '6' or '7'). It specifies for which Java runtime
.add(
attr("ijar", LABEL_LIST)
.mandatory()
.cfg(HostTransition.createFactory())
// This needs to be in the execution configuration.
.cfg(ExecutionTransitionFactory.create())
.allowedFileTypes(FileTypeSet.ANY_FILE)
.exec())
/* <!-- #BLAZE_RULE(java_toolchain).ATTRIBUTE(header_compiler) -->
Label of the header compiler. Required if --java_header_compilation is enabled.
<!-- #END_BLAZE_RULE.ATTRIBUTE --> */
.add(
attr("header_compiler", LABEL_LIST)
.cfg(HostTransition.createFactory())
.singleArtifact()
// This needs to be in the execution configuration.
.cfg(ExecutionTransitionFactory.create())
.allowedFileTypes(FileTypeSet.ANY_FILE)
.exec())
/* <!-- #BLAZE_RULE(java_toolchain).ATTRIBUTE(header_compiler_direct) -->
Expand All @@ -202,7 +216,8 @@ The Java target version (e.g., '6' or '7'). It specifies for which Java runtime
<!-- #END_BLAZE_RULE.ATTRIBUTE --> */
.add(
attr("header_compiler_direct", LABEL_LIST)
.cfg(HostTransition.createFactory())
// This needs to be in the execution configuration.
.cfg(ExecutionTransitionFactory.create())
.allowedFileTypes(FileTypeSet.ANY_FILE)
.exec())
.add(
Expand All @@ -226,17 +241,19 @@ The Java target version (e.g., '6' or '7'). It specifies for which Java runtime
<!-- #END_BLAZE_RULE.ATTRIBUTE --> */
.add(
attr("oneversion", LABEL)
.cfg(HostTransition.createFactory())
.singleArtifact()
// This needs to be in the execution configuration.
.cfg(ExecutionTransitionFactory.create())
.allowedFileTypes(FileTypeSet.ANY_FILE)
.exec())
/* <!-- #BLAZE_RULE(java_toolchain).ATTRIBUTE(oneversion_whitelist) -->
Label of the one-version whitelist.
<!-- #END_BLAZE_RULE.ATTRIBUTE --> */
.add(
attr("oneversion_whitelist", LABEL)
.cfg(HostTransition.createFactory())
.singleArtifact()
// This needs to be in the execution configuration.
.cfg(ExecutionTransitionFactory.create())
.allowedFileTypes(FileTypeSet.ANY_FILE)
.exec())
/* <!-- #BLAZE_RULE(java_toolchain).ATTRIBUTE(forcibly_disable_header_compilation) -->
Expand All @@ -253,15 +270,17 @@ The Java target version (e.g., '6' or '7'). It specifies for which Java runtime
<!-- #END_BLAZE_RULE.ATTRIBUTE --> */
.add(
attr("package_configuration", LABEL_LIST)
.cfg(HostTransition.createFactory())
.allowedFileTypes()
// This needs to be in the execution configuration.
.cfg(ExecutionTransitionFactory.create())
.mandatoryNativeProviders(ImmutableList.of(JavaPackageConfigurationProvider.class)))
/* <!-- #BLAZE_RULE(java_toolchain).ATTRIBUTE(jacocorunner) -->
Label of the JacocoCoverageRunner deploy jar.
<!-- #END_BLAZE_RULE.ATTRIBUTE --> */
.add(
attr("jacocorunner", LABEL)
.cfg(HostTransition.createFactory())
// This needs to be in the execution configuration.
.cfg(ExecutionTransitionFactory.create())
.allowedFileTypes(FileTypeSet.ANY_FILE)
.exec())
.build();
Expand Down

0 comments on commit eee59fc

Please sign in to comment.