xref: /JGit/tools/bazelisk_version.bzl (revision 5caa951515068409f913d62ff6712c8d0f3b72c4)
1*5caa9515SDavid Ostrovsky_template = """
2*5caa9515SDavid Ostrovskyload("@bazel_skylib//lib:versions.bzl", "versions")
3*5caa9515SDavid Ostrovsky
4*5caa9515SDavid Ostrovskydef check_bazel_version():
5*5caa9515SDavid Ostrovsky  versions.check(minimum_bazel_version = "{version}")
6*5caa9515SDavid Ostrovsky""".strip()
7*5caa9515SDavid Ostrovsky
8*5caa9515SDavid Ostrovskydef _impl(repository_ctx):
9*5caa9515SDavid Ostrovsky    repository_ctx.symlink(Label("@//:.bazelversion"), ".bazelversion")
10*5caa9515SDavid Ostrovsky    bazelversion = repository_ctx.read(".bazelversion").strip()
11*5caa9515SDavid Ostrovsky
12*5caa9515SDavid Ostrovsky    repository_ctx.file("BUILD", executable = False)
13*5caa9515SDavid Ostrovsky
14*5caa9515SDavid Ostrovsky    repository_ctx.file("check.bzl", executable = False, content = _template.format(version = bazelversion))
15*5caa9515SDavid Ostrovsky
16*5caa9515SDavid Ostrovskybazelisk_version = repository_rule(implementation = _impl)
17