summaryrefslogtreecommitdiffstats
path: root/tools/bazelisk_version.bzl
blob: d8b3d10982e9aacbd3b3465723b10e8a2155c19a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
_template = """
load("@bazel_skylib//lib:versions.bzl", "versions")

def check_bazel_version():
  versions.check(minimum_bazel_version = "{version}")
""".strip()

def _impl(repository_ctx):
    repository_ctx.symlink(Label("@//:.bazelversion"), ".bazelversion")
    bazelversion = repository_ctx.read(".bazelversion").strip()

    repository_ctx.file("BUILD", executable = False)

    repository_ctx.file("check.bzl", executable = False, content = _template.format(version = bazelversion))

bazelisk_version = repository_rule(implementation = _impl)