Skip to content

Commit 672ac8c

Browse files
committed
fix: upgrade rules_kotlin to 2.2.2 for Windows compatibility
Upgrade from 2.2.0-codeql.1 to 2.2.2-codeql.1 which includes: - Fix Windows bzlmod builder classpath issue - Move to official bazel worker api This eliminates the need for --legacy_external_runfiles on Windows. Also fix codegen templates to be included in runfiles.
1 parent dc2d396 commit 672ac8c

File tree

9 files changed

+113
-3
lines changed

9 files changed

+113
-3
lines changed

MODULE.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ bazel_dep(name = "bazel_skylib", version = "1.8.1")
2626
bazel_dep(name = "abseil-cpp", version = "20240116.1", repo_name = "absl")
2727
bazel_dep(name = "nlohmann_json", version = "3.11.3", repo_name = "json")
2828
bazel_dep(name = "fmt", version = "12.1.0-codeql.1")
29-
bazel_dep(name = "rules_kotlin", version = "2.2.0-codeql.1")
29+
bazel_dep(name = "rules_kotlin", version = "2.2.2-codeql.1")
3030
bazel_dep(name = "gazelle", version = "0.47.0")
3131
bazel_dep(name = "rules_dotnet", version = "0.21.5-codeql.1")
3232
bazel_dep(name = "googletest", version = "1.14.0.bcr.1")

