From b38c3268fb2a8a63ee5320dae3df563ca72242cb Mon Sep 17 00:00:00 2001 From: Paolo Tranquilli Date: Fri, 6 Feb 2026 12:18:07 +0100 Subject: [PATCH] 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. --- MODULE.bazel | 2 +- .../rules_kotlin/2.2.0-codeql.1/source.json | 4 +- .../rules_kotlin/2.2.2-codeql.1/MODULE.bazel | 38 +++++++++++++++++++ .../codeql_add_language_version_option.patch | 30 +++++++++++++++ .../patches/codeql_do_not_emit_jdeps.patch | 14 +++++++ .../rules_kotlin/2.2.2-codeql.1/source.json | 9 +++++ .../modules/rules_kotlin/metadata.json | 1 + misc/codegen/BUILD.bazel | 3 ++ misc/codegen/templates/BUILD.bazel | 15 ++++++++ 9 files changed, 113 insertions(+), 3 deletions(-) create mode 100644 misc/bazel/registry/modules/rules_kotlin/2.2.2-codeql.1/MODULE.bazel create mode 100644 misc/bazel/registry/modules/rules_kotlin/2.2.2-codeql.1/patches/codeql_add_language_version_option.patch create mode 100644 misc/bazel/registry/modules/rules_kotlin/2.2.2-codeql.1/patches/codeql_do_not_emit_jdeps.patch create mode 100644 misc/bazel/registry/modules/rules_kotlin/2.2.2-codeql.1/source.json diff --git a/MODULE.bazel b/MODULE.bazel index aaa0ea0f7d6..f2c23b9ce85 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -26,7 +26,7 @@ bazel_dep(name = "bazel_skylib", version = "1.8.1") bazel_dep(name = "abseil-cpp", version = "20240116.1", repo_name = "absl") bazel_dep(name = "nlohmann_json", version = "3.11.3", repo_name = "json") bazel_dep(name = "fmt", version = "12.1.0-codeql.1") -bazel_dep(name = "rules_kotlin", version = "2.2.0-codeql.1") +bazel_dep(name = "rules_kotlin", version = "2.2.2-codeql.1") bazel_dep(name = "gazelle", version = "0.47.0") bazel_dep(name = "rules_dotnet", version = "0.21.5-codeql.1") bazel_dep(name = "googletest", version = "1.14.0.bcr.1") diff --git a/misc/bazel/registry/modules/rules_kotlin/2.2.0-codeql.1/source.json b/misc/bazel/registry/modules/rules_kotlin/2.2.0-codeql.1/source.json index bfa243b5a22..ca35aa4a5c1 100644 --- a/misc/bazel/registry/modules/rules_kotlin/2.2.0-codeql.1/source.json +++ b/misc/bazel/registry/modules/rules_kotlin/2.2.0-codeql.1/source.json @@ -2,8 +2,8 @@ "integrity": "sha256-4STROYYIW8ChW+LIXBQVurVwhEK3jSSf4iv430OlNA0=", "url": "https://github.com/bazelbuild/rules_kotlin/releases/download/v2.2.0/rules_kotlin-v2.2.0.tar.gz", "patches": { - "codeql_do_not_emit_jdeps.patch": "sha256-gIlhXEY71vlCkpr5wj2vm3yv6RwcuKLhgbTGqdVvQfU=", - "codeql_add_language_version_option.patch": "sha256-HoH8NWXxmYHmm/SxaugRdXgMntvcQx5gRLW2yQIvWhM=" + "codeql_add_language_version_option.patch": "sha256-HoH8NWXxmYHmm/SxaugRdXgMntvcQx5gRLW2yQIvWhM=", + "codeql_do_not_emit_jdeps.patch": "sha256-gIlhXEY71vlCkpr5wj2vm3yv6RwcuKLhgbTGqdVvQfU=" }, "patch_strip": 1 } diff --git a/misc/bazel/registry/modules/rules_kotlin/2.2.2-codeql.1/MODULE.bazel b/misc/bazel/registry/modules/rules_kotlin/2.2.2-codeql.1/MODULE.bazel new file mode 100644 index 00000000000..2c77fc8adb2 --- /dev/null +++ b/misc/bazel/registry/modules/rules_kotlin/2.2.2-codeql.1/MODULE.bazel @@ -0,0 +1,38 @@ +module( + name = "rules_kotlin", + version = "2.2.2-codeql.1", + compatibility_level = 1, + repo_name = "rules_kotlin", +) + +bazel_dep(name = "platforms", version = "0.0.11") +bazel_dep(name = "bazel_skylib", version = "1.7.1") +bazel_dep(name = "rules_java", version = "8.9.0") +bazel_dep(name = "rules_android", version = "0.6.4") +bazel_dep(name = "bazel_features", version = "1.25.0") +bazel_dep(name = "protobuf", version = "29.0", repo_name = "com_google_protobuf") +bazel_dep(name = "rules_proto", version = "6.0.2", repo_name = "rules_proto") +bazel_dep(name = "abseil-py", version = "2.1.0", repo_name = "py_absl") +bazel_dep(name = "rules_cc", version = "0.0.16") +bazel_dep(name = "bazel_worker_api", version = "0.0.8") +bazel_dep(name = "bazel_worker_java", version = "0.0.8") + +rules_java_toolchains = use_extension("@rules_java//java:extensions.bzl", "toolchains") +use_repo(rules_java_toolchains, "remote_java_tools") + +rules_kotlin_extensions = use_extension( + "//src/main/starlark/core/repositories:bzlmod_setup.bzl", + "rules_kotlin_extensions", +) +use_repo( + rules_kotlin_extensions, + "com_github_google_ksp", + "com_github_jetbrains_kotlin", + "com_github_pinterest_ktlint", + "kotlinx_serialization_core_jvm", + "kotlinx_serialization_json", + "kotlinx_serialization_json_jvm", + "kotlin_build_tools_impl", +) + +register_toolchains("//kotlin/internal:default_toolchain") diff --git a/misc/bazel/registry/modules/rules_kotlin/2.2.2-codeql.1/patches/codeql_add_language_version_option.patch b/misc/bazel/registry/modules/rules_kotlin/2.2.2-codeql.1/patches/codeql_add_language_version_option.patch new file mode 100644 index 00000000000..795d1f88f38 --- /dev/null +++ b/misc/bazel/registry/modules/rules_kotlin/2.2.2-codeql.1/patches/codeql_add_language_version_option.patch @@ -0,0 +1,30 @@ +--- a/src/main/starlark/core/options/opts.kotlinc.bzl 2000-01-01 01:00:00.000000000 +0100 ++++ b/src/main/starlark/core/options/opts.kotlinc.bzl 2025-11-17 16:51:01.012063056 +0100 +@@ -51,6 +51,11 @@ + return None + return ["-Xjdk-release=%s" % version] + ++def _map_language_version_to_flag(version): ++ if not version: ++ return None ++ return ["-language-version=%s" % version, "-api-version=%s" % version] ++ + _KOPTS_ALL = { + "include_stdlibs": struct( + args = dict( +@@ -495,6 +500,15 @@ + value_to_flag = None, + map_value_to_flag = _map_warning_level, + ), ++ "language_version": struct( ++ args = dict( ++ default = "1.9", ++ doc = "-language-version", ++ ), ++ type = attr.string, ++ value_to_flag = None, ++ map_value_to_flag = _map_language_version_to_flag, ++ ), + } + + def _merge(key, rule_defined): diff --git a/misc/bazel/registry/modules/rules_kotlin/2.2.2-codeql.1/patches/codeql_do_not_emit_jdeps.patch b/misc/bazel/registry/modules/rules_kotlin/2.2.2-codeql.1/patches/codeql_do_not_emit_jdeps.patch new file mode 100644 index 00000000000..e6b71ab0c4f --- /dev/null +++ b/misc/bazel/registry/modules/rules_kotlin/2.2.2-codeql.1/patches/codeql_do_not_emit_jdeps.patch @@ -0,0 +1,14 @@ +Emitting jdeps is broken for the 2.0.0 kotlin extractor, and we don't need those files. +Patching it here rather than passing `--@rules_kotlin//kotlin/settings:jvm_emit_jdeps=false` +allows us to not have to specify that option (and therefore pull in `rules_kotlin`) in `semmle-code`. +--- a/kotlin/settings/BUILD.bazel ++++ b/kotlin/settings/BUILD.bazel +@@ -16,6 +16,6 @@ release_archive( + # Flag that controls the emission of jdeps files during kotlin jvm compilation. + bool_flag( + name = "jvm_emit_jdeps", +- build_setting_default = True, # Upstream default behavior ++ build_setting_default = False, + visibility = ["//visibility:public"], + ) + diff --git a/misc/bazel/registry/modules/rules_kotlin/2.2.2-codeql.1/source.json b/misc/bazel/registry/modules/rules_kotlin/2.2.2-codeql.1/source.json new file mode 100644 index 00000000000..23deb231a09 --- /dev/null +++ b/misc/bazel/registry/modules/rules_kotlin/2.2.2-codeql.1/source.json @@ -0,0 +1,9 @@ +{ + "integrity": "sha256-QR2yavs0ksyDUbW1NJkxUir+LFTyZRttEncwoSVtD2A=", + "url": "https://github.com/bazelbuild/rules_kotlin/releases/download/v2.2.2/rules_kotlin-v2.2.2.tar.gz", + "patches": { + "codeql_add_language_version_option.patch": "sha256-HoH8NWXxmYHmm/SxaugRdXgMntvcQx5gRLW2yQIvWhM=", + "codeql_do_not_emit_jdeps.patch": "sha256-gIlhXEY71vlCkpr5wj2vm3yv6RwcuKLhgbTGqdVvQfU=" + }, + "patch_strip": 1 +} diff --git a/misc/bazel/registry/modules/rules_kotlin/metadata.json b/misc/bazel/registry/modules/rules_kotlin/metadata.json index 3609865f4d5..23266f29c4e 100644 --- a/misc/bazel/registry/modules/rules_kotlin/metadata.json +++ b/misc/bazel/registry/modules/rules_kotlin/metadata.json @@ -22,6 +22,7 @@ ], "versions": [ "2.2.0-codeql.1", + "2.2.2-codeql.1" ], "yanked_versions": {} } diff --git a/misc/codegen/BUILD.bazel b/misc/codegen/BUILD.bazel index c7b88de96b7..90e9842a941 100644 --- a/misc/codegen/BUILD.bazel +++ b/misc/codegen/BUILD.bazel @@ -5,6 +5,9 @@ py_binary( srcs = ["codegen.py"], data = [ "//misc/codegen/templates:cpp", + "//misc/codegen/templates:dbscheme", + "//misc/codegen/templates:ql", + "//misc/codegen/templates:rust", "//misc/codegen/templates:trap", ], visibility = ["//visibility:public"], diff --git a/misc/codegen/templates/BUILD.bazel b/misc/codegen/templates/BUILD.bazel index a86346245af..9068cc7f66e 100644 --- a/misc/codegen/templates/BUILD.bazel +++ b/misc/codegen/templates/BUILD.bazel @@ -1,5 +1,10 @@ package(default_visibility = ["//misc/codegen:__subpackages__"]) +filegroup( + name = "dbscheme", + srcs = ["dbscheme.mustache"], +) + filegroup( name = "trap", srcs = glob(["trap_*.mustache"]), @@ -9,3 +14,13 @@ filegroup( name = "cpp", srcs = glob(["cpp_*.mustache"]), ) + +filegroup( + name = "ql", + srcs = glob(["ql_*.mustache"]), +) + +filegroup( + name = "rust", + srcs = glob(["rust_*.mustache"]), +)