mirror of https://github.com/bazelbuild/rules_cc
Remove linter warnings that a feature or action_config may not be declared by setting it to None instead.
Also rename the rule from cc_toolchain_config_rule to cc_toolchain_config Issue #5380 RELNOTES: None. PiperOrigin-RevId: 238945434
This commit is contained in:
parent
0c017ebc6d
commit
3b89ccfbe7
|
@ -304,7 +304,7 @@ func getRule(cToolchainIdentifiers map[string]CToolchainIdentifier) string {
|
|||
fmt.Sprintf(`"compiler": attr.string(values=["%s"]),`,
|
||||
strings.Join(compilerValues, "\", \"")))
|
||||
}
|
||||
return fmt.Sprintf(`cc_toolchain_config_rule = rule(
|
||||
return fmt.Sprintf(`cc_toolchain_config = rule(
|
||||
implementation = _impl,
|
||||
attrs = {
|
||||
%s
|
||||
|
@ -1074,6 +1074,11 @@ func getAssignmentStatement(field string, valToIds map[string][]string,
|
|||
fmt.Sprintf(
|
||||
"%selse:\n%sfail(\"Unreachable\")\n",
|
||||
getTabs(depth), getTabs(depth+1)))
|
||||
} else {
|
||||
b.WriteString(
|
||||
fmt.Sprintf(
|
||||
"%selse:\n%s%s = None\n",
|
||||
getTabs(depth), getTabs(depth+1), field))
|
||||
}
|
||||
}
|
||||
b.WriteString("\n")
|
||||
|
|
|
@ -1080,7 +1080,7 @@ func TestAllAndNoneAvailableErrorsWhenMoreThanOneElement(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestNoFailUnreachableInFeaturesAndActionConfigsDeclaration(t *testing.T) {
|
||||
func TestFeaturesAndActionConfigsSetToNoneWhenAllOptionsAreExausted(t *testing.T) {
|
||||
toolchainFeatureAEnabled := getCToolchain("1", "cpuA", "compilerA",
|
||||
[]string{getFeature([]string{"name: 'A'", "enabled: true"})},
|
||||
)
|
||||
|
@ -1118,8 +1118,9 @@ func TestNoFailUnreachableInFeaturesAndActionConfigsDeclaration(t *testing.T) {
|
|||
a_feature = feature(name = "A")
|
||||
elif (ctx.attr.cpu == "cpuA" and ctx.attr.compiler == "compilerA"):
|
||||
a_feature = feature(name = "A", enabled = True)
|
||||
|
||||
` /* empty line after the elif means there's no else statement */},
|
||||
else:
|
||||
a_feature = None
|
||||
`},
|
||||
{field: "action_config",
|
||||
toolchains: []string{
|
||||
toolchainActionConfigAEnabled, toolchainActionConfigADisabled, toolchainWithoutActionConfigA},
|
||||
|
@ -1128,8 +1129,9 @@ func TestNoFailUnreachableInFeaturesAndActionConfigsDeclaration(t *testing.T) {
|
|||
a_action = action_config(action_name = "A")
|
||||
elif (ctx.attr.cpu == "cpuA" and ctx.attr.compiler == "compilerD"):
|
||||
a_action = action_config(action_name = "A", enabled = True)
|
||||
|
||||
` /* empty line after the elif means there's no else statement */ },
|
||||
else:
|
||||
a_action = None
|
||||
`},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
|
|
Loading…
Reference in New Issue