From 0c2ed1b14e0ecb579cbc0796d49cb34a99c4a8fa Mon Sep 17 00:00:00 2001 From: Jon Ross-Perkins Date: Tue, 3 Dec 2024 09:52:20 -0800 Subject: [PATCH] Switch from bazeliskrc to bazelversion (#4612) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The only documentation I can find for `.bazelversion` is in https://github.com/bazelbuild/bazelisk/blob/master/README.md. However, `bazel` will error out if it doesn't match the `.bazelversion`. For example: ``` ╚╡/usr/bin/bazel build :all ERROR: The project you're trying to build requires Bazel 7.3.0 (specified in [elided]/carbon-lang/.bazelversion), but it wasn't found in /usr/bin. ``` Switching to this because the `MODULE.bazel` requires tighter version pinning in order to avoid churn, and this should help catch mistakes early. In `MODULE.bazel`, demote mention of the version issue because it should only really occur now when the version is being deliberately changed, so the connection should be more apparent. --- .bazeliskrc | 7 ------- .bazelversion | 1 + MODULE.bazel | 16 ++-------------- docs/project/contribution_tools.md | 2 +- 4 files changed, 4 insertions(+), 22 deletions(-) delete mode 100644 .bazeliskrc create mode 100644 .bazelversion diff --git a/.bazeliskrc b/.bazeliskrc deleted file mode 100644 index acd982a1731bc..0000000000000 --- a/.bazeliskrc +++ /dev/null @@ -1,7 +0,0 @@ -# Part of the Carbon Language project, under the Apache License v2.0 with LLVM -# Exceptions. See /LICENSE for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -# Keep pinned to a recent release, listed at -# https://github.com/bazelbuild/bazel. -USE_BAZEL_VERSION=7.3.0 diff --git a/.bazelversion b/.bazelversion new file mode 100644 index 0000000000000..1502020768a7b --- /dev/null +++ b/.bazelversion @@ -0,0 +1 @@ +7.3.0 diff --git a/MODULE.bazel b/MODULE.bazel index 444c0430ae293..c2f395a0eac79 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -7,24 +7,12 @@ `MODULE.bazel.lock` may change locally when `bazel` is executed. This means one of: -1. `MODULE.bazel` is changing. +1. An input is changing, typically `MODULE.bazel` or `.bazelversion`. - Running `bazel mod deps` provides a canonical update to `MODULE.bazel.lock`; include the changes. - GitHub test actions may also identify platform-specific lockfile updates. -2. The `bazel` version doesn't match the version used to generate the - `MODULE.bazel.lock`. - - Bazel releases can change the lock file contents. - - We use Bazelisk in order to keep everyone using the same version: - https://bazel.build/install/bazelisk - - Developers are encouraged to alias `bazel` to `bazelisk` for - ease-of-use; some setups, like Homebrew, will include that with a - `bazelisk` install. - - Contribution tools documentation includes `bazelisk` setup: - https://github.com/carbon-language/carbon-lang/blob/trunk/docs/project/contribution_tools.md - - Make sure `bazelisk --version` (or `bazel --version`) matches the - version in `.bazeliskrc`. -3. The host platform hasn't yet been added to the lock file. +2. The host platform hasn't yet been added to the lock file. - Platforms tested with GitHub actions are kept up-to-date. Other platforms may fall out of sync due to `bazel` or dependency changes, and should be updated with a PR the same way a platform is added. diff --git a/docs/project/contribution_tools.md b/docs/project/contribution_tools.md index 3c1ee40e169b7..9cf8b562f03a6 100644 --- a/docs/project/contribution_tools.md +++ b/docs/project/contribution_tools.md @@ -169,7 +169,7 @@ These tools are essential for work on Carbon. - Main tools - [Bazel](https://www.bazel.build/) - [Bazelisk](https://docs.bazel.build/versions/master/install-bazelisk.html): - Downloads and runs the [configured Bazel version](/.bazeliskrc). + Downloads and runs the [configured Bazel version](/.bazelversion). - [Clang](https://clang.llvm.org/) and [LLVM](https://llvm.org/) - NOTE: Most LLVM 14+ installs should build Carbon. If you're having issues, see