Skip to content

Commit a9a90fe

Browse files
committed
Add support for x_warning_level
1 parent ac136e7 commit a9a90fe

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/main/starlark/core/options/opts.kotlinc.bzl

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,23 @@ load("@com_github_jetbrains_kotlin//:capabilities.bzl", _KOTLIN_OPTS = "KOTLIN_O
1616
load("//src/main/starlark/core/options:convert.bzl", "convert")
1717
load("//src/main/starlark/core/options:derive.bzl", "derive")
1818

19+
_ALLOWED_SUPPRESS_LEVELS = [
20+
"error",
21+
"warning",
22+
"disabled",
23+
]
24+
25+
def _map_warning_level(values):
26+
if not values:
27+
return None
28+
29+
args = []
30+
for k, v in values.items():
31+
if v not in _ALLOWED_SUPPRESS_LEVELS:
32+
fail("Error: Suppress key '{}' has an invalid value of '{}'".format(k, v))
33+
args.append("-Xwarning-level={}:{}".format(k, v))
34+
return args
35+
1936
def _map_optin_class_to_flag(values):
2037
return ["-opt-in=%s" % v for v in values]
2138

@@ -425,6 +442,15 @@ default: 'first-only-warn' in language version 2.2+, 'first-only' in version 2.1
425442
derive.info: derive.repeated_values_for("-Xsuppress-warning="),
426443
},
427444
),
445+
"x_warning_level": struct(
446+
args = dict(
447+
default = {},
448+
doc = "Define APIs to opt-in to.",
449+
),
450+
type = attr.string_dict,
451+
value_to_flag = None,
452+
map_value_to_flag = _map_warning_level,
453+
),
428454
"x_type_enhancement_improvements_strict_mode": struct(
429455
args = dict(
430456
default = False,

0 commit comments

Comments
 (0)