From b7f5832eaf4fce780cdd799dbd1f38436f6d650c Mon Sep 17 00:00:00 2001 From: Marc Plano-Lesay Date: Wed, 18 Nov 2020 03:24:26 +1100 Subject: [PATCH] Add warning as error to the warn option. Matches Gradle's equivalent option (AllWarningsAsErrors). --- kotlin/internal/jvm/compile.bzl | 8 ++++++-- kotlin/internal/opts.bzl | 14 ++++++++------ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/kotlin/internal/jvm/compile.bzl b/kotlin/internal/jvm/compile.bzl index f4f83ce92..2010145bc 100644 --- a/kotlin/internal/jvm/compile.bzl +++ b/kotlin/internal/jvm/compile.bzl @@ -338,8 +338,10 @@ def _kotlinc_options_provider_to_flags(opts): if not opts: return "" flags = [] - if not opts.warn: + if opts.warn == "off": flags.append("-nowarn") + elif opts.warn == "error": + flags.append("-Werror") if opts.x_use_experimental: flags.append("-Xuse-experimental=kotlin.Experimental") if opts.x_use_ir: @@ -354,8 +356,10 @@ def _javac_options_provider_to_flags(opts): if not opts: return "" flags = [] - if not opts.warn: + if opts.warn == "off": flags.append("-nowarn") + elif opts.warn == "error": + flags.append("-Werror") if opts.x_ep_disable_all_checks: flags.append("-XepDisableAllChecks") if opts.x_lint: diff --git a/kotlin/internal/opts.bzl b/kotlin/internal/opts.bzl index 65f24506d..5115cf12a 100644 --- a/kotlin/internal/opts.bzl +++ b/kotlin/internal/opts.bzl @@ -15,10 +15,11 @@ _KOPTS = { "warn": struct( args = dict( - default = True, - doc = "Enable or disable compiler warnings.", + default = "report", + doc = "Control warning behaviour.", + values = ["off", "report", "error"], ), - type = attr.bool, + type = attr.string, ), "x_use_experimental": struct( args = dict( @@ -77,10 +78,11 @@ kt_kotlinc_options = rule( _JOPTS = { "warn": struct( args = dict( - default = True, - doc = "Enable or disable compiler warnings.", + default = "report", + doc = "Control warning behaviour.", + values = ["off", "report", "error"], ), - type = attr.bool, + type = attr.string, ), "x_ep_disable_all_checks": struct( args = dict(