ソースを参照

Bazel: Reuse version from .bazelversion for minimum used version check

Bazel is still supported in addition to the Bazel wrapper Bazelisk,
that is recommended, as it would automatically switch to the right
Bazel version on stable branches (like it was the case with Buck).

That why minimum used Bazel version check is still needed in WORKSPACE
file in addition to the .bazelversion used by Bazelisk. That means that
currently, bazel version is maintained in two places:

* .bazelversion
* WORKSPACE

This change introduces the repository rule to read the bazel version
from the .bazelversion file and perform the minimum version check.

Change-Id: Ib9c1382935ded7bcd322ed0122838c40ba2faa6c
Signed-off-by: David Ostrovsky <david@ostrovsky.org>
tags/v5.6.0.201911271000-m3
David Ostrovsky 4年前
コミット
5caa951515
2個のファイルの変更23行の追加2行の削除
  1. 7
    2
      WORKSPACE
  2. 16
    0
      tools/bazelisk_version.bzl

+ 7
- 2
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")


+ 16
- 0
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)

読み込み中…
キャンセル
保存