Skip to content

Commit

Permalink
Remove skylib, as it cannot be loaded soon enough in the workspace
Browse files Browse the repository at this point in the history
  • Loading branch information
restingbull committed Jan 3, 2025
1 parent 33d73f6 commit 2282e9e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 17 deletions.
21 changes: 16 additions & 5 deletions src/main/starlark/core/repositories/compiler.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
Defines kotlin compiler repositories.
"""

load("@bazel_skylib//lib:versions.bzl", "versions")
load("//src/main/starlark/core/repositories/kotlin:templates.bzl", "TEMPLATES")

def _kotlin_compiler_impl(repository_ctx):
Expand Down Expand Up @@ -48,17 +47,29 @@ def _kotlin_capabilities_impl(repository_ctx):
executable = False,
)

def _coerce_int(string_value):
digits = "".join([
string_value[i]
for i in range(len(string_value))
if string_value[i].isdigit()
])
return 0 if not digits else int(digits)

def _version(version_string):
return tuple([
_coerce_int(segment)
for segment in version_string.split(".", 3)
])

def _parse_version(basename):
if "capabilities" not in basename:
return None
version_string = basename[len("capabilities_"):basename.find(".bzl")]
if version_string == "legacy":
return (0, 0, 0)
return versions.parse(version_string)
return _version(version_string)

def _get_capability_template(compiler_version, templates):
version_index = {}
target = versions.parse(compiler_version)
target = _version(compiler_version)
for template in templates:
version = _parse_version(template.basename)
if not version:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2024 The Bazel Authors. All rights reserved.
# Copyright 2025 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
22 changes: 11 additions & 11 deletions src/main/starlark/core/repositories/kotlin/templates.bzl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2024 The Bazel Authors. All rights reserved.
# Copyright 2025 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -14,13 +14,13 @@

# DO NOT EDIT: generated by bazel run //src/main/kotlin/io/bazel/kotlin/generate:kotlin_release_options
TEMPLATES = [
Label("capabilities_1.4.bzl.com_github_jetbrains_kotlin.bazel"),
Label("capabilities_1.5.bzl.com_github_jetbrains_kotlin.bazel"),
Label("capabilities_1.6.bzl.com_github_jetbrains_kotlin.bazel"),
Label("capabilities_1.7.bzl.com_github_jetbrains_kotlin.bazel"),
Label("capabilities_1.8.bzl.com_github_jetbrains_kotlin.bazel"),
Label("capabilities_1.9.bzl.com_github_jetbrains_kotlin.bazel"),
Label("capabilities_2.0.bzl.com_github_jetbrains_kotlin.bazel"),
Label("capabilities_2.1.bzl.com_github_jetbrains_kotlin.bazel"),
Label("capabilities_legacy.bzl.com_github_jetbrains_kotlin.bazel")
]
Label("capabilities_1.4.bzl.com_github_jetbrains_kotlin.bazel"),
Label("capabilities_1.5.bzl.com_github_jetbrains_kotlin.bazel"),
Label("capabilities_1.6.bzl.com_github_jetbrains_kotlin.bazel"),
Label("capabilities_1.7.bzl.com_github_jetbrains_kotlin.bazel"),
Label("capabilities_1.8.bzl.com_github_jetbrains_kotlin.bazel"),
Label("capabilities_1.9.bzl.com_github_jetbrains_kotlin.bazel"),
Label("capabilities_2.0.bzl.com_github_jetbrains_kotlin.bazel"),
Label("capabilities_2.1.bzl.com_github_jetbrains_kotlin.bazel"),
Label("capabilities_legacy.bzl.com_github_jetbrains_kotlin.bazel"),
]

0 comments on commit 2282e9e

Please sign in to comment.