Skip to content

Commit

Permalink
Turn applicable_licenses on platform() into a no-op. (bazelbuild#18089)
Browse files Browse the repository at this point in the history
This prevents an analysis loop where default_applicable_licenses
applies a license to a platform, but then the same license rule
depends on the platform.

Backport of Ic12306f5a405c88bd65acf3b8ec419328ce663f3
  • Loading branch information
aiuto authored Apr 13, 2023
1 parent 1474b5b commit 5ddef47
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.google.devtools.build.lib.analysis.PlatformConfiguration;
import com.google.devtools.build.lib.analysis.RuleDefinition;
import com.google.devtools.build.lib.analysis.RuleDefinitionEnvironment;
import com.google.devtools.build.lib.packages.BuildType;
import com.google.devtools.build.lib.packages.RuleClass;
import com.google.devtools.build.lib.packages.RuleClass.ToolchainResolutionMode;
import com.google.devtools.build.lib.packages.Type;
Expand All @@ -41,6 +42,13 @@ public RuleClass build(RuleClass.Builder builder, RuleDefinitionEnvironment env)
// No need to show up in ":all", etc. target patterns.
.value(ImmutableList.of("manual"))
.nonconfigurable("low-level attribute, used in platform configuration"))
.override(
// A platform is essentially a constant which is never linked into a target.
// This will, in a very hacky way, suppress picking up default_applicable_licenses
attr("applicable_licenses", BuildType.LABEL_LIST)
.value(ImmutableList.of())
.allowedFileTypes()
.nonconfigurable("fundamental constant, used in platform configuration"))
.exemptFromConstraintChecking("this rule helps *define* a constraint")
.useToolchainResolution(ToolchainResolutionMode.DISABLED)
.removeAttribute("deps")
Expand Down

0 comments on commit 5ddef47

Please sign in to comment.