Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 57e03e6

Browse files
committed
Adding a linux CI workflow
1 parent c113e8d commit 57e03e6

File tree

13 files changed

+230
-120
lines changed

13 files changed

+230
-120
lines changed

.github/workflows/build.yml

Lines changed: 152 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,72 @@ on: [push]
44

55
jobs:
66
build:
7-
8-
runs-on: windows-latest
7+
name: ${{ matrix.name }}
8+
runs-on: ${{ matrix.os }}
99

10+
strategy:
11+
matrix:
12+
name: [
13+
windows,
14+
linux,
15+
]
16+
17+
include:
18+
- name: windows
19+
os: windows-latest
20+
exe-suffix: .exe
21+
- name: linux
22+
os: ubuntu-18.04
23+
exe-suffix:
24+
1025
steps:
1126
- uses: actions/checkout@v1
1227

13-
- name: pre-cache
14-
id: pre-cache
28+
- name: init
29+
id: init
1530
shell: bash
1631
run: |
1732
git ls-remote https://github.com/stevencpp/llvm-project.git master > csd.lock
18-
19-
msvc_base="C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC"
20-
msvc_dir=$msvc_base/`dir "$msvc_base"`
21-
echo "::set-output name=vsmodules-dir::$msvc_dir/ifc/x64"
22-
echo "$msvc_dir" > vsmodules.lock
23-
24-
.github/workflows/vs_env.bat x64
25-
echo "::add-path::C:\\Program Files\\LLVM\\bin"
33+
echo "::set-output name=vcpkg-dir::$VCPKG_INSTALLATION_ROOT"
34+
35+
if [ "$RUNNER_OS" = "Windows" ]; then
36+
msvc_base="C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC"
37+
msvc_dir=$msvc_base/`dir "$msvc_base"`
38+
echo "::set-output name=vsmodules-dir::$msvc_dir/ifc/x64"
39+
echo "$msvc_dir" > vsmodules.lock
40+
41+
.github/workflows/vs_env.bat x64
42+
echo "::add-path::C:\\Program Files\\LLVM\\bin"
43+
else
44+
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key 2>/dev/null | sudo apt-key add -
45+
sudo add-apt-repository 'deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-9 main' -y
46+
sudo apt-get update -q
47+
sudo apt-get install -y clang-9 lld-9 libc++-9-dev libc++abi-9-dev clang-tools-9
48+
export CXX=clang++-9; export CC=clang-9;
49+
export CXXFLAGS="-stdlib=libc++ -fsanitize=address,undefined"; export LDFLAGS="-stdlib=libc++ -fuse-ld=lld";
50+
export CSD_CXXFLAGS="-stdlib=libc++"
51+
export CXXFLAGS="-stdlib=libc++"
52+
$CXX --version
53+
54+
export CMAKE_VERSION=3.15.5
55+
export CMAKE_ID=cmake-$CMAKE_VERSION-Linux-x86_64
56+
curl -fsSL -o cmake.tar.gz "https://github.com/Kitware/CMake/releases/download/v$CMAKE_VERSION/$CMAKE_ID.tar.gz"
57+
tar -zxf cmake.tar.gz
58+
export PATH=$PWD/$CMAKE_ID/bin:$PATH
59+
whereis cmake
60+
cmake --version
61+
62+
curl -fsSL -o ninja.zip https://github.com/ninja-build/ninja/releases/download/v1.9.0/ninja-linux.zip
63+
sudo 7z x ninja.zip -o/usr/local/bin
64+
ninja --version
65+
66+
#sudo apt-get install -y ccache
67+
68+
export -p > env.sh
69+
fi
2670
2771
- name: clang-scan-deps cache
28-
uses: actions/cache@v1
72+
uses: actions/cache@releases/v1
2973
id: cache-csd
3074
with:
3175
path: csd
@@ -35,14 +79,18 @@ jobs:
3579
if: steps.cache-csd.outputs.cache-hit != 'true'
3680
shell: bash
3781
run: |
38-
source vsenv.sh
39-
40-
curl -fsSL -o LLVM9.exe https://releases.llvm.org/9.0.0/LLVM-9.0.0-win64.exe
41-
7z x LLVM9.exe -y -o"C:/Program Files/LLVM"
42-
export PATH="/c/Program Files/LLVM/bin:$PATH"
43-
clang-cl --version
44-
export CXX=clang-cl && export CC=clang-cl
45-
set
82+
source env.sh
83+
export CXXFLAGS="$CSD_CXXFLAGS"
84+
85+
if [ "$RUNNER_OS" = "Windows" ]; then
86+
curl -fsSL -o LLVM9.exe https://releases.llvm.org/9.0.0/LLVM-9.0.0-win64.exe
87+
7z x LLVM9.exe -y -o"C:/Program Files/LLVM"
88+
export PATH="/c/Program Files/LLVM/bin:$PATH"
89+
clang-cl --version
90+
export CXX=clang-cl && export CC=clang-cl
91+
export CMAKE_LINKER=-DCMAKE_LINKER=lld-link
92+
set
93+
fi
4694
4795
git clone --depth 1 https://github.com/stevencpp/llvm-project.git
4896
@@ -52,77 +100,80 @@ jobs:
52100
53101
cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Release ../llvm-project/llvm \
54102
-DLLVM_ENABLE_PROJECTS='clang;clang-tools-extra;libcxx;libcxxabi;libunwind;compiler-rt;lld' \
55-
-DLLVM_ENABLE_MODULES=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=TRUE \
56-
-DCMAKE_LINKER=lld-link
57-
ninja clang-scan-deps.exe
58-
cp bin/clang-scan-deps.exe ../csd
103+
-DLLVM_ENABLE_MODULES=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=TRUE $CMAKE_LINKER
104+
ninja clang-scan-deps${{ matrix.exe-suffix }}
105+
cp bin/clang-scan-deps* ../csd
59106
60107
ninja `ninja -t targets all | grep cmake_object_order_depends_target | sed 's/: phony//' | tr '\n' ' '`
108+
cd ..
61109
mkdir scan
62-
find . \( -name '*.h' -o -name '*.inc' -o -name '*.def' -o -name '*.cpp' \) -exec cp --parents {} scan \;
63-
cp compile_commands.json scan
64-
7z a ../csd/scan.zip scan/*
110+
find llvm-build -regextype posix-extended \
111+
-regex '.*\.(c|cc|cpp|cxx|def|h|hh|hpp|hxx|inc|S)$' \
112+
-exec cp --parents {} scan \;
113+
cp --parents llvm-build/compile_commands.json scan
114+
find llvm-project -regextype posix-extended \
115+
-not -regex '.*/(test|INPUTS|docs).*' -and \
116+
-regex '.*\.(c|cc|cpp|cxx|def|h|hh|hpp|hxx|inc|S)$' \
117+
-exec cp --parents {} scan \;
118+
cp --parents llvm-project/lld/unittests/MachOTests/empty_obj_x86_armv7.txt scan
119+
mv scan csd
65120
66121
- name: clang-scan-deps upload
67122
if: steps.cache-csd.outputs.cache-hit != 'true'
68123
uses: actions/upload-artifact@master
69124
with:
70-
name: clang-scan-deps.exe
71-
path: csd/clang-scan-deps.exe
125+
name: clang-scan-deps-${{ matrix.name }}
126+
path: csd/clang-scan-deps${{ matrix.exe-suffix }}
72127

