Add $java_toolchain attribute to J2ObjcAspect.
This prevents errors when the aspect is over rules that don't have the attribute.
@@ -17,6 +17,7 @@ package com.google.devtools.build.lib.rules.objc;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.devtools.build.lib.packages.Attribute.attr;
import static com.google.devtools.build.lib.packages.BuildType.LABEL;
+import static com.google.devtools.build.lib.rules.java.JavaRuleClasses.JAVA_TOOLCHAIN_ATTRIBUTE_NAME;
import static java.nio.charset.StandardCharsets.ISO_8859_1;
import static java.util.stream.Collectors.toList;
@@ -39,6 +40,7 @@ import com.google.devtools.build.lib.analysis.actions.CustomCommandLine.VectorAr
import com.google.devtools.build.lib.analysis.actions.SpawnAction;
import com.google.devtools.build.lib.analysis.config.ConfigAwareAspectBuilder;
import com.google.devtools.build.lib.analysis.config.HostTransition;
+import com.google.devtools.build.lib.analysis.platform.ToolchainInfo;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
@@ -117,12 +119,14 @@ public class J2ObjcAspect extends NativeAspectClass implements ConfiguredAspectF
private final Label ccToolchainType;
private final LabelLateBoundDefault<CppConfiguration> ccToolchain;
private final CppSemantics cppSemantics;
+ private final Label javaToolchain;
public J2ObjcAspect(RuleDefinitionEnvironment env, CppSemantics cppSemantics) {
this.toolsRepository = checkNotNull(env.getToolsRepository());
this.ccToolchainType = CppRuleClasses.ccToolchainTypeAttribute(env);
this.ccToolchain = CppRuleClasses.ccToolchainAttribute(env);
this.cppSemantics = cppSemantics;
+ this.javaToolchain = JavaSemantics.javaToolchainAttribute(env);
}
/** Returns whether this aspect allows proto services to be generated from this proto rule */
@@ -222,6 +226,11 @@ public class J2ObjcAspect extends NativeAspectClass implements ConfiguredAspectF
getProtoToolchainLabel(
toolsRepository + "//tools/j2objc:j2objc_proto_toolchain")))
.add(attr(":j2objc_cc_toolchain", LABEL).value(ccToolchain))
+ .add(
+ attr(JAVA_TOOLCHAIN_ATTRIBUTE_NAME, LABEL)
+ .useOutputLicenses()
+ .mandatoryProviders(ToolchainInfo.PROVIDER.id())
+ .value(javaToolchain))
.build();
}
