Repository navigation
378 lines (331 loc) · 15.2 KB
/
Copy pathbuild.yml
File metadata and controls
378 lines (331 loc) · 15.2 KB
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
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
name: CI
on: [push]
jobs:
build:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
env:
VCPKG_GIT_HASH: 5d7ff36ae562a9d2af61ec64d163985c38adcf17
VCPKG_DEPS: fmt lmdb nlohmann-json catch2 range-v3 clara reproc abseil
strategy:
fail-fast: false
matrix:
name: [
windows,
linux,
macos,
]
include:
- name: windows
os: windows-latest
exe-suffix: .exe
- name: linux
os: ubuntu-18.04
exe-suffix:
- name: macos
os: macOS-latest
exe-suffix:
steps:
- uses: actions/checkout@v1
- name: init
id: init
shell: bash
run: |
# only rebuild clang-scan-deps if new commits are pushed to the llvm fork
git ls-remote https://github.com/stevencpp/llvm-project.git master > csd.lock
# rebuild the deps when the build environment changes
# if env.lock changes then the cache will be invalidated
echo "${{ runner.os }}" > env.lock
# bash always prepends its own paths when starting steps
# so we save the build environment to env.sh and restore it later
# clang-scan-deps and the tests need llvm and ninja to build
if [ "$RUNNER_OS" = "Windows" ]; then
# note: the MSBuild extension DLL needs to be 32-bit
# and so for the ninja build the environment needs to be x86
curl -fsSL -o LLVM9.exe https://releases.llvm.org/9.0.0/LLVM-9.0.0-win32.exe
7z x LLVM9.exe -y -o"C:/Program Files (x86)/LLVM"
export PATH="/c/Program Files (x86)/LLVM/bin:$PATH"
clang-cl --version
export CXX=cl && export CC=cl
# run vcvarsall (for ninja to work) and save the environment to env.sh:
.github/workflows/vs_env.bat x86
source env.sh
cl >> env.lock 2>&1
cl >> vsmodules.lock 2>&1
ifc_dir="$(dirname "`which cl`")/../../../ifc/x86"
# when saving the cache, the path needs to be in windows format (bug?)
ifc_dir="$(echo "$ifc_dir" | sed -e 's/^\///' -e 's/\//\\/g' -e 's/^./\0:/')"
echo "::set-output name=vsmodules-dir::$ifc_dir"
elif [ "$RUNNER_OS" = "Linux" ]; then
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key 2>/dev/null | sudo apt-key add -
sudo add-apt-repository 'deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-9 main' -y
sudo apt-get update -q
sudo apt-get install -y clang-9 lld-9 libc++-9-dev libc++abi-9-dev clang-tools-9
export CXX=clang++-9; export CC=clang-9;
export CXXFLAGS="-stdlib=libc++ -fsanitize=address,undefined";
#export CXXFLAGS="-stdlib=libc++"
export CSD_CXXFLAGS="-stdlib=libc++"
export LDFLAGS="-stdlib=libc++ -fuse-ld=lld";
# apt fetches a new version of the compiler every few days
# e.g clang version 9.0.1-+20191121055306+d1f4d6a4934-1~exp1~20191121045841.88
# don't rebuild unless it's a new release
$CXX --version | sed 's/-.*//' >> env.lock 2>&1
echo "$CXXFLAGS $CFLAGS $LDFLAGS" >> env.lock
echo "old cmake version: " && cmake --version
export CMAKE_VERSION=3.16.1
export CMAKE_ID=cmake-$CMAKE_VERSION-Linux-x86_64
curl -fsSL -o cmake.tar.gz "https://github.com/Kitware/CMake/releases/download/v$CMAKE_VERSION/$CMAKE_ID.tar.gz"
tar -zxf cmake.tar.gz
export PATH=$PWD/$CMAKE_ID/bin:$PATH
whereis cmake
curl -fsSL -o ninja.zip https://github.com/ninja-build/ninja/releases/download/v1.9.0/ninja-linux.zip
sudo 7z x ninja.zip -o/usr/local/bin
ninja --version
#sudo apt-get install -y ccache
export -p > env.sh
elif [ "$RUNNER_OS" = "macOS" ]; then
ninja --version || echo no ninja yet
# brew update # this is slow
# brew install ninja
curl -fsSL -o ninja.zip https://github.com/ninja-build/ninja/releases/download/v1.9.0/ninja-mac.zip
unzip ninja.zip
mv ninja /usr/local/bin
ninja --version >> env.lock 2>&1
cmake --version >> env.lock 2>&1
clang --version >> env.lock 2>&1
export CXXFLAGS="-fsanitize=address,undefined";
# vckpg is not installed on macOS yet
export VCPKG_INSTALLATION_ROOT=`pwd`/vcpkg
export -p > env.sh
fi
cmake --version >> env.lock 2>&1
echo "==== env.lock ===="
cat env.lock
echo "$VCPKG_GIT_HASH $VCPKG_DEPS" >> vcpkg.lock
- name: visual studio modules cache
if: runner.os == 'Windows'
uses: actions/cache@v1
id: cache-vsmodules
with:
path: ${{ steps.init.outputs.vsmodules-dir }}
key: ${{ runner.os }}-vsmodules-${{ hashFiles('**\vsmodules.lock') }}
- name: install visual studio modules
if: runner.os == 'Windows' && steps.cache-vsmodules.outputs.cache-hit != 'true'
shell: bash
run: |
echo "dummy" # workaround for a bug in parsing the yaml file
# note: this should run before any other builds because they might leave
# an msbuild.exe running which causes the installer to fail
echo "update vs_installer.exe before installing components"
curl -fsSL -o vs_enterprise.exe "https://aka.ms/vs/16/release/vs_Enterprise.exe"
./vs_enterprise.exe --update --quiet --wait
echo "install the pre-built standard library modules and cache them, the tests use this"
"C:/Program Files (x86)/Microsoft Visual Studio/Installer/vs_installer.exe" modify --quiet --norestart \
--installPath="C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise" \
--add Microsoft.VisualStudio.Component.VC.Modules.x86.x64 || echo failed
if [ ! -d "${{ steps.init.outputs.vsmodules-dir }}" ]; then
cat /tmp/dd_*.log
exit 1;
fi
- name: clang-scan-deps cache
if: runner.os != 'macOS'
uses: actions/cache@v1
id: cache-csd
with:
path: csd
key: ${{ runner.os }}-csd-2-${{ hashFiles('**\csd.lock') }}
- name: clang-scan-deps build
if: runner.os != 'macOS' && steps.cache-csd.outputs.cache-hit != 'true'
shell: bash
run: |
source env.sh
export CXXFLAGS="$CSD_CXXFLAGS"
if [ "$RUNNER_OS" = "Windows" ]; then
export CXX=clang-cl && export CC=clang-cl
export CMAKE_LINKER=-DCMAKE_LINKER=lld-link
set
fi
git clone --depth 1 https://github.com/stevencpp/llvm-project.git
mkdir csd
mkdir llvm-build
cd llvm-build
cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Release ../llvm-project/llvm \
-DLLVM_ENABLE_PROJECTS='clang;clang-tools-extra;libcxx;libcxxabi;libunwind;compiler-rt;lld' \
-DLLVM_ENABLE_MODULES=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=TRUE $CMAKE_LINKER \
-DLLVM_STATIC_LINK_CXX_STDLIB=TRUE
ninja clang-scan-deps${{ matrix.exe-suffix }}
cp bin/clang-scan-deps* ../csd
ninja `ninja -t targets all | grep cmake_object_order_depends_target | sed 's/: phony//' | tr '\n' ' '`
cd ..
mkdir ../scan # 'find' should not find the scan directory in the current path
find llvm-build -regextype posix-extended \
-regex '.*\.(c|cc|cpp|cxx|def|h|hh|hpp|hxx|inc|ipp|S)$' \
-exec cp --parents {} ../scan \;
cp --parents llvm-build/compile_commands.json ../scan
find llvm-project -regextype posix-extended \
-not -regex '.*/(test|INPUTS|docs).*' -and \
-regex '.*\.(c|cc|cpp|cxx|def|h|hh|hpp|hxx|inc|ipp|S)$' \
-exec cp --parents {} ../scan \;
cp --parents llvm-project/lld/unittests/MachOTests/empty_obj_x86_armv7.txt ../scan
mv ../scan csd
- name: clang-scan-deps upload
if: runner.os != 'macOS' && steps.cache-csd.outputs.cache-hit != 'true'
uses: actions/upload-artifact@master
with:
name: clang-scan-deps-${{ matrix.name }}
path: csd/clang-scan-deps${{ matrix.exe-suffix }}
- name: llvm-scanner-input upload
if: runner.os != 'macOS' && steps.cache-csd.outputs.cache-hit != 'true'
uses: actions/upload-artifact@master
with:
name: llvm-scanner-input-${{ matrix.name }}
path: csd/scan
- name: vcpkg cache
uses: actions/cache@v1
id: cache-vcpkg
with:
path: vcpkg
# if the vcpkg hash or the set of dependencies change,
# restore the most recently saved cache for the environment
# if the build environment changes then start from scratch
key: vcpkg-${{ hashFiles('**\env.lock') }}-${{ hashFiles('**\vcpkg.lock') }}
restore-keys: vcpkg-${{ hashFiles('**\env.lock') }}-
- name: vcpkg install
if: steps.cache-vcpkg.outputs.cache-hit != 'true'
shell: bash
run: |
source env.sh
if cd vcpkg; then
git fetch
else
git clone https://github.com/microsoft/vcpkg.git
cd vcpkg
if [ "$RUNNER_OS" = "macOS" ]; then
./bootstrap-vcpkg.sh || cat toolsrc/build.rel/CMakeFiles/CMakeError.log
fi
fi
git reset --hard $VCPKG_GIT_HASH
if [ "$RUNNER_OS" = "Windows" ]; then export VCPKG_TRIPLET="--triplet x86-windows"; fi
"$VCPKG_INSTALLATION_ROOT/vcpkg" install $VCPKG_TRIPLET $VCPKG_DEPS
"$VCPKG_INSTALLATION_ROOT/vcpkg" upgrade --no-dry-run
rm -rf downloads buildtrees packages
- name: build
shell: bash
run: |
source env.sh
if [ "$RUNNER_OS" = "macOS" ]; then
mkdir -p csd # tempfix to allow building on macOS until we build the scanner
touch csd/clang-scan-deps
fi
mkdir build && cd build
cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug .. \
-DCMAKE_TOOLCHAIN_FILE=../vcpkg/scripts/buildsystems/vcpkg.cmake \
-DCPPM_SCANNER_PATH=../csd/clang-scan-deps${{ matrix.exe-suffix }}
# -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
cmake --build . --parallel
- name: install package
# creating the package can take a while so do this only when we've pushed some tags for a release
if: startsWith(github.ref, 'refs/tags/')
shell: bash
run: |
source env.sh
cd build
if [ "$RUNNER_OS" = "Windows" ]; then
curl -fsSL -o nsis.exe "https://netix.dl.sourceforge.net/project/nsis/NSIS%203/3.04/nsis-3.04-setup.exe"
cmd.exe /C "nsis.exe /S"
# chocolatey also has a tool named "cpack"
"/c/Program Files/CMake/bin/cpack" -G NSIS
#cmd.exe /C "cpp_modules-0.0.1-win32.exe /S"
cmd.exe /C "cpp_modules-0.0.1-win32.exe /S /D=C:\Program Files\cpp_modules"
cat CPackConfig.cmake
elif [ "$RUNNER_OS" = "Linux" ]; then
# change the default install path for the generated self extracting script
STGZ_TEMPLATE=`ls ../cmake*/share/cmake*/Modules/Internal/CPack/CPack.STGZ_Header.sh.in`
STGZ_TEMPLATE_TMP=$STGZ_TEMPLATE.bak
sudo sed 's/cpack_include_subdir=\"\"/cpack_include_subdir=\"FALSE\"/' $STGZ_TEMPLATE > $STGZ_TEMPLATE_TMP
sudo sed 's/toplevel=\"`pwd`\"/toplevel=\/usr\/local\/cpp_modules \&\& mkdir -p \/usr\/local\/cpp_modules/' $STGZ_TEMPLATE_TMP > $STGZ_TEMPLATE
cpack -G STGZ
sudo ./cpp_modules-0.0.1-Linux.sh --skip-license
elif [ "$RUNNER_OS" = "macOS" ]; then
#cpack -G Bundle
echo todo # syntax error on fi without this
fi
- name: install
if: startsWith(github.ref, 'refs/tags/') != true
shell: bash
run: |
source env.sh
cd build
if [ "$RUNNER_OS" = "Windows" ]; then
cmake --install .
elif [ "$RUNNER_OS" = "Linux" ]; then
cmake_path=`which cmake` # sudo changes the path and we have cmake 3.12 installed by default
sudo $cmake_path --install .
fi
- name: test
if: runner.os != 'macOS'
shell: bash
continue-on-error: false
run: |
source env.sh
if [ ! -d llvm-build ]; then
if [ "$RUNNER_OS" != "Windows" ]; then
mv csd/scan/* .
export CXXFLAGS="-cxx-isystem /usr/lib/llvm-9/include/c++/v1 $CXXFLAGS"
sudo mkdir -p /usr/local/cpp_modules/lib/clang/10.0.0
sudo ln -s /usr/lib/llvm-9/lib/clang/9*/include /usr/local/cpp_modules/lib/clang/10.0.0/include
rm -rf llvm-project/libcxx/include
ln -s /usr/lib/llvm-9/include/c++/v1 llvm-project/libcxx/include
fuzzer_dir=llvm-build/projects/compiler-rt/lib/fuzzer/libcxx_fuzzer_x86_64/include/c++/v1
rm -rf $fuzzer_dir
ln -s /usr/lib/llvm-9/include/c++/v1 $fuzzer_dir
fi
fi
TESTS="[lmdb],[scanner],[gen_ninja],[ninja]"
if [ "$RUNNER_OS" = "Windows" ]; then
TESTS="$TESTS,[msbuild]"
CLANG_PATH="`which clang++.exe`"
CLANG_CL_PATH="`which clang-cl.exe`"
INSTALL_PATH="$PROGRAMFILES/cpp_modules"
else
CLANG_PATH="`which clang++-9`"
CLANG_CL_PATH="dummy" # catch2 error without this
INSTALL_PATH="/usr/local/cpp_modules"
fi
build/src/test/cppm_test $TESTS \
--scanner_tool_path=build/src/scanner/cppm_scanner_tool${{ matrix.exe-suffix }} \
--ninja_fork_path="$INSTALL_PATH/bin/ninja${{ matrix.exe-suffix }}" \
--clang_scan_deps_path="$INSTALL_PATH/bin/clang-scan-deps${{ matrix.exe-suffix }}" \
--system_test_path=tests \
--clang_cxx_path="$CLANG_PATH" --clang_cl_path="$CLANG_CL_PATH"
if [ "$RUNNER_OS" = "Windows" ]; then
#tests/iostream/benchmark.sh cl.exe
#tests/iostream/benchmark.sh clang++.exe
echo dummy # syntax error at else otherwise
else
chmod +x tests/iostream/benchmark.sh
#tests/iostream/benchmark.sh clang++-9
echo dummy
fi
if [ "$RUNNER_OS" = "Windows" ]; then exit 0; fi
cd llvm-build
mkdir -p tools/clang/tools/extra/clangd/fuzzer #workaround for an include bug
mkdir -p tools/clang/tools/extra/clangd/tool #same
../build/src/test/cppm_test [scanner_comp_db] \
--scanner_comp_db=compile_commands.json \
--scanner_db_path="." --scanner_item_root_path="." \
--scanner_file_to_touch=../llvm-project/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp \
--clang_scan_deps_path="$INSTALL_PATH/bin/clang-scan-deps${{ matrix.exe-suffix }}"
- name: codecov upload
uses: codecov/codecov-action@v1
if: false && runner.os != 'macOS'
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: release
uses: softprops/action-gh-release@v1
if: runner.os != 'macOS' && startsWith(github.ref, 'refs/tags/')
with:
files: build/cpp_modules-0.0.1-*
prerelease: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}