73-
- name: scan.zip upload
128+
- name: llvm-scanner-input upload
74129
if: steps.cache-csd.outputs.cache-hit != 'true'
75130
uses: actions/upload-artifact@master
76131
with:
77-
name: scan.zip
78-
path: csd/scan.zip
132+
name: llvm-scanner-input-${{ matrix.name }}
133+
path: csd/scan
79134

80135
- name: vcpkg cache
81-
uses: actions/cache@v1
136+
uses: actions/cache@releases/v1
82137
id: cache-vcpkg
83138
with:
84-
path: vcpkg
139+
path: ${{ steps.init.outputs.vcpkg-dir }}/installed
85140
key: ${{ runner.os }}-vcpkg
86-
87-
- name: vcpkg bootstrap
88-
if: steps.cache-vcpkg.outputs.cache-hit != 'true'
89-
shell: cmd
90-
run:
91-
git clone https://github.com/microsoft/vcpkg.git &&
92-
cd vcpkg && bootstrap-vcpkg.bat && cd ..
93141

94142
- name: vcpkg install
95-
shell: cmd
96-
run:
97-
cd vcpkg && git pull &&
98-
vcpkg install fmt:x86-windows lmdb:x86-windows nlohmann-json:x86-windows
99-
catch2:x86-windows range-v3:x86-windows clara:x86-windows reproc:x86-windows &&
100-
vcpkg upgrade --no-dry-run &&
101-
if exist downloads rmdir /S /Q downloads &&
102-
if exist buildtrees rmdir /S /Q buildtrees &&
103-
if exist packages rmdir /S /Q packages &&
104-
cd ..
143+
shell: bash
144+
run: |
145+
source env.sh
146+
cd $VCPKG_INSTALLATION_ROOT
147+
git reset --hard origin/master
148+
git pull
149+
if [ "$RUNNER_OS" = "Windows"]; then export VCPKG_TRIPLET=--triplet x86-windows; fi
150+
vcpkg install $VCPKG_TRIPLET fmt lmdb nlohmann-json catch2 range-v3 clara reproc
151+
vcpkg upgrade --no-dry-run
105152
106153
- name: visual studio modules cache
107-
uses: actions/cache@v1
154+
if: runner.os == 'Windows'
155+
uses: actions/cache@releases/v1
108156
id: cache-vsmodules
109157
with:
110-
path: ${{ steps.pre-cache.outputs.vsmodules-dir }}
158+
path: ${{ steps.init.outputs.vsmodules-dir }}
111159
key: ${{ runner.os }}-vsmodules-${{ hashFiles('**\vsmodules.lock') }}
112160

