Skip to content

Commit d76e0ad

Browse files
committed
Implement automatic generation of kotlinc options using the official kotlin-compiler-arguments-description artifact from JetBrains.
- Auto-generated options: WriteKotlincCapabilities generates both capabilities.bzl (flag existence/stability metadata) and generated_opts.bzl (full typed Starlark options) from the compiler metadata artifact. - Simplified maintenance: Manual _KOPTS dict replaced with GENERATED_KOPTS import, with _MANUAL_KOPTS for special cases only. Changes: - Add kotlin-compiler-arguments-description dependency (version must match kotlin compiler version) - Rewrite WriteKotlincCapabilities to use the new artifact - Generate generated_opts_X.Y.bzl with attr.bool for booleans, attr.string for strings, attr.string_list for arrays - Simplify opts.kotlinc.bzl to merge generated + manual options
1 parent f253347 commit d76e0ad

File tree

13 files changed

+1733
-430
lines changed

13 files changed

+1733
-430
lines changed

MODULE.bazel

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ maven.install(
104104
"com.squareup.moshi:moshi-kotlin:1.15.2",
105105
"com.squareup.moshi:moshi-kotlin-codegen:1.15.2",
106106
"org.codehaus.plexus:plexus-utils:3.0.24",
107+
# kotlin-compiler-arguments-description provides JSON schema of all compiler options
108+
# Used by generator to produce capabilities.bzl with stability metadata
109+
"org.jetbrains.kotlin:kotlin-compiler-arguments-description:2.3.0",
110+
"org.jetbrains.kotlinx:kotlinx-serialization-json-jvm:1.7.3",
107111
"org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.2",
108112
],
109113
fail_if_repin_required = True,

docs/kotlin.md

Lines changed: 83 additions & 36 deletions
Large diffs are not rendered by default.

kotlin_rules_maven_install.json

