-
Notifications
You must be signed in to change notification settings - Fork 305
286 lines (277 loc) · 9.52 KB
/
unifiedBuildTestAndInstall.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
name: Build, Test, and Install
on:
workflow_dispatch:
inputs:
runner:
description: "The GitHub runner to use"
required: true
type: choice
options:
- ubuntu-22.04
- ubuntu-20.04
- macos-13
- macos-12
- macos-11
- windows-2022
- windows-2019
cmake_build_type:
required: true
type: choice
options:
- release
- relwithdebinfo
- debug
default: relwithdebinfo
build_shared_libs:
required: true
type: choice
options:
- on
- off
default: off
llvm_enable_assertions:
required: true
type: choice
options:
- on
- off
llvm_force_enable_stats:
required: true
type: choice
options:
- on
- off
runTests:
description: "Run tests"
required: true
type: boolean
default: false
install:
description: "Install steps to run (empty if do not install)"
required: false
type: string
package_name_prefix:
description: "The prefix for package name (has no effect unless \"install\" is set)"
required: false
type: string
cmake_c_compiler:
description: "The C compiler to use"
required: true
type: choice
options:
- clang
- clang-10
- clang-11
- clang-12
- clang-13
- clang-14
- clang-15
- clang-16
- clang-17
- gcc
- cl
default: clang
cmake_cxx_compiler:
description: "The C++ compiler to use"
required: true
type: choice
options:
- clang++
- clang++-10
- clang++-11
- clang++-12
- clang++-13
- clang++-14
- clang++-15
- clang++-16
- clang++-17
- gcc++
- cl
default: clang++
workflow_call:
inputs:
runner:
description: "The GitHub runner to use"
required: true
type: string
cmake_build_type:
required: true
type: string
build_shared_libs:
required: true
type: string
llvm_enable_assertions:
required: true
type: string
llvm_force_enable_stats:
required: true
type: string
runTests:
description: "If true, then run tests, otherwise skip tests"
required: true
type: boolean
install:
description: "Install steps to run"
required: false
type: string
package_name_prefix:
description: "The prefix for package name"
required: false
type: string
cmake_c_compiler:
description: "The C compiler to use"
required: false
type: string
default: clang
cmake_cxx_compiler:
description: "The C++ compiler to use"
required: false
type: string
default: clang++
jobs:
build-test-and-install:
runs-on: ${{ inputs.runner }}
permissions:
contents: write # Upload assets to release.
steps:
- name: Clone llvm/circt
uses: actions/checkout@v3
with:
fetch-depth: 2
submodules: "true"
- name: Unshallow llvm/circt
run: |
git fetch --unshallow --no-recurse-submodules
# Per-operating system setup
- name: Setup (linux)
if: runner.os == 'Linux'
run: |
sudo apt-get install ninja-build
- name: Setup (macos)
if: runner.os == 'macOS'
run: |
brew install ninja gnu-tar
- name: Setup (windows)
id: setup-windows
if: runner.os == 'Windows'
shell: bash
run: |
echo setup=./utils/find-vs.ps1 >> "$GITHUB_OUTPUT"
# Setup Caching
#
# Use sccache as it works on Windows. Disable caching for non-release Windows
# builds due to a bug between cmake and sccache. See:
# - https://gitlab.kitware.com/cmake/cmake/-/issues/22529
- name: sccache
if: runner.os != 'Windows' || inputs.cmake_build_type == 'release'
uses: hendrikmuhs/[email protected]
with:
key: ${{ inputs.runner }}-${{ inputs.cmake_c_compiler }}-${{ inputs.cmake_cxx_compiler }}-${{ inputs.cmake_build_type }}-${{ inputs.build_shared_libs }}-${{ inputs.llvm_enable_assertions }}-${{ inputs.llvm_force_enable_stats}}
max-size: 500M
variant: sccache
- name: Configure sccache
id: configure-sccache
if: runner.os != 'Windows' || inputs.cmake_build_type == 'release'
shell: bash
run:
echo enable_sccache="-DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache" >> $GITHUB_OUTPUT
# Configure
- name: Configure CIRCT
run: |
${{ steps.setup-windows.outputs.setup }}
mkdir build
cd build
cmake -G Ninja -S "$(pwd)/../llvm/llvm" $EXTRA_CMAKE_ARGS -DCMAKE_BUILD_TYPE=${{ inputs.cmake_build_type }} -DBUILD_SHARED_LIBS=${{ inputs.build_shared_libs }} -DLLVM_BUILD_TOOLS=ON -DLLVM_BUILD_EXAMPLES=OFF -DLLVM_ENABLE_ASSERTIONS=${{ inputs.llvm_enable_assertions }} -DLLVM_ENABLE_PROJECTS=mlir -DLLVM_EXTERNAL_PROJECTS=circt -DLLVM_EXTERNAL_CIRCT_SOURCE_DIR=".." -DLLVM_STATIC_LINK_CXX_STDLIB=ON -DLLVM_PARALLEL_LINK_JOBS=1 -DLLVM_TARGETS_TO_BUILD="host" -DLLVM_FORCE_ENABLE_STATS=${{ inputs.llvm_force_enable_stats }} -DLLVM_ENABLE_ZSTD=OFF -DVERILATOR_DISABLE=ON -DCIRCT_RELEASE_TAG_ENABLED=ON -DCIRCT_RELEASE_TAG=firtool -DCMAKE_EXPORT_COMPILE_COMMANDS=OFF -DCMAKE_C_COMPILER=${{ inputs.cmake_c_compiler }} -DCMAKE_CXX_COMPILER=${{ inputs.cmake_cxx_compiler }} ${{ steps.configure-sccache.outputs.enable_sccache }} -DCMAKE_INSTALL_PREFIX="$(pwd)/../install" -DLLVM_INSTALL_UTILS=ON
# Optionally test
- name: Test CIRCT
if: inputs.runTests
run: |
${{ steps.setup-windows.outputs.setup }}
ninja -C build check-circt check-circt-unit
- name: Install
if: inputs.install
run: |
${{ steps.setup-windows.outputs.setup }}
ninja -C build ${{ inputs.install }}
file install/*
file install/bin/*
- name: Name Install Directory
id: name_dir
if: inputs.install
shell: bash
run: |
BASE=$(git describe --tag)
SANITIZED=$(echo -n $BASE | tr '/' '-')
echo "value=$SANITIZED" >> "$GITHUB_OUTPUT"
ARCH=$(echo ${{ runner.arch }} | tr '[:upper:]' '[:lower:]')
echo arch="$ARCH" >> $GITHUB_OUTPUT
OS=$(echo ${{ runner.os }} | tr '[:upper:]' '[:lower:]')
echo os="$OS" >> $GITHUB_OUTPUT
ARCHIVE=
if [[ ${{ runner.os }} == 'Windows' ]]; then
ARCHIVE="zip"
else
ARCHIVE="tar.gz"
fi
echo archive="$ARCHIVE" >> $GITHUB_OUTPUT
TAR=
if [[ ${{ runner.os }} == 'macOS' ]]; then
TAR="gtar czf"
else
TAR="tar czf"
fi
echo tar="$TAR" >> $GITHUB_OUTPUT
SHA256=
if [[ ${{ runner.os }} == 'Windows' ]]; then
SHA256="sha256sum"
else
SHA256="shasum -a 256"
fi
echo sha256="$SHA256" >> $GITHUB_OUTPUT
- name: Name Archive
id: name_archive
if: inputs.install
shell: bash
run: |
NAME=${{ inputs.package_name_prefix }}-${{ steps.name_dir.outputs.os }}-${{ steps.name_dir.outputs.arch }}.${{ steps.name_dir.outputs.archive }}
echo "name=$NAME" >> "$GITHUB_OUTPUT"
- name: Package Binaries Linux and MacOS
if: inputs.install && ( runner.os == 'macOS' || runner.os == 'Linux' )
run: |
mv install ${{ steps.name_dir.outputs.value }}
${{ steps.name_dir.outputs.tar }} ${{ steps.name_archive.outputs.name }} ${{ steps.name_dir.outputs.value }}
- name: Package Binaries Windows
if: inputs.install && runner.os == 'Windows'
shell: pwsh
run: |
mv install ${{ steps.name_dir.outputs.value }}
Compress-Archive -Path ${{ steps.name_dir.outputs.value }} -DestinationPath ${{ steps.name_archive.outputs.name }}
- name: Show Tarball
if: inputs.install
shell: bash
run: |
ls -l ${{ steps.name_archive.outputs.name }}
${{ steps.name_dir.outputs.sha256 }} ${{ steps.name_archive.outputs.name }} | cut -d ' ' -f1 > ${{ steps.name_archive.outputs.name }}.sha256
# Upload build artifacts
- name: Upload Binary (Non-Tag)
uses: actions/upload-artifact@v3
if: inputs.install && github.ref_type != 'tag'
with:
name: ${{ steps.name_archive.outputs.name }}
path: ${{ steps.name_archive.outputs.name }}
retention-days: 7
- name: Upload SHA256 (Non-Tag)
uses: actions/upload-artifact@v3
if: inputs.install && github.ref_type != 'tag'
with:
name: ${{ steps.name_archive.outputs.name }}.sha256
path: ${{ steps.name_archive.outputs.name }}.sha256
retention-days: 7
- name: Upload Binaries (Tag)
uses: AButler/[email protected]
if: inputs.install && github.ref_type == 'tag'
with:
# The * will grab the .sha256 as well
files: ${{ steps.name_archive.outputs.name }}*
repo-token: ${{ secrets.GITHUB_TOKEN }}
release-tag: ${{ github.ref_name }} # Upload to release tag when manually run.