-
Notifications
You must be signed in to change notification settings - Fork 3
230 lines (203 loc) · 9.07 KB
/
llvm-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
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
name: LLVM Build
run-name: Build LLVM for ${{inputs.INPUT_LLVM_VER}}
on:
workflow_dispatch:
inputs:
INPUT_LLVM_VER:
description: 'LLVM package version'
required: true
type: string
default: ""
INPUT_LLVM_REF:
description: 'LLVM repo tag or ref'
required: true
type: string
default: ""
INPUT_LLVM_ENABLE_PROJECTS:
description: 'LLVM_ENABLE_PROJECTS'
required: false
type: string
default: "clang;lld;clang-tools-extra"
INPUT_LLVM_ENABLE_RUNTIMES:
description: 'LLVM_ENABLE_RUNTIMES'
required: false
type: string
default: ""
INPUT_LLVM_TARGETS_TO_BUILD:
description: 'LLVM_TARGETS_TO_BUILD'
required: false
type: string
default: "all"
INPUT_CMAKE_ADDITIONAL_CONFIG_ARGS:
description: 'Additional CMake configure params'
required: false
type: string
default: ""
jobs:
llvm-build:
name: llvm-${{github.event.inputs.INPUT_LLVM_VER}}-${{matrix.toolchain}}-${{matrix.arch}}-${{matrix.crt}}-${{matrix.cfg}}
runs-on: windows-2022
strategy:
fail-fast: true
matrix:
toolchain:
- msvc17
arch:
- x86
- x64
crt:
- md
- mt
cfg:
- release
- minsizerel
env:
LLVM_VER: ${{github.event.inputs.INPUT_LLVM_VER}}
LLVM_REF: ${{github.event.inputs.INPUT_LLVM_REF}}
LLVM_ENABLE_PROJECTS: ${{github.event.inputs.INPUT_LLVM_ENABLE_PROJECTS}}
LLVM_ENABLE_RUNTIMES: ${{github.event.inputs.INPUT_LLVM_ENABLE_RUNTIMES}}
LLVM_TARGETS_TO_BUILD: ${{github.event.inputs.INPUT_LLVM_TARGETS_TO_BUILD}}
CMAKE_ADDITIONAL_CONFIG_ARGS: ${{github.event.inputs.INPUT_CMAKE_ADDITIONAL_CONFIG_ARGS}}
steps:
- name: Setup Environments
id: setup_env
shell: cmd
run: |
:: Setup Environments
if "x${{matrix.arch}}" neq "xx86" (
if "x${{matrix.arch}}" neq "xx64" (
echo.unknow arch: "${{matrix.arch}}".
exit -2
)
)
if "x${{matrix.crt}}" equ "xmd" set BUILD_CRT=MD
if "x${{matrix.crt}}" equ "xmt" set BUILD_CRT=MT
if "x${{matrix.cfg}}" equ "xdebug" set BUILD_CONFIG=Debug
if "x${{matrix.cfg}}" equ "xrelease" set BUILD_CONFIG=Release
if "x${{matrix.cfg}}" equ "xrelwithdebinfo" set BUILD_CONFIG=RelWithDebInfo
if "x${{matrix.cfg}}" equ "xminsizerel" set BUILD_CONFIG=MinSizeRel
if "%BUILD_CRT%" equ "" (
echo.unknow crt: "${{matrix.crt}}".
exit -3
)
if "%BUILD_CONFIG%" equ "" (
echo.unknow config: "${{matrix.cfg}}".
exit -4
)
set RELEASE_NAME=llvm-${{env.LLVM_VER}}-${{matrix.toolchain}}-${{matrix.arch}}-${{matrix.crt}}-${{matrix.cfg}}
set RELEASE_FILE=C:\%RELEASE_NAME%.7z
set RELEASE_BODY_FILE=${{ github.workspace }}\release.md
set SOURCE_DIR=${{ github.workspace }}\src
set BUILD_DIR=C:\build
set INSTALL_DIR=C:\llvm
set CMAKE_CONFIG_ARGS=-DCMAKE_BUILD_TYPE:STRING=%BUILD_CONFIG%
set CMAKE_CONFIG_ARGS=%CMAKE_CONFIG_ARGS% -DCMAKE_INSTALL_PREFIX:PATH=%INSTALL_DIR%
set CMAKE_CONFIG_ARGS=%CMAKE_CONFIG_ARGS% -DCMAKE_C_FLAGS:STRING="/utf-8"
set CMAKE_CONFIG_ARGS=%CMAKE_CONFIG_ARGS% -DCMAKE_CXX_FLAGS:STRING="/utf-8"
set CMAKE_CONFIG_ARGS=%CMAKE_CONFIG_ARGS% -DLLVM_USE_CRT_DEBUG:STRING=%BUILD_CRT%d
set CMAKE_CONFIG_ARGS=%CMAKE_CONFIG_ARGS% -DLLVM_USE_CRT_RELEASE:STRING=%BUILD_CRT%
set CMAKE_CONFIG_ARGS=%CMAKE_CONFIG_ARGS% -DLLVM_USE_CRT_RELWITHDEBINFO:STRING=%BUILD_CRT%
set CMAKE_CONFIG_ARGS=%CMAKE_CONFIG_ARGS% -DLLVM_USE_CRT_MINSIZEREL:STRING=%BUILD_CRT%
set CMAKE_CONFIG_ARGS=%CMAKE_CONFIG_ARGS% -DLLVM_ENABLE_PROJECTS:STRING="${{env.LLVM_ENABLE_PROJECTS}}"
set CMAKE_CONFIG_ARGS=%CMAKE_CONFIG_ARGS% -DLLVM_ENABLE_RUNTIMES:STRING="${{env.LLVM_ENABLE_RUNTIMES}}"
set CMAKE_CONFIG_ARGS=%CMAKE_CONFIG_ARGS% -DLLVM_TARGETS_TO_BUILD:STRING="${{env.LLVM_TARGETS_TO_BUILD}}"
set CMAKE_CONFIG_ARGS=%CMAKE_CONFIG_ARGS% -DLLVM_OPTIMIZED_TABLEGEN:BOOL=ON
set CMAKE_CONFIG_ARGS=%CMAKE_CONFIG_ARGS% -DLLVM_ENABLE_ASSERTIONS:BOOL=ON
set CMAKE_CONFIG_ARGS=%CMAKE_CONFIG_ARGS% -DLLVM_ENABLE_BINDINGS:BOOL=OFF
set CMAKE_CONFIG_ARGS=%CMAKE_CONFIG_ARGS% -DLLVM_ENABLE_LIBXML2:BOOL=OFF
set CMAKE_CONFIG_ARGS=%CMAKE_CONFIG_ARGS% -DLLVM_ENABLE_ZLIB:BOOL=OFF
set CMAKE_CONFIG_ARGS=%CMAKE_CONFIG_ARGS% -DLLVM_ENABLE_Z3_SOLVER:BOOL=OFF
set CMAKE_CONFIG_ARGS=%CMAKE_CONFIG_ARGS% -DLLVM_BUILD_BENCHMARKS:BOOL=OFF
set CMAKE_CONFIG_ARGS=%CMAKE_CONFIG_ARGS% -DLLVM_BUILD_DOCS:BOOL=OFF
set CMAKE_CONFIG_ARGS=%CMAKE_CONFIG_ARGS% -DLLVM_BUILD_EXAMPLES:BOOL=OFF
set CMAKE_CONFIG_ARGS=%CMAKE_CONFIG_ARGS% -DLLVM_BUILD_TESTS:BOOL=OFF
set CMAKE_CONFIG_ARGS=%CMAKE_CONFIG_ARGS% -DLLVM_INCLUDE_BENCHMARKS:BOOL=OFF
set CMAKE_CONFIG_ARGS=%CMAKE_CONFIG_ARGS% -DLLVM_INCLUDE_EXAMPLES:BOOL=OFF
set CMAKE_CONFIG_ARGS=%CMAKE_CONFIG_ARGS% -DLLVM_INCLUDE_TESTS:BOOL=OFF
set CMAKE_CONFIG_ARGS=%CMAKE_CONFIG_ARGS% -DLLVM_INCLUDE_GO_TESTS:BOOL=OFF
set CMAKE_ADDITIONAL_CONFIG_ARGS=${{env.CMAKE_ADDITIONAL_CONFIG_ARGS}}
if "%CMAKE_ADDITIONAL_CONFIG_ARGS%" neq "" (
set CMAKE_CONFIG_ARGS=%CMAKE_CONFIG_ARGS% %CMAKE_ADDITIONAL_CONFIG_ARGS%
)
if "%BUILD_CRT%" neq "MT" (
set CMAKE_CONFIG_ARGS=%CMAKE_CONFIG_ARGS% -DCMAKE_INSTALL_UCRT_LIBRARIES=ON
)
echo.==================================================
echo.LLVM_VER : %LLVM_VER%
echo.LLVM_REF : %LLVM_REF%
echo.LLVM_ENABLE_PROJECTS : %LLVM_ENABLE_PROJECTS%
echo.LLVM_ENABLE_RUNTIMES : %LLVM_ENABLE_RUNTIMES%
echo.LLVM_TARGETS_TO_BUILD : %LLVM_TARGETS_TO_BUILD%
echo.RELEASE_NAME : %RELEASE_NAME%
echo RELEASE_FILE : %RELEASE_FILE%
echo.CMAKE_CONFIG_ARGS : %CMAKE_CONFIG_ARGS%
echo.==================================================
echo.RELEASE_NAME=%RELEASE_NAME%>>%GITHUB_ENV%
echo.RELEASE_FILE=%RELEASE_FILE%>>%GITHUB_ENV%
echo.RELEASE_BODY_FILE=%RELEASE_BODY_FILE%>>%GITHUB_ENV%
echo.SOURCE_DIR=%SOURCE_DIR%>>%GITHUB_ENV%
echo.BUILD_DIR=%BUILD_DIR%>>%GITHUB_ENV%
echo.INSTALL_DIR=%INSTALL_DIR%>>%GITHUB_ENV%
echo.BUILD_CRT=%BUILD_CRT%>>%GITHUB_ENV%
echo.BUILD_CONFIG=%BUILD_CONFIG%>>%GITHUB_ENV%
echo.CMAKE_CONFIG_ARGS=%CMAKE_CONFIG_ARGS%>>%GITHUB_ENV%
exit 0
- name: Checkout Source
if: ${{ success() }} && ${{ !cancelled() }}
id: checkout_src
uses: actions/checkout@v3
with:
repository: 'llvm/llvm-project'
ref: '${{env.LLVM_REF}}'
path: 'src'
- name: Get LLVM SHA
if: ${{ success() }} && ${{ !cancelled() }}
id: get_llvm_hash
shell: pwsh
run: |
cd ${{env.SOURCE_DIR}}
$commitHash = (git rev-parse HEAD).Substring(0,40)
echo "LLVM_REF_HASH=$commitHash"
echo "LLVM_REF_HASH=$commitHash" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
exit 0
- name: Build
if: ${{ success() }} && ${{ !cancelled() }}
id: build_llvm
shell: cmd
run: |
:: Build LLVM
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" ${{matrix.arch}}
echo ::group::Configure
cmake -G Ninja -S "%SOURCE_DIR%/llvm" -B "%BUILD_DIR%" %CMAKE_CONFIG_ARGS% || exit -6
echo ::endgroup::
echo ::group::Build
cmake --build "%BUILD_DIR%" --config %BUILD_CONFIG% || exit -7
echo ::endgroup::
echo ::group::Install
cmake --build "%BUILD_DIR%" --target install || exit -8
echo ::endgroup::
echo ::group::Package
7z a -t7z -mx9 -md128m "%RELEASE_FILE%" "%INSTALL_DIR%\*"
if not exist %RELEASE_FILE% exit -7
echo ::endgroup::
echo ::group::Generate Release Info
echo.^| Build Option ^| Value ^|>${{env.RELEASE_BODY_FILE}}
echo.^|-^|-^|>>${{env.RELEASE_BODY_FILE}}
echo.^| LLVM_VER ^| %LLVM_VER% ^|>>${{env.RELEASE_BODY_FILE}}
echo.^| LLVM_REF ^| [%LLVM_REF%](https://github.com/llvm/llvm-project/tree/%LLVM_REF_HASH%) ^|>>${{env.RELEASE_BODY_FILE}}
echo.^| LLVM_ENABLE_PROJECTS ^| "%LLVM_ENABLE_PROJECTS%" ^|>>${{env.RELEASE_BODY_FILE}}
echo.^| LLVM_ENABLE_RUNTIMES ^| "%LLVM_ENABLE_RUNTIMES%" ^|>>${{env.RELEASE_BODY_FILE}}
echo.^| LLVM_TARGETS_TO_BUILD ^| "%LLVM_TARGETS_TO_BUILD%" ^|>>${{env.RELEASE_BODY_FILE}}
type ${{env.RELEASE_BODY_FILE}}
echo ::endgroup::
exit 0
- name: Release
if: ${{ success() }} && ${{ !cancelled() }}
id: update_release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
tag_name: llvm-${{env.LLVM_VER}}
body_path: ${{env.RELEASE_BODY_FILE}}
files: ${{env.RELEASE_FILE}}