Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bazel] Disable hybrid mode #25847

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
package(default_visibility = ["//visibility:public"])

exports_files([
"WORKSPACE.bzlmod",
"MODULE.bazel",
"python-requirements.txt",
"tool_requirements.py",
])
Expand Down
8 changes: 0 additions & 8 deletions WORKSPACE.bzlmod

This file was deleted.

11 changes: 5 additions & 6 deletions quality/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand All @@ -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(
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -196,7 +195,7 @@ RUST_TARGETS = [
rustfmt_test(
name = "rustfmt_check",
exclude_patterns = format_exclude,
workspace = "//:WORKSPACE.bzlmod",
workspace = "//:MODULE.bazel",
)

rustfmt_fix(
Expand All @@ -212,7 +211,7 @@ sh_test(
name = "shellcheck_check",
srcs = ["//util/sh/scripts:run-shellcheck.sh"],
data = [
"//:WORKSPACE.bzlmod",
"//:MODULE.bazel",
"@shellcheck",
],
env = {
Expand Down
4 changes: 2 additions & 2 deletions rules/bitstreams.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#
Expand Down Expand Up @@ -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 <https://github.com/lowRISC/opentitan/issues/16832>.
configure = True,
)
Expand Down
2 changes: 1 addition & 1 deletion rules/scripts/clang_format.template.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion rules/scripts/rustfmt.template.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion util/git/hooks/post-checkout
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 2 additions & 3 deletions util/prep-bazel-airgapped-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions util/sh/scripts/run-shellcheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down
Loading