misc/bazel/registry/modules/rules_kotlin/2.2.0-codeql.1/source.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
"integrity": "sha256-4STROYYIW8ChW+LIXBQVurVwhEK3jSSf4iv430OlNA0=",
33
"url": "https://github.com/bazelbuild/rules_kotlin/releases/download/v2.2.0/rules_kotlin-v2.2.0.tar.gz",
44
"patches": {
5-
"codeql_do_not_emit_jdeps.patch": "sha256-gIlhXEY71vlCkpr5wj2vm3yv6RwcuKLhgbTGqdVvQfU=",
6-
"codeql_add_language_version_option.patch": "sha256-HoH8NWXxmYHmm/SxaugRdXgMntvcQx5gRLW2yQIvWhM="
5+
"codeql_add_language_version_option.patch": "sha256-HoH8NWXxmYHmm/SxaugRdXgMntvcQx5gRLW2yQIvWhM=",
6+
"codeql_do_not_emit_jdeps.patch": "sha256-gIlhXEY71vlCkpr5wj2vm3yv6RwcuKLhgbTGqdVvQfU="
77
},
88
"patch_strip": 1
99
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
module(
2+
name = "rules_kotlin",
3+
version = "2.2.2-codeql.1",
4+
compatibility_level = 1,
5+
repo_name = "rules_kotlin",
6+
)
7+
8+
bazel_dep(name = "platforms", version = "0.0.11")
9+
bazel_dep(name = "bazel_skylib", version = "1.7.1")
10+
bazel_dep(name = "rules_java", version = "8.9.0")
11+
bazel_dep(name = "rules_android", version = "0.6.4")
12+
bazel_dep(name = "bazel_features", version = "1.25.0")
13+
bazel_dep(name = "protobuf", version = "29.0", repo_name = "com_google_protobuf")
14+
bazel_dep(name = "rules_proto", version = "6.0.2", repo_name = "rules_proto")
15+
bazel_dep(name = "abseil-py", version = "2.1.0", repo_name = "py_absl")
16+
bazel_dep(name = "rules_cc", version = "0.0.16")
17+
bazel_dep(name = "bazel_worker_api", version = "0.0.8")
18+
bazel_dep(name = "bazel_worker_java", version = "0.0.8")
19+
20+
rules_java_toolchains = use_extension("@rules_java//java:extensions.bzl", "toolchains")
21+
use_repo(rules_java_toolchains, "remote_java_tools")
22+
23+
rules_kotlin_extensions = use_extension(
24+
"//src/main/starlark/core/repositories:bzlmod_setup.bzl",
25+
"rules_kotlin_extensions",
26+
)
27+
use_repo(
28+
rules_kotlin_extensions,
29+
"com_github_google_ksp",
30+
"com_github_jetbrains_kotlin",
31+
"com_github_pinterest_ktlint",
32+
"kotlinx_serialization_core_jvm",
33+
"kotlinx_serialization_json",
34+
"kotlinx_serialization_json_jvm",
35+
"kotlin_build_tools_impl",
36+
)
37+
38+
register_toolchains("//kotlin/internal:default_toolchain")
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
--- a/src/main/starlark/core/options/opts.kotlinc.bzl 2000-01-01 01:00:00.000000000 +0100
2+
+++ b/src/main/starlark/core/options/opts.kotlinc.bzl 2025-11-17 16:51:01.012063056 +0100
3+
@@ -51,6 +51,11 @@
4+
return None
5+
return ["-Xjdk-release=%s" % version]
6+
7+
+def _map_language_version_to_flag(version):
8+
+ if not version:
9+
+ return None
10+
+ return ["-language-version=%s" % version, "-api-version=%s" % version]
11+
+
12+
_KOPTS_ALL = {
13+
"include_stdlibs": struct(
14+
args = dict(
15+
@@ -495,6 +500,15 @@
16+
value_to_flag = None,
17+
map_value_to_flag = _map_warning_level,
18+
),
19+
+ "language_version": struct(
20+
+ args = dict(
21+
+ default = "1.9",
22+
+ doc = "-language-version",
23+
+ ),
24+
+ type = attr.string,
25+
+ value_to_flag = None,
26+
+ map_value_to_flag = _map_language_version_to_flag,
27+
+ ),
28+
}
29+
30+
def _merge(key, rule_defined):
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Emitting jdeps is broken for the 2.0.0 kotlin extractor, and we don't need those files.
2+
Patching it here rather than passing `--@rules_kotlin//kotlin/settings:jvm_emit_jdeps=false`
3+
allows us to not have to specify that option (and therefore pull in `rules_kotlin`) in `semmle-code`.
4+
--- a/kotlin/settings/BUILD.bazel
5+
+++ b/kotlin/settings/BUILD.bazel
6+
@@ -16,6 +16,6 @@ release_archive(
7+
# Flag that controls the emission of jdeps files during kotlin jvm compilation.
8+
bool_flag(
9+
name = "jvm_emit_jdeps",
10+
- build_setting_default = True, # Upstream default behavior
11+
+ build_setting_default = False,
12+
visibility = ["//visibility:public"],
13+
)
14+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"integrity": "sha256-QR2yavs0ksyDUbW1NJkxUir+LFTyZRttEncwoSVtD2A=",
3+
"url": "https://github.com/bazelbuild/rules_kotlin/releases/download/v2.2.2/rules_kotlin-v2.2.2.tar.gz",
4+
"patches": {
5+
"codeql_add_language_version_option.patch": "sha256-HoH8NWXxmYHmm/SxaugRdXgMntvcQx5gRLW2yQIvWhM=",
6+
"codeql_do_not_emit_jdeps.patch": "sha256-gIlhXEY71vlCkpr5wj2vm3yv6RwcuKLhgbTGqdVvQfU="
7+
},
8+
"patch_strip": 1
9+
}

misc/bazel/registry/modules/rules_kotlin/metadata.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
],
2323
"versions": [
2424
"2.2.0-codeql.1",
25+
"2.2.2-codeql.1"
2526
],
2627
"yanked_versions": {}
2728
}

misc/codegen/BUILD.bazel

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ py_binary(
55
srcs = ["codegen.py"],
66
data = [
77
"//misc/codegen/templates:cpp",
8+
"//misc/codegen/templates:dbscheme",
9+
"//misc/codegen/templates:ql",
10+
"//misc/codegen/templates:rust",
811
"//misc/codegen/templates:trap",
912
],
1013
visibility = ["//visibility:public"],

misc/codegen/templates/BUILD.bazel

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
package(default_visibility = ["//misc/codegen:__subpackages__"])
22

3+
filegroup(
4+
name = "dbscheme",
5+
srcs = ["dbscheme.mustache"],
6+
)
7+
38
filegroup(
49
name = "trap",
510
srcs = glob(["trap_*.mustache"]),
@@ -9,3 +14,13 @@ filegroup(
914
name = "cpp",
1015
srcs = glob(["cpp_*.mustache"]),
1116
)
17+
18+
filegroup(
19+
name = "ql",
20+
srcs = glob(["ql_*.mustache"]),
21+
)
22+
23+
filegroup(
24+
name = "rust",
25+
srcs = glob(["rust_*.mustache"]),
26+
)

0 commit comments

Comments
 (0)