summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--WORKSPACE9
-rw-r--r--tools/bazelisk_version.bzl16
2 files changed, 23 insertions, 2 deletions
diff --git a/WORKSPACE b/WORKSPACE
index 101e7cc59b..86e12b607e 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -9,9 +9,14 @@ http_archive(
urls = ["https://github.com/bazelbuild/bazel-skylib/archive/0.8.0.tar.gz"],
)
-load("@bazel_skylib//lib:versions.bzl", "versions")
+# Check Bazel version when invoked by Bazel directly
+load("//tools:bazelisk_version.bzl", "bazelisk_version")
-versions.check(minimum_bazel_version = "0.29.0")
+bazelisk_version(name = "bazelisk_version")
+
+load("@bazelisk_version//:check.bzl", "check_bazel_version")
+
+check_bazel_version()
load("//tools:bazlets.bzl", "load_bazlets")
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)