-
Notifications
You must be signed in to change notification settings - Fork 1
87 lines (87 loc) · 2.91 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# SPDX-FileCopyrightText: 2024 Roman Gilg <[email protected]>
# SPDX-License-Identifier: MIT
name: Build
on:
workflow_call:
inputs:
image:
description: Image to build
required: true
type: string
artifact-name:
description: Artifact name of build dir
required: false
type: string
default: 'build'
is-sanitized:
description: Should sanitizers be compiled into the build
required: false
type: boolean
default: false
ninja:
description: Should Ninja be used as generator
required: false
type: boolean
default: true
cmake-args:
description: Specify CMake arguments manually
required: false
type: string
default: ''
jobs:
set-cmake-args:
name: CMake Args
runs-on: ubuntu-latest
env:
cmake-args: ''
outputs:
args: ${{ steps.set-output.outputs.result }}
steps:
- name: Set from manually specified CMake args
if: ${{ inputs.cmake-args != '' }}
run: echo \"cmake-args=${{ inputs.cmake-args }}\" >> $GITHUB_ENV;
- name: Set default CMake args for sanitized build
if: ${{ inputs.cmake-args == '' && inputs.is-sanitized }}
run: echo "cmake-args=-DECM_ENABLE_SANITIZERS='address;leak;undefined'" >> $GITHUB_ENV"
- name: Set default CMake args for coverage build
if: ${{ inputs.cmake-args == '' && !inputs.is-sanitized }}
run:
"echo \"cmake-args=-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_CXX_FLAGS=--coverage -DCMAKE_EXE_LINKER_FLAGS=--coverage\" >> $GITHUB_ENV"
- name: Set clang as compiler
if: ${{ inputs.cmake-args == '' }}
run:
"echo \"cmake-args=-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \
${{ env.cmake-args }}\" >> $GITHUB_ENV"
- name: Set generator
if: ${{ inputs.cmake-args == '' && inputs.ninja }}
run: echo "cmake-args=-G Ninja ${{ env.cmake-args }}" >> $GITHUB_ENV
- id: set-output
name: Set resulting variable
run: echo "result=${{ env.cmake-args }}" >> "$GITHUB_OUTPUT"
build:
name: Build
needs: set-cmake-args
runs-on: ubuntu-latest
container:
image: ${{ inputs.image }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Install Dependencies
uses: ./.github/actions/dep-artifacts
with:
secret: ${{ secrets.GITHUB_TOKEN }}
- run: mkdir build
- name: Configure
run: cmake -S . -B build ${{ needs.set-cmake-args.outputs.args }}
- name: Build
run: cmake --build build
- name: Tar artifact (keep permissions)
run: tar -czf build-dir.tar build
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.artifact-name }}
path: build-dir.tar
retention-days: 1