Make genrules not understand $(JAVA) and $(JAVABASE) if --experimental_enable_jvm_configuration_make_variables is not in effect.
RELNOTES: None.
@@ -371,7 +371,11 @@ public abstract class GenRuleBase implements RuleConfiguredTargetFactory {
return valueFromToolchains;
}
- if (JDK_MAKE_VARIABLE.matcher("$(" + variableName + ")").find()) {
+ // We use the presence of the Java Make variable in the current configuration as a proxy for
+ // whether Java Make variables are enabled. This lets us avoid declaring a dependency on the
+ // Jvm fragment (genrules should not depend on Java so they shouldn't do that).
+ if (JDK_MAKE_VARIABLE.matcher("$(" + variableName + ")").find()
+ && ruleContext.getConfiguration().getMakeEnvironment().containsKey(variableName)) {
List<String> attributes = new ArrayList<>();
attributes.addAll(ConfigurationMakeVariableContext.DEFAULT_MAKE_VARIABLE_ATTRIBUTES);
attributes.add(":host_jdk");
