From 08910f7d773219d298d496126248ab3db67b6af8 Mon Sep 17 00:00:00 2001 From: Dragon-Git <1762578117@qq.com> Date: Sat, 28 Sep 2024 21:23:00 +0800 Subject: [PATCH] [ci] cache verilator --- .github/workflows/python-package.yml | 20 +++++++++++--------- script/install_verilator.sh | 25 +++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 9 deletions(-) create mode 100644 script/install_verilator.sh diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index fe89039..36d4149 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -23,18 +23,20 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Cache verilator + uses: actions/cache@v4 + env: + cache-name: cache-verilator-new + with: + path: /home/runner/work/verilator + key: verilator-v5${{ env.cache-name }} + - name: Install verilator run: | sudo apt-get install -y --no-install-recommends help2man make g++ perl python3 autoconf flex bison libfl2 libfl-dev zlib1g zlib1g-dev - git clone https://github.com/verilator/verilator.git - cd verilator - git reset --hard v5.028 - autoconf - ./configure - make -j $(nproc) - sudo make install - cd .. - rm -rf verilator + export VERILATOR_ROOT="/home/runner/work/verilator" \ + export PATH="$VERILATOR_ROOT/bin:$PATH" \ + sudo bash ./script/install_verilator.sh - name: Install verilator-uvm run: | diff --git a/script/install_verilator.sh b/script/install_verilator.sh new file mode 100644 index 0000000..dc37a03 --- /dev/null +++ b/script/install_verilator.sh @@ -0,0 +1,25 @@ +#! /bin/bash + +# VERILATOR_ROOT="$PWD/verilator" + +# Clone repo only if it doesn't exist +if [ ! -d $VERILATOR_ROOT ]; then + cd $VERILATOR_ROOT/../ + git clone https://github.com/verilator/verilator.git +fi + +cd $VERILATOR_ROOT + +# Returns non-zero if no .o files exist +find -name '*.o' | grep -q . + +# If .o files don't exist, do autoconf and do make +if [ $? -ne 0 ]; then + git checkout v5.028 + autoconf + ./configure --prefix="$VERILATOR_ROOT" + make -j `nproc` + make install +else + echo "Verilator already built, skipping compile/install steps" +fi \ No newline at end of file