Skip to content

Commit e78858a

Browse files
committed
Update options
Apparently, the reflection subtlely changed as well.
1 parent 51b753b commit e78858a

File tree

5 files changed

+180
-26
lines changed

5 files changed

+180
-26
lines changed

scripts/reflow_skylark

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@
1616

1717
# Note: Written on a mac please make it compatible with linux if needed.
1818

19-
buildifier --warnings=-confusing-name,-constant-glob,-duplicated-name,-function-docstring,-function-docstring-args,-function-docstring-header,-module-docstring,-name-conventions,-no-effect,-constant-glob,-provider-params,-print,-rule-impl-return,-bzl-visibility,-unnamed-macro,-uninitialized,-unreachable -lint warn $(find . -type f \
20-
-iname "*.bzl" -or \
21-
-name "*.bazel" -and -not -name "MODULE.*" -or \
22-
-name "WORKSPACE"
19+
buildifier --warnings=-confusing-name,-constant-glob,-duplicated-name,-function-docstring,-function-docstring-args,-function-docstring-header,-module-docstring,-name-conventions,-no-effect,-constant-glob,-provider-params,-print,-rule-impl-return,-bzl-visibility,-unnamed-macro,-uninitialized,-unreachable -lint warn $(find . \
20+
-path ./.ijwb -prune \
21+
-type f \
22+
-iname "*.bzl" -or -name "*.bazel" \
23+
-and -not \( -name "MODULE.*" -or \
24+
-name "WORKSPACE" \)
2325
)

src/main/kotlin/io/bazel/kotlin/generate/BUILD.bazel

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
1-
load("//kotlin:jvm.bzl", "kt_jvm_binary", "kt_jvm_library")
1+
load("//kotlin:jvm.bzl", "kt_jvm_binary", "kt_jvm_import", "kt_jvm_library")
22

33
# Work around neverlink.
4-
java_import(
4+
kt_jvm_import(
55
name = "kotlinc_jar",
66
jars = [
77
"@com_github_jetbrains_kotlin//:kotlin-compiler",
88
],
9-
deps = [],
9+
deps = [
10+
"//kotlin/compiler:annotations",
11+
"//kotlin/compiler:kotlin-stdlib",
12+
"//kotlin/compiler:kotlin-stdlib-jdk7",
13+
"//kotlin/compiler:kotlin-stdlib-jdk8",
14+
"//kotlin/compiler:kotlinx-coroutines-core-jvm",
15+
"//kotlin/compiler:trove4j",
16+
],
1017
)
1118

1219
kt_jvm_library(

src/main/kotlin/io/bazel/kotlin/generate/WriteKotlincCapabilities.kt

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
package io.bazel.kotlin.generate
22

33
import io.bazel.kotlin.generate.WriteKotlincCapabilities.KotlincCapabilities.Companion.asCapabilities
4+
import io.bazel.kotlin.generate.WriteKotlincCapabilities.KotlincCapability
45
import org.jetbrains.kotlin.cli.common.arguments.Argument
56
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
67
import org.jetbrains.kotlin.config.LanguageVersion
8+
import org.jetbrains.kotlin.load.java.JvmAbi
9+
import java.nio.charset.StandardCharsets
710
import java.nio.file.FileSystems
811
import java.nio.file.Files
912
import java.time.Year
@@ -77,29 +80,38 @@ object WriteKotlincCapabilities {
7780
Files.createDirectories(parent)
7881
}
7982
writeText(
80-
K2JVMCompilerArguments::class.members.asSequence()
81-
.map { member ->
82-
member.annotations.find { it is Argument }?.let { argument ->
83-
member to (argument as Argument)
84-
}
85-
}
86-
.filterNotNull()
87-
.map { (member, argument) ->
88-
KotlincCapability(
89-
flag = argument.value,
90-
default = "${member.call(instance)}",
91-
type = member.returnType.toString(),
92-
)
93-
}
83+
getArguments(K2JVMCompilerArguments::class.java)
9484
.filterNot(KotlincCapability::shouldSuppress)
95-
.asCapabilities().asCapabilitiesBzl(),
85+
.asCapabilities()
86+
.asCapabilitiesBzl(),
87+
StandardCharsets.UTF_8
9688
)
9789
}
9890
.let {
9991
println("Wrote to $it")
10092
}
10193
}
10294

95+
private fun getArguments(klass: Class<*>) : Sequence<KotlincCapability> = sequence {
96+
val instance = K2JVMCompilerArguments()
97+
klass.superclass?.let {
98+
yieldAll(getArguments(it))
99+
}
100+
101+
for (field in klass.declaredFields) {
102+
field.getAnnotation(Argument::class.java)?.let { argument ->
103+
val getter = klass.getMethod(JvmAbi.getterName(field.name))
104+
yield(
105+
KotlincCapability(
106+
flag = argument.value,
107+
default = "${ getter.invoke(instance)}",
108+
type = field.type.toString(),
109+
)
110+
)
111+
}
112+
}
113+
}
114+
103115
private class KotlincCapabilities(capabilities: Iterable<KotlincCapability>) :
104116
List<KotlincCapability> by capabilities.toList() {
105117

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ _KOPTS_ALL = {
410410
"jvm_target": struct(
411411
args = dict(
412412
default = "",
413-
doc = "The -jvm_target flag. This is only tested at 1.8.",
413+
doc = "The target version of the generated JVM bytecode",
414414
values = ["1.6", "1.8", "9", "10", "11", "12", "13", "15", "16", "17"],
415415
),
416416
type = attr.string,
@@ -420,7 +420,9 @@ _KOPTS_ALL = {
420420
"x_jdk_release": struct(
421421
args = dict(
422422
default = "",
423-
doc = "The -jvm_target flag. This is only tested at 1.8.",
423+
doc = """Compile against the specified JDK API version, similarly to javac's '-release'. This requires JDK 9 or newer.
424+
The supported versions depend on the JDK used; for JDK 17+, the supported versions are 1.8 and 9–21.
425+
This also sets the value of '-jvm-target' to be equal to the selected JDK version.""",
424426
values = ["1.6", "1.8", "9", "10", "11", "12", "13", "15", "16", "17"],
425427
),
426428
type = attr.string,

src/main/starlark/core/repositories/kotlin/capabilities_2.1.bzl.com_github_jetbrains_kotlin.bazel

Lines changed: 133 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,136 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414
KOTLIN_OPTS = [
15-
16-
]
15+
"-Werror",
16+
"-Wextra",
17+
"-XXexplicit-return-types",
18+
"-Xabi-stability",
19+
"-Xadd-modules",
20+
"-Xallow-any-scripts-in-source-roots",
21+
"-Xallow-kotlin-package",
22+
"-Xallow-no-source-files",
23+
"-Xallow-unstable-dependencies",
24+
"-Xassertions",
25+
"-Xbackend-threads",
26+
"-Xcheck-phase-conditions",
27+
"-Xcheck-sticky-phase-conditions",
28+
"-Xcommon-sources",
29+
"-Xcompile-java",
30+
"-Xconsistent-data-class-copy-visibility",
31+
"-Xcontext-receivers",
32+
"-Xdebug",
33+
"-Xdefault-script-extension",
34+
"-Xdirect-java-actualization",
35+
"-Xdisable-default-scripting-plugin",
36+
"-Xdisable-phases",
37+
"-Xdisable-standard-script",
38+
"-Xdont-warn-on-error-suppression",
39+
"-Xemit-jvm-type-annotations",
40+
"-Xenable-builder-inference",
41+
"-Xenable-incremental-compilation",
42+
"-Xenhance-type-parameter-types-to-def-not-null",
43+
"-Xexpect-actual-classes",
44+
"-Xexplicit-api",
45+
"-Xextended-compiler-checks",
46+
"-Xfragment-refines",
47+
"-Xfragment-sources",
48+
"-Xfragments",
49+
"-Xfriend-paths",
50+
"-Xgenerate-strict-metadata-version",
51+
"-Xignore-const-optimization-errors",
52+
"-Xinference-compatibility",
53+
"-Xinline-classes",
54+
"-Xir-do-not-clear-binding-context",
55+
"-Xir-inliner",
56+
"-Xjava-package-prefix",
57+
"-Xjava-source-roots",
58+
"-Xjavac-arguments",
59+
"-Xjdk-release",
60+
"-Xjspecify-annotations",
61+
"-Xjsr305",
62+
"-Xjvm-default",
63+
"-Xjvm-enable-preview",
64+
"-Xklib",
65+
"-Xlambdas",
66+
"-Xlegacy-smart-cast-after-try",
67+
"-Xlink-via-signatures",
68+
"-Xlist-phases",
69+
"-Xmetadata-klib",
70+
"-Xmetadata-version",
71+
"-Xmodule-path",
72+
"-Xmulti-dollar-interpolation",
73+
"-Xmulti-platform",
74+
"-Xmultifile-parts-inherit",
75+
"-Xnew-inference",
76+
"-Xno-call-assertions",
77+
"-Xno-check-actual",
78+
"-Xno-inline",
79+
"-Xno-new-java-annotation-targets",
80+
"-Xno-optimize",
81+
"-Xno-param-assertions",
82+
"-Xno-receiver-assertions",
83+
"-Xno-reset-jar-timestamps",
84+
"-Xno-source-debug-extension",
85+
"-Xno-unified-null-checks",
86+
"-Xnon-local-break-continue",
87+
"-Xnullability-annotations",
88+
"-Xphases-to-dump",
89+
"-Xphases-to-dump-after",
90+
"-Xphases-to-dump-before",
91+
"-Xphases-to-validate",
92+
"-Xphases-to-validate-after",
93+
"-Xphases-to-validate-before",
94+
"-Xprofile",
95+
"-Xprofile-phases",
96+
"-Xrender-internal-diagnostic-names",
97+
"-Xreport-all-warnings",
98+
"-Xreport-output-files",
99+
"-Xreport-perf",
100+
"-Xsam-conversions",
101+
"-Xsanitize-parentheses",
102+
"-Xscript-resolver-environment",
103+
"-Xself-upper-bound-inference",
104+
"-Xserialize-ir",
105+
"-Xskip-metadata-version-check",
106+
"-Xskip-prerelease-check",
107+
"-Xstdlib-compilation",
108+
"-Xstring-concat",
109+
"-Xsupport-compatqual-checker-framework-annotations",
110+
"-Xsuppress-api-version-greater-than-language-version-error",
111+
"-Xsuppress-deprecated-jvm-target-warning",
112+
"-Xsuppress-missing-builtins-error",
113+
"-Xsuppress-version-warnings",
114+
"-Xsuppress-warning",
115+
"-Xtype-enhancement-improvements-strict-mode",
116+
"-Xunrestricted-builder-inference",
117+
"-Xuse-14-inline-classes-mangling-scheme",
118+
"-Xuse-fast-jar-file-system",
119+
"-Xuse-fir-experimental-checkers",
120+
"-Xuse-fir-ic",
121+
"-Xuse-fir-lt",
122+
"-Xuse-inline-scopes-numbers",
123+
"-Xuse-javac",
124+
"-Xuse-k2",
125+
"-Xuse-k2-kapt",
126+
"-Xuse-old-backend",
127+
"-Xuse-old-class-files-reading",
128+
"-Xuse-old-innerclasses-logic",
129+
"-Xuse-type-table",
130+
"-Xvalidate-bytecode",
131+
"-Xvalue-classes",
132+
"-Xverbose-phases",
133+
"-Xverify-ir",
134+
"-Xverify-ir-visibility",
135+
"-Xverify-ir-visibility-after-inlining",
136+
"-Xwhen-guards",
137+
"-api-version",
138+
"-java-parameters",
139+
"-jvm-target",
140+
"-language-version",
141+
"-no-reflect",
142+
"-nowarn",
143+
"-opt-in",
144+
"-progressive",
145+
"-verbose",
146+
"-version",
147+
]

0 commit comments

Comments
 (0)