diff --git a/src/main/java/com/google/devtools/build/lib/analysis/config/CoreOptionConverters.java b/src/main/java/com/google/devtools/build/lib/analysis/config/CoreOptionConverters.java index fc76634c3cb7dd..988c90401fc69d 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/config/CoreOptionConverters.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/config/CoreOptionConverters.java @@ -16,6 +16,8 @@ import static com.google.devtools.build.lib.packages.BuildType.LABEL; import static com.google.devtools.build.lib.packages.BuildType.LABEL_LIST; +import static com.google.devtools.build.lib.packages.BuildType.NODEP_LABEL; +import static com.google.devtools.build.lib.packages.BuildType.NODEP_LABEL_LIST; import static com.google.devtools.build.lib.packages.Type.BOOLEAN; import static com.google.devtools.build.lib.packages.Type.INTEGER; import static com.google.devtools.build.lib.packages.Type.STRING; @@ -57,6 +59,7 @@ public class CoreOptionConverters { .put(STRING_LIST, new CommaSeparatedOptionListConverter()) .put(LABEL, new LabelConverter()) .put(LABEL_LIST, new LabelListConverter()) + .put(NODEP_LABEL, new LabelConverter()) .build(); /** A converter from strings to Starlark int values. */ diff --git a/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java b/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java index 88b701d4fdce79..20e308ffe2a6ff 100644 --- a/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java +++ b/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java @@ -56,6 +56,7 @@ import com.google.devtools.build.lib.packages.RuleClass.Builder.ThirdPartyLicenseExistencePolicy; import com.google.devtools.build.lib.packages.RuleFactory.AttributeValues; import com.google.devtools.build.lib.packages.Type.ConversionException; +import com.google.devtools.build.lib.packages.Type.LabelClass; import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec; import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec.VisibleForSerialization; import com.google.devtools.build.lib.util.FileTypeSet; @@ -941,7 +942,7 @@ public RuleClass build(String name, String key) { attr(STARLARK_BUILD_SETTING_DEFAULT_ATTR_NAME, type) .nonconfigurable(BUILD_SETTING_DEFAULT_NONCONFIGURABLE) .mandatory(); - if (BuildType.isLabelType(type)) { + if (type.getLabelClass() == LabelClass.DEPENDENCY) { defaultAttrBuilder.allowedFileTypes(FileTypeSet.ANY_FILE); defaultAttrBuilder.allowedRuleClasses(ANY_RULE); } diff --git a/src/main/java/com/google/devtools/build/lib/rules/LabelBuildSettings.java b/src/main/java/com/google/devtools/build/lib/rules/LabelBuildSettings.java index a3a67fb6d8b63b..da497bb122f2cb 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/LabelBuildSettings.java +++ b/src/main/java/com/google/devtools/build/lib/rules/LabelBuildSettings.java @@ -15,6 +15,7 @@ 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.packages.BuildType.NODEP_LABEL; import static com.google.devtools.build.lib.packages.RuleClass.Builder.STARLARK_BUILD_SETTING_DEFAULT_ATTR_NAME; import com.google.devtools.build.lib.analysis.RuleDefinitionEnvironment; @@ -56,7 +57,7 @@ public class LabelBuildSettings { null, (rule, attributes, configuration) -> { if (rule == null || configuration == null) { - return attributes.get(STARLARK_BUILD_SETTING_DEFAULT_ATTR_NAME, LABEL); + return attributes.get(STARLARK_BUILD_SETTING_DEFAULT_ATTR_NAME, NODEP_LABEL); } Object commandLineValue = configuration.getOptions().getStarlarkOptions().get(rule.getLabel()); @@ -64,7 +65,7 @@ public class LabelBuildSettings { try { asLabel = commandLineValue == null - ? attributes.get(STARLARK_BUILD_SETTING_DEFAULT_ATTR_NAME, LABEL) + ? attributes.get(STARLARK_BUILD_SETTING_DEFAULT_ATTR_NAME, NODEP_LABEL) : LABEL.convert(commandLineValue, "label_flag value resolution"); } catch (ConversionException e) { throw new IllegalStateException( @@ -81,7 +82,7 @@ private static RuleClass buildRuleClass(RuleClass.Builder builder, boolean flag) .removeAttribute("licenses") .removeAttribute("distribs") .add(attr(":alias", LABEL).value(ACTUAL)) - .setBuildSetting(BuildSetting.create(flag, LABEL)) + .setBuildSetting(BuildSetting.create(flag, NODEP_LABEL)) .canHaveAnyProvider() .useToolchainResolution(ToolchainResolutionMode.DISABLED) .build();