aboutsummaryrefslogtreecommitdiffstats
path: root/tools/bazelisk_version.bzl
diff options
context:
space:
mode:
Diffstat (limited to 'tools/bazelisk_version.bzl')
-rw-r--r--tools/bazelisk_version.bzl16
1 files changed, 16 insertions, 0 deletions
diff --git a/tools/bazelisk_version.bzl b/tools/bazelisk_version.bzl
new file mode 100644
index 0000000000..d8b3d10982
--- /dev/null
+++ b/tools/bazelisk_version.bzl
@@ -0,0 +1,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)