113161
- name: install visual studio modules
114-
if: steps.cache-vsmodules.outputs.cache-hit != 'true'
115-
shell: cmd
116-
run:
162+
if: runner.os == 'Windows' && steps.cache-vsmodules.outputs.cache-hit != 'true'
163+
shell: bash
164+
run: |
117165
taskkill /IM "MSBuild.exe" /F
118166
119-
"C:/Program Files (x86)/Microsoft Visual Studio/Installer/vs_installer.exe" modify --quiet --norestart
120-
--installPath="C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise"
121-
--add Microsoft.VisualStudio.Component.VC.Modules.x86.x64
167+
"C:/Program Files (x86)/Microsoft Visual Studio/Installer/vs_installer.exe" modify --quiet --norestart \
168+
--installPath="C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise" \
169+
--add Microsoft.VisualStudio.Component.VC.Modules.x86.x64
122170
123-
if not exist "${{ steps.pre-cache.outputs.vsmodules-dir }}" echo failed && exit 1
171+
if [ ! -d "${{ steps.init.outputs.vsmodules-dir }}" ]; then
172+
echo failed; exit 1;
173+
fi
124174
125175
- name: install llvm
176+
if: runner.os == 'Windows'
126177
shell: bash
127178
run: |
128179
curl -fsSL -o LLVM.exe "https://prereleases.llvm.org/win-snapshots/LLVM-10.0.0-r375090-win64.exe"
@@ -132,34 +183,54 @@ jobs:
132183
- name: build
133184
shell: bash
134185
run: |
186+
source env.sh
135187
mkdir build
136188
cd build
137-
cmake -DCMAKE_TOOLCHAIN_FILE="../vcpkg/scripts/buildsystems/vcpkg.cmake" \
138-
-G "Visual Studio 16 2019" -A "Win32" \
139-
-DCMAKE_INSTALL_PREFIX="C:/Program Files/cpp_modules" \
140-
..
141-
cmake --build . --config "Debug" --parallel
142-
cmake --install . --config "Debug"
189+
export VCPKG_ARG=-DCMAKE_TOOLCHAIN_FILE="$VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake"
190+
if [ "$RUNNER_OS" = "Windows" ]; then
191+
cmake $VCPKG_ARG -G "Visual Studio 16 2019" -A "Win32" \
192+
-DCMAKE_INSTALL_PREFIX="C:/Program Files/cpp_modules" ..
193+
cmake --build . --config "Debug" --parallel
194+
cmake --install . --config "Debug"
195+
else
196+
cmake $VCPKG_ARG -G "Ninja" -DCMAKE_BUILD_TYPE=Debug ..
197+
# -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
198+
cmake --build . --parallel
199+
fi
143200
144201
- name: test
145202
shell: bash
146203
run: |
147-
source vsenv.sh
204+
source env.sh
205+
206+
TEST_DRIVER=cppm_test
207+
TESTS=[lmdb],[scanner],[gen_ninja]
208+
if [ "$RUNNER_OS" = "Windows" ]; then
209+
TEST_DRIVER=Debug/cppm_test.exe
210+
TESTS=$TESTS,[msbuild]
211+
TEST_ARGS="--msbuild-test-path=tests \
212+
--scanner_tool_path=build/src/scanner/Debug/cppm_scanner_tool.exe \
213+
--ninja_fork_path=build/_deps/ninja-build/Debug/ninja.exe"
214+
else
215+
TEST_ARGS="--clang_cxx_path=`which clang++-9` \
216+
--ninja_fork_path=build/_deps/ninja-build/ninja"
217+
fi
218+
219+
build/src/test/$TEST_DRIVER $TESTS $TEST_ARGS \
220+
--clang_scan_deps_path="$GITHUB_WORKSPACE/csd/clang-scan-deps${{ matrix.exe-suffix }}"
221+
222+
if [ "$RUNNER_OS" = "Windows" ]; then exit 0; fi
148223
149224
if [ ! -d llvm-build ]; then
150-
git clone --depth 1 https://github.com/stevencpp/llvm-project.git;
151-
7z x csd/scan.zip
152-
mkdir llvm-build
153-
mv scan/* llvm-build
154-
curl -fsSL -o headers.zip "https://drive.google.com/uc?export=download&id=1tbrnwu4gvz9IWsyxwZ_yKExRD9AMmqMb"
155-
7z x headers.zip -y -ollvm-build
225+
mv csd/scan/* .
226+
mkdir -p llvm-build/bin
227+
mv csd/clang-scan-deps* llvm-build/bin
156228
fi
157-
158229
cd llvm-build
159-
../build/src/test/Debug/cppm_test.exe [scanner_comp_db] --scanner_comp_db="compile_commands.json" \
230+
mkdir -p tools/clang/tools/extra/clangd/fuzzer #workaround for an include bug
231+
mkdir -p tools/clang/tools/extra/clangd/tool #same
232+
../build/src/test/$TEST_DRIVER [scanner_comp_db] \
233+
--scanner_comp_db="compile_commands.json" \
160234
--scanner_db_path="." --scanner_item_root_path="." \
161-
--scanner_file_to_touch="../llvm-project/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp"
162-
cd ..
163-
164-
cd build/src/test
165-
./Debug/cppm_test.exe [lmdb],[scanner],[msbuild],[gen_ninja]
235+
--scanner_file_to_touch="../llvm-project/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp" \
236+
--clang_scan_deps_path="$GITHUB_WORKSPACE/llvm-build/bin/clang-scan-deps${{ matrix.exe-suffix }}"

.github/workflows/vs_env.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ for /f "usebackq delims=*" %%i in (`%VSWHERE% -latest -property installationPath
77
call "%%i\VC\Auxiliary\Build\vcvarsall.bat" %*
88
)
99

10-
bash -c "export -p > vsenv.sh"
10+
bash -c "export -p > env.sh"

.travis.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,7 @@ script:
5858
cd src/test &&
5959
./cppm_test [lmdb],[scanner],[gen_ninja]
6060
--clang_scan_deps_path=../../../clang-scan-deps
61-
--clang_c_path=`which clang-9`
6261
--clang_cxx_path=`which clang++-9`
63-
--ninja_path=`which ninja`
6462
--ninja_fork_path=../../_deps/ninja-build/ninja &&
6563
git clone --depth 1 https://github.com/stevencpp/llvm-project.git &&
6664
mkdir -p llvm-build && cd llvm-build &&

src/scanner/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ include(FetchContent)
1111
FetchContent_Declare(
1212
ninja
1313
GIT_REPOSITORY https://github.com/stevencpp/ninja.git
14-
GIT_TAG 4ae6a9ac46862670a88c0507db4e00bfdd735b19
14+
GIT_TAG 3c0e177b2607f971e663ecbad0efab5d5ed39a40
1515
)
1616

1717
FetchContent_MakeAvailable(ninja)

src/scanner/lmdb_wrapper_impl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ MDB_val to_val_from_aggregate(const std::tuple<Ts...> &tup, std::index_sequence<
172172
memcpy(&buf[ofs], &size, sizeof(stored_size_type));
173173
ofs += sizeof(stored_size_type);
174174
}
175+
if (size == 0) // accessing elem.data() is UB if size == 0
176+
return;
175177
memcpy(&buf[ofs], elem.data(), size);
176178
ofs += size;
177179
} else {

0 commit comments

Comments
 (0)