Skip to content

Commit

Permalink
Run bant as build-cleaner from our bazel_dep()
Browse files Browse the repository at this point in the history
  • Loading branch information
hzeller committed Jan 7, 2025
1 parent 5842417 commit 67459ad
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 37 deletions.
4 changes: 2 additions & 2 deletions .github/bin/make-compilation-db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ set -e
BAZEL=${BAZEL:-bazel}
BANT=${BANT:-needs-to-be-compiled-locally}

BAZEL_OPTS="-c opt --noshow_progress"
if [ "${BANT}" = "needs-to-be-compiled-locally" ]; then
# Bant not given, compile from bzlmod dep. We need to do that before
# we run other bazel rules below as we change the cxxopt flags. Remember
# the full realpath of the resulting binary to be immune to symbolic-link
# switcharoo by bazel.
${BAZEL} build ${BAZEL_OPTS} --cxxopt=-std=c++20 @bant//bant:bant
${BAZEL} build -c opt --cxxopt=-std=c++20 @bant//bant:bant >/dev/null 2>&1
BANT=$(realpath bazel-bin/external/bant*/bant/bant)
fi

BAZEL_OPTS="-c opt --noshow_progress"
# Bazel-build all targets that generate files, so that they can be
# seen in dependency analysis.
${BAZEL} build ${BAZEL_OPTS} $(${BANT} list-targets | \
Expand Down
37 changes: 37 additions & 0 deletions .github/bin/run-build-cleaner.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env bash
# Copyright 2024 The Verible Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -u
set -e

# Which bazel and bant to use can be chosen by environment variables
BAZEL=${BAZEL:-bazel}
BANT=${BANT:-needs-to-be-compiled-locally}

if [ "${BANT}" = "needs-to-be-compiled-locally" ]; then
# Bant not given, compile from bzlmod dep.
${BAZEL} build -c opt --cxxopt=-std=c++20 @bant//bant:bant >/dev/null 2>&1
BANT=$(realpath bazel-bin/external/bant*/bant/bant)
fi

DWYU_OUT="${TMPDIR:-/tmp}/dwyu.out"

if "${BANT}" -q dwyu ... ; then
echo "Dependencies ok"
else
echo
echo "^ Please run buildozer commands to fix the dependencies and amend PR"
exit 1
fi
37 changes: 2 additions & 35 deletions .github/workflows/verible-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ env:
jobs:


VerifyFormatting:
CheckFormattingAndBuildfileClean:
runs-on: ubuntu-24.04
steps:

Expand All @@ -42,6 +42,7 @@ jobs:
- name: Run formatting style check
run: |
CLANG_FORMAT=clang-format-17 ./.github/bin/run-format.sh
./.github/bin/run-build-cleaner.sh
./.github/bin/check-potential-problems.sh
- name: 📤 Upload performance graphs
Expand Down Expand Up @@ -117,40 +118,6 @@ jobs:
name: "diag"
path: "**/plot_*.svg"

RunBantBuildCleaner:
# Running http://bant.build/ to check all dependencies in BUILD files.
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Get Bant
run: |
# TODO: provide this as action where we simply say with version=...
VERSION="v0.1.9"
STATIC_VERSION="bant-${VERSION}-linux-static-x86_64"
wget "https://github.com/hzeller/bant/releases/download/${VERSION}/${STATIC_VERSION}.tar.gz"
tar xvzf "${STATIC_VERSION}.tar.gz"
mkdir -p bin
ln -sf ../"${STATIC_VERSION}/bin/bant" bin/
bin/bant -V
- name: Build Project genrules
run: |
# Fetch all dependencies and run genrules for bant to see every file
# that makes it into the compile. Use bant itself to find genrules.
bazel build $(bin/bant -q genrule-outputs | awk '{print $2}') \
//verible/common/analysis:command-file-lexer \
//verible/verilog/parser:verilog-lex \
//verible/verilog/parser:verilog-y \
//verible/verilog/parser:verilog-y-final
- name: Run bant build-cleaner
run: |
bin/bant dwyu ...
Check:
container: ubuntu:jammy
runs-on: [self-hosted, Linux, X64, gcp-custom-runners]
Expand Down

0 comments on commit 67459ad

Please sign in to comment.