diff --git a/.bazelrc b/.bazelrc index ec57c239c4ef2..5587cc87beb7c 100644 --- a/.bazelrc +++ b/.bazelrc @@ -2,8 +2,9 @@ # Licensed under the Apache License, Version 2.0, see LICENSE for details. # SPDX-License-Identifier: Apache-2.0 -# Enable bzlmod using both `MODULE.bazel` and `WORKSPACE.bzlmod`. +# Enable bzlmod with `MODULE.bazel` and disable the `WORKSPACE` system. common --enable_bzlmod +common --enable_workspace=no # https://docs.opentitan.org/doc/rm/c_cpp_coding_style/#cxx-version specifies build --action_env=BAZEL_CXXOPTS="-std=gnu++14" diff --git a/BUILD.bazel b/BUILD.bazel index 36c85f77b16c1..010504ddd88d8 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -5,7 +5,7 @@ package(default_visibility = ["//visibility:public"]) exports_files([ - "WORKSPACE.bzlmod", + "MODULE.bazel", "python-requirements.txt", "tool_requirements.py", ]) diff --git a/WORKSPACE.bzlmod b/WORKSPACE.bzlmod deleted file mode 100644 index a670850ba99e8..0000000000000 --- a/WORKSPACE.bzlmod +++ /dev/null @@ -1,8 +0,0 @@ -# Copyright lowRISC contributors (OpenTitan project). -# Licensed under the Apache License, Version 2.0, see LICENSE for details. -# SPDX-License-Identifier: Apache-2.0 - -# If you're planning to add to this file, please read -# //third_party/README.md first. - -workspace(name = "lowrisc_opentitan") diff --git a/quality/BUILD.bazel b/quality/BUILD.bazel index 1814b2e7f715b..97466decd6300 100644 --- a/quality/BUILD.bazel +++ b/quality/BUILD.bazel @@ -79,7 +79,7 @@ licence_test( Licensed under the Apache License, Version 2.0, see LICENSE for details. SPDX-License-Identifier: Apache-2.0 """, - workspace = "//:WORKSPACE.bzlmod", + workspace = "//:MODULE.bazel", ) format_exclude = [ @@ -99,7 +99,7 @@ clang_format_test( name = "clang_format_check", exclude_patterns = format_exclude, mode = "diff", - workspace = "//:WORKSPACE.bzlmod", + workspace = "//:MODULE.bazel", ) clang_format_check( @@ -141,7 +141,6 @@ test_suite( ) buildifier_exclude = [ - "./WORKSPACE.bzlmod", # Prevent Buildifier from inserting unnecessary newlines. "./**/vendor/**", "./build/**", "./third_party/rust/crates/crates.bzl", # Autogenerated by cargo-raze @@ -159,7 +158,7 @@ buildifier_test( mode = "diff", no_sandbox = True, verbose = True, - workspace = "//:WORKSPACE.bzlmod", + workspace = "//:MODULE.bazel", ) # TODO(cfrantz): Find a way to keep this list of rust targets synchronized @@ -196,7 +195,7 @@ RUST_TARGETS = [ rustfmt_test( name = "rustfmt_check", exclude_patterns = format_exclude, - workspace = "//:WORKSPACE.bzlmod", + workspace = "//:MODULE.bazel", ) rustfmt_fix( @@ -212,7 +211,7 @@ sh_test( name = "shellcheck_check", srcs = ["//util/sh/scripts:run-shellcheck.sh"], data = [ - "//:WORKSPACE.bzlmod", + "//:MODULE.bazel", "@shellcheck", ], env = { diff --git a/rules/bitstreams.bzl b/rules/bitstreams.bzl index 3f94dafacf6aa..0190f3d534e7d 100644 --- a/rules/bitstreams.bzl +++ b/rules/bitstreams.bzl @@ -69,7 +69,7 @@ def _bitstreams_repo_impl(rctx): if result.return_code != 0: fail("Bitstream cache not initialized properly.") -# The bitstream repo should be evaluated with `bazel sync --configure` after +# The bitstream repo should be evaluated with `bazel fetch --configure` after # every Git checkout. Once the cache is initialized, a typical invocation will # find the latest cached artifacts and map them to Bazel targets. # @@ -123,7 +123,7 @@ bitstreams_repo = repository_rule( # This rule depends on the Git repository, but there's no ergonomic way to # encode the dependency in Bazel. Instead, indicate that the rule depends on # something outside of Bazel's dependency graph and rely on the user calling - # `bazel sync --configure` when checking out new revisions. For historical + # `bazel fetch --configure` when checking out new revisions. For historical # context, see . configure = True, ) diff --git a/rules/scripts/clang_format.template.sh b/rules/scripts/clang_format.template.sh index d3738f91b77e2..5b6a4265197fa 100644 --- a/rules/scripts/clang_format.template.sh +++ b/rules/scripts/clang_format.template.sh @@ -16,7 +16,7 @@ elif [[ ! -z "${BUILD_WORKSPACE_DIRECTORY+is_set}" ]]; then cd ${BUILD_WORKSPACE_DIRECTORY} || exit 1 else echo "Neither WORKSPACE nor BUILD_WORKSPACE_DIRECTORY were set." - echo "If this is a test rule, add 'workspace = \"//:WORKSPACE.bzlmod\"' to your rule." + echo "If this is a test rule, add 'workspace = \"//:MODULE.bazel\"' to your rule." exit 1 fi diff --git a/rules/scripts/rustfmt.template.sh b/rules/scripts/rustfmt.template.sh index d34994761d0d1..06590c8938889 100644 --- a/rules/scripts/rustfmt.template.sh +++ b/rules/scripts/rustfmt.template.sh @@ -16,7 +16,7 @@ elif [[ -n "${BUILD_WORKSPACE_DIRECTORY+is_set}" ]]; then cd "${BUILD_WORKSPACE_DIRECTORY}" || exit 1 else echo "Neither WORKSPACE nor BUILD_WORKSPACE_DIRECTORY were set." - echo "If this is a test rule, add 'workspace = \"//:WORKSPACE.bzlmod\"' to your rule." + echo "If this is a test rule, add 'workspace = \"//:MODULE.bazel\"' to your rule." exit 1 fi diff --git a/util/git/hooks/post-checkout b/util/git/hooks/post-checkout index 5e0ee249802f9..797ae315929c1 100755 --- a/util/git/hooks/post-checkout +++ b/util/git/hooks/post-checkout @@ -3,4 +3,4 @@ # Licensed under the Apache License, Version 2.0, see LICENSE for details. # SPDX-License-Identifier: Apache-2.0 -exec ./bazelisk.sh sync --configure +exec ./bazelisk.sh fetch --configure diff --git a/util/prep-bazel-airgapped-build.sh b/util/prep-bazel-airgapped-build.sh index a93905e9a225c..259f435abb53f 100755 --- a/util/prep-bazel-airgapped-build.sh +++ b/util/prep-bazel-airgapped-build.sh @@ -115,14 +115,13 @@ if [[ ${AIRGAPPED_DIR_CONTENTS} == "ALL" || \ --output bazel chmod +x bazel - # Make Bazel sync its own dependencies to the repository cache: + # Make Bazel fetch its own dependencies to the repository cache: # https://bazel.build/run/build#repository_cache_with_bazel_7_or_later mkdir -p "${BAZEL_AIRGAPPED_DIR}/empty_workspace" pushd "${BAZEL_AIRGAPPED_DIR}/empty_workspace" touch MODULE.bazel - touch WORKSPACE cp "${REPO_TOP}/.bazelversion" . - bazel sync --repository_cache="${BAZEL_AIRGAPPED_DIR}/${BAZEL_CACHEDIR}" + bazel fetch --repository_cache="${BAZEL_AIRGAPPED_DIR}/${BAZEL_CACHEDIR}" popd rm -rf "${BAZEL_AIRGAPPED_DIR}/empty_workspace" fi diff --git a/util/sh/scripts/run-shellcheck.sh b/util/sh/scripts/run-shellcheck.sh index 38af8127484e2..672048b943eb4 100755 --- a/util/sh/scripts/run-shellcheck.sh +++ b/util/sh/scripts/run-shellcheck.sh @@ -6,12 +6,12 @@ set -e # Escape the sandbox when running under `bazel test`. This script assumes that -# when it's invoked by Bazel, the Bazel target will depend on `//:WORKSPACE.bzlmod`. +# when it's invoked by Bazel, the Bazel target will depend on `//:MODULE.bazel`. # This assumption enables us to infer that we're running in the sandbox when we -# see a symlink named "WORKSPACE.bzlmod". -if [[ -L WORKSPACE.bzlmod ]]; then +# see a symlink named "MODULE.bazel". +if [[ -L MODULE.bazel ]]; then SHELLCHECK="$(realpath "${SHELLCHECK}")" - REPO_TOP="$(dirname "$(realpath WORKSPACE.bzlmod)")" + REPO_TOP="$(dirname "$(realpath MODULE.bazel)")" cd "${REPO_TOP}" else REPO_TOP="$(git rev-parse --show-toplevel)"