128 lines
4.3 KiB
YAML
128 lines
4.3 KiB
YAML
---
|
|
# DESCRIPTION: Github actions config
|
|
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
|
|
|
name: reusable-build
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
cc:
|
|
description: "Compiler to use: 'gcc' or 'clang'"
|
|
required: true
|
|
type: string
|
|
ccwarn:
|
|
description: "Build Verilator with warnings treated as errors (--enable-ccwarn)"
|
|
required: false
|
|
default: true
|
|
type: boolean
|
|
dev-asan:
|
|
description: "Build Verilator with the address sanitizer (--enable-dev-asan)"
|
|
required: false
|
|
default: false
|
|
type: boolean
|
|
dev-gcov:
|
|
description: "Build Verilator with gcov instrumentation (--enable-dev-gcov)"
|
|
required: false
|
|
default: false
|
|
type: boolean
|
|
install:
|
|
description: "Archive the Verilator installation, not the repo tree"
|
|
required: false
|
|
default: false
|
|
type: boolean
|
|
runs-on:
|
|
description: "Runner to build on, e.g. ubuntu-24.04"
|
|
required: true
|
|
type: string
|
|
sha:
|
|
description: "Commit SHA to build"
|
|
required: true
|
|
type: string
|
|
outputs:
|
|
archive:
|
|
description: "Name of the built archive artifact"
|
|
value: ${{ jobs.build.outputs.archive }}
|
|
|
|
env:
|
|
CACHE_BASE_KEY: build-${{ inputs.runs-on }}-${{ inputs.cc }}${{ inputs.ccwarn && '-ccwarn' || '' }}${{ inputs.dev-asan && '-asan' || '' }}${{ inputs.dev-gcov && '-gcov' || '' }}
|
|
CCACHE_COMPILERCHECK: content
|
|
CCACHE_DIR: ${{ github.workspace }}/.ccache
|
|
|
|
defaults:
|
|
run:
|
|
shell: bash
|
|
working-directory: repo
|
|
|
|
jobs:
|
|
|
|
build:
|
|
name: Build
|
|
runs-on: ${{ inputs.runs-on }}
|
|
outputs:
|
|
archive: ${{ steps.create-archive.outputs.archive }}
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
|
|
with:
|
|
path: repo
|
|
ref: ${{ inputs.sha }}
|
|
# Coverage needs full history; install needs it for the 'git describe'
|
|
# behind 'verilator --version'
|
|
fetch-depth: ${{ (inputs.install || inputs.dev-gcov) && '0' || '1' }}
|
|
|
|
# ccache is unreliable on the macOS runners; disable it there
|
|
- name: Disable ccache on macOS
|
|
if: ${{ startsWith(inputs.runs-on, 'macos') }}
|
|
run: echo "CCACHE_DISABLE=1" >> "$GITHUB_ENV"
|
|
|
|
- name: Cache $CCACHE_DIR
|
|
if: ${{ env.CCACHE_DISABLE != '1' }}
|
|
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v5
|
|
env:
|
|
CACHE_KEY: ${{ env.CACHE_BASE_KEY }}-ccache
|
|
with:
|
|
path: ${{ env.CCACHE_DIR }}
|
|
key: ${{ env.CACHE_KEY }}-${{ inputs.sha }}
|
|
restore-keys: |
|
|
${{ env.CACHE_KEY }}
|
|
|
|
- name: Install packages for build
|
|
run: ./ci/ci-install.bash build
|
|
|
|
- name: Build
|
|
run: |
|
|
./ci/ci-build.bash \
|
|
--prefix ${{ github.workspace }}/install \
|
|
--compiler ${{ inputs.cc }} \
|
|
${{ inputs.ccwarn && '--ccwarn' || '' }} \
|
|
${{ inputs.dev-asan && '--asan' || '' }} \
|
|
${{ inputs.dev-gcov && '--gcov' || '' }}
|
|
|
|
- name: Install
|
|
if: ${{ inputs.install }}
|
|
run: make install
|
|
|
|
- name: Create archive
|
|
id: create-archive
|
|
working-directory: ${{ github.workspace }}
|
|
run: |
|
|
# Archive name, unique per build; flavour tags mark non-default builds
|
|
ARCHIVE="verilator-${{ inputs.sha }}-${{ inputs.runs-on }}-${{ inputs.cc }}"
|
|
ARCHIVE="$ARCHIVE${{ inputs.ccwarn && '-ccwarn' || '' }}"
|
|
ARCHIVE="$ARCHIVE${{ inputs.dev-asan && '-asan' || '' }}"
|
|
ARCHIVE="$ARCHIVE${{ inputs.dev-gcov && '-gcov' || '' }}"
|
|
ARCHIVE="$ARCHIVE.tar.zst"
|
|
# zstd compresses faster than gzip and decompresses far faster in the many downstream jobs
|
|
ZSTD_NBTHREADS=0 tar --posix --zstd -c -f "$ARCHIVE" ${{ inputs.install && 'install' || 'repo' }}
|
|
echo "archive=$ARCHIVE" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Upload archive
|
|
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
|
|
with:
|
|
path: ${{ github.workspace }}/${{ steps.create-archive.outputs.archive }}
|
|
name: ${{ steps.create-archive.outputs.archive }}
|
|
overwrite: true
|
|
# Archive is already zstd-compressed; skip upload-artifact's zip pass
|
|
compression-level: 0
|