Lines changed: 74 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"__AUTOGENERATED_FILE_DO_NOT_MODIFY_THIS_FILE_MANUALLY": "THERE_IS_NO_DATA_ONLY_ZUUL",
3-
"__INPUT_ARTIFACTS_HASH": 1433358606,
4-
"__RESOLVED_ARTIFACTS_HASH": 1634294553,
3+
"__INPUT_ARTIFACTS_HASH": 1715830214,
4+
"__RESOLVED_ARTIFACTS_HASH": -1677814615,
55
"conflict_resolution": {
66
"com.google.errorprone:error_prone_annotations:2.23.0": "com.google.errorprone:error_prone_annotations:2.26.1",
77
"com.google.guava:guava:33.0.0-jre": "com.google.guava:guava:33.2.1-jre"
@@ -399,6 +399,13 @@
399399
},
400400
"version": "1.3"
401401
},
402+
"org.jetbrains.kotlin:kotlin-compiler-arguments-description": {
403+
"shasums": {
404+
"jar": "f1bbc25e458cc0ac3ecb2dabf0ab901a53c0889118715fc02fab325cb4767d6d",
405+
"sources": "b0be844090f96391ee5e38faed1abf9ba810c7e585db3077b3ec47d14bf0d638"
406+
},
407+
"version": "2.3.0"
408+
},
402409
"org.jetbrains.kotlin:kotlin-metadata-jvm": {
403410
"shasums": {
404411
"jar": "0c64203991d0232d989cd5e366d6028d27b1b087240818178bd50c268eeab56f",
@@ -448,6 +455,20 @@
448455
},
449456
"version": "1.4.2"
450457
},
458+
"org.jetbrains.kotlinx:kotlinx-serialization-core-jvm": {
459+
"shasums": {
460+
"jar": "f0adde45864144475385cf4aa7e0b7feb27f61fcf9472665ed98cc971b06b1eb",
461+
"sources": "d084ce9bf130919d4b899db09896531440d1e330919187c7932d7fe0fa5257b8"
462+
},
463+
"version": "1.7.3"
464+
},
465+
"org.jetbrains.kotlinx:kotlinx-serialization-json-jvm": {
466+
"shasums": {
467+
"jar": "b1e9138499ed8d20375edda3f2b1c95f3103a258eff6af9edc5ea07100f2b29c",
468+
"sources": "fddb3c7e3c92692769285476308dd7a39009aed1e8ae80112169d72d75a275ab"
469+
},
470+
"version": "1.7.3"
471+
},
451472
"org.jetbrains:annotations": {
452473
"shasums": {
453474
"jar": "ace2a10dc8e2d5fd34925ecac03e4988b2c0f851650c94b8cef49ba1bd111478",
@@ -648,6 +669,10 @@
648669
"org.codehaus.plexus:plexus-utils",
649670
"org.eclipse.sisu:org.eclipse.sisu.inject"
650671
],
672+
"org.jetbrains.kotlin:kotlin-compiler-arguments-description": [
673+
"org.jetbrains.kotlin:kotlin-stdlib",
674+
"org.jetbrains.kotlinx:kotlinx-serialization-json-jvm"
675+
],
651676
"org.jetbrains.kotlin:kotlin-metadata-jvm": [
652677
"org.jetbrains.kotlin:kotlin-stdlib"
653678
],
@@ -668,6 +693,13 @@
668693
"org.jetbrains.kotlin:kotlin-stdlib",
669694
"org.jetbrains.kotlin:kotlin-stdlib-common"
670695
],
696+
"org.jetbrains.kotlinx:kotlinx-serialization-core-jvm": [
697+
"org.jetbrains.kotlin:kotlin-stdlib"
698+
],
699+
"org.jetbrains.kotlinx:kotlinx-serialization-json-jvm": [
700+
"org.jetbrains.kotlin:kotlin-stdlib",
701+
"org.jetbrains.kotlinx:kotlinx-serialization-core-jvm"
702+
],
671703
"org.ow2.asm:asm-analysis": [
672704
"org.ow2.asm:asm-tree"
673705
],
@@ -1280,6 +1312,16 @@
12801312
"org.hamcrest.core",
12811313
"org.hamcrest.internal"
12821314
],
1315+
"org.jetbrains.kotlin:kotlin-compiler-arguments-description": [
1316+
"org.jetbrains.kotlin.arguments.description",
1317+
"org.jetbrains.kotlin.arguments.description.removed",
1318+
"org.jetbrains.kotlin.arguments.dsl",
1319+
"org.jetbrains.kotlin.arguments.dsl.base",
1320+
"org.jetbrains.kotlin.arguments.dsl.types",
1321+
"org.jetbrains.kotlin.arguments.serialization.json",
1322+
"org.jetbrains.kotlin.arguments.serialization.json.base",
1323+
"org.jetbrains.kotlin.cli.common.arguments"
1324+
],
12831325
"org.jetbrains.kotlin:kotlin-metadata-jvm": [
12841326
"kotlin.metadata",
12851327
"kotlin.metadata.internal",
@@ -1423,6 +1465,18 @@
14231465
"kotlinx.coroutines.sync",
14241466
"kotlinx.coroutines.test"
14251467
],
1468+
"org.jetbrains.kotlinx:kotlinx-serialization-core-jvm": [
1469+
"kotlinx.serialization",
1470+
"kotlinx.serialization.builtins",
1471+
"kotlinx.serialization.descriptors",
1472+
"kotlinx.serialization.encoding",
1473+
"kotlinx.serialization.internal",
1474+
"kotlinx.serialization.modules"
1475+
],
1476+
"org.jetbrains.kotlinx:kotlinx-serialization-json-jvm": [
1477+
"kotlinx.serialization.json",
1478+
"kotlinx.serialization.json.internal"
1479+
],
14261480
"org.jetbrains:annotations": [
14271481
"org.intellij.lang.annotations",
14281482
"org.jetbrains.annotations"
@@ -1562,6 +1616,8 @@
15621616
"org.eclipse.sisu:org.eclipse.sisu.plexus:jar:sources",
15631617
"org.hamcrest:hamcrest-core",
15641618
"org.hamcrest:hamcrest-core:jar:sources",
1619+
"org.jetbrains.kotlin:kotlin-compiler-arguments-description",
1620+
"org.jetbrains.kotlin:kotlin-compiler-arguments-description:jar:sources",
15651621
"org.jetbrains.kotlin:kotlin-metadata-jvm",
15661622
"org.jetbrains.kotlin:kotlin-metadata-jvm:jar:sources",
15671623
"org.jetbrains.kotlin:kotlin-reflect",
@@ -1576,6 +1632,10 @@
15761632
"org.jetbrains.kotlin:kotlin-stdlib:jar:sources",
15771633
"org.jetbrains.kotlinx:kotlinx-coroutines-core",
15781634
"org.jetbrains.kotlinx:kotlinx-coroutines-core:jar:sources",
1635+
"org.jetbrains.kotlinx:kotlinx-serialization-core-jvm",
1636+
"org.jetbrains.kotlinx:kotlinx-serialization-core-jvm:jar:sources",
1637+
"org.jetbrains.kotlinx:kotlinx-serialization-json-jvm",
1638+
"org.jetbrains.kotlinx:kotlinx-serialization-json-jvm:jar:sources",
15791639
"org.jetbrains:annotations",
15801640
"org.jetbrains:annotations:jar:sources",
15811641
"org.jspecify:jspecify",
@@ -1703,6 +1763,8 @@
17031763
"org.eclipse.sisu:org.eclipse.sisu.plexus:jar:sources",
17041764
"org.hamcrest:hamcrest-core",
17051765
"org.hamcrest:hamcrest-core:jar:sources",
1766+
"org.jetbrains.kotlin:kotlin-compiler-arguments-description",
1767+
"org.jetbrains.kotlin:kotlin-compiler-arguments-description:jar:sources",
17061768
"org.jetbrains.kotlin:kotlin-metadata-jvm",
17071769
"org.jetbrains.kotlin:kotlin-metadata-jvm:jar:sources",
17081770
"org.jetbrains.kotlin:kotlin-reflect",
@@ -1717,6 +1779,10 @@
17171779
"org.jetbrains.kotlin:kotlin-stdlib:jar:sources",
17181780
"org.jetbrains.kotlinx:kotlinx-coroutines-core",
17191781
"org.jetbrains.kotlinx:kotlinx-coroutines-core:jar:sources",
1782+
"org.jetbrains.kotlinx:kotlinx-serialization-core-jvm",
1783+
"org.jetbrains.kotlinx:kotlinx-serialization-core-jvm:jar:sources",
1784+
"org.jetbrains.kotlinx:kotlinx-serialization-json-jvm",
1785+
"org.jetbrains.kotlinx:kotlinx-serialization-json-jvm:jar:sources",
17201786
"org.jetbrains:annotations",
17211787
"org.jetbrains:annotations:jar:sources",
17221788
"org.jspecify:jspecify",
@@ -1844,6 +1910,8 @@
18441910
"org.eclipse.sisu:org.eclipse.sisu.plexus:jar:sources",
18451911
"org.hamcrest:hamcrest-core",
18461912
"org.hamcrest:hamcrest-core:jar:sources",
1913+
"org.jetbrains.kotlin:kotlin-compiler-arguments-description",
1914+
"org.jetbrains.kotlin:kotlin-compiler-arguments-description:jar:sources",
18471915
"org.jetbrains.kotlin:kotlin-metadata-jvm",
18481916
"org.jetbrains.kotlin:kotlin-metadata-jvm:jar:sources",
18491917
"org.jetbrains.kotlin:kotlin-reflect",
@@ -1858,6 +1926,10 @@
18581926
"org.jetbrains.kotlin:kotlin-stdlib:jar:sources",
18591927
"org.jetbrains.kotlinx:kotlinx-coroutines-core",
18601928
"org.jetbrains.kotlinx:kotlinx-coroutines-core:jar:sources",
1929+
"org.jetbrains.kotlinx:kotlinx-serialization-core-jvm",
1930+
"org.jetbrains.kotlinx:kotlinx-serialization-core-jvm:jar:sources",
1931+
"org.jetbrains.kotlinx:kotlinx-serialization-json-jvm",
1932+
"org.jetbrains.kotlinx:kotlinx-serialization-json-jvm:jar:sources",
18611933
"org.jetbrains:annotations",
18621934
"org.jetbrains:annotations:jar:sources",
18631935
"org.jspecify:jspecify",

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ kt_jvm_library(
1919
deps = [
2020
":kotlinc_jar",
2121
"//kotlin/compiler:kotlin-reflect",
22+
"@kotlin_rules_maven//:org_jetbrains_kotlin_kotlin_compiler_arguments_description",
23+
"@kotlin_rules_maven//:org_jetbrains_kotlinx_kotlinx_serialization_json_jvm",
2224
],
2325
)
2426

0 commit comments

Comments
 (0)