Skip to content

Commit 7b7615a

Browse files
authored
Modernize codebase
- Enhance CMakeLists.txt files. - Move to Boost Test from Google Test to support pre-C++11 compilers. - Add more configurations on CI matrix builds. - Other minor fixes
1 parent 0af15e4 commit 7b7615a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+3452
-3800
lines changed

.github/depends/boost.sh

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,37 @@
1-
#!/bin/sh
1+
#!/bin/bash
22

33
usage()
44
{
55
cat <<EOL
66
-b - 32-bit or 64-bit library, maybe 32, 64 or both
77
-t - the toolset, maybe gcc, clang or both
8+
-p - installation prefix
89
EOL
910
}
1011

1112
build_boost()
1213
{
13-
BASE=`pwd`/..
14-
./b2 -j4 --toolset=$1 --prefix=${BASE}/usr --libdir="${BASE}/usr/$1/lib$2" --with-chrono --with-context --with-filesystem --with-system --with-timer address-model=$2 install
14+
mkdir $3 || exit 1
15+
./b2 \
16+
-j4 \
17+
--toolset=$1 \
18+
--prefix=$3 \
19+
--with-test \
20+
--with-headers \
21+
--with-chrono \
22+
--with-context \
23+
--with-filesystem \
24+
--with-system \
25+
--with-timer \
26+
address-model=$2 \
27+
install || exit 1
1528
}
1629

1730
bit="64"
1831
toolset="gcc"
32+
prefix="$HOME/boost-prefix"
1933

20-
while getopts "b:t:" c; do
34+
while getopts "b:t:p:" c; do
2135
case "$c" in
2236
b)
2337
bit="$OPTARG"
@@ -27,24 +41,27 @@ while getopts "b:t:" c; do
2741
toolset="$OPTARG"
2842
[ "$toolset" != "gcc" ] && [ "$toolset" != "clang" ] && [ "$toolset" != "both" ] && usage && exit 1
2943
;;
44+
p)
45+
prefix="$OPTARG"
46+
;;
3047
?*)
3148
echo "invalid arguments." && exit 1
3249
;;
3350
esac
3451
done
3552

36-
wget https://boostorg.jfrog.io/artifactory/main/release/1.72.0/source/boost_1_72_0.tar.bz2
37-
tar xf boost_1_72_0.tar.bz2
38-
cd boost_1_72_0
39-
./bootstrap.sh
53+
wget https://boostorg.jfrog.io/artifactory/main/release/1.76.0/source/boost_1_76_0.tar.bz2 || exit 1
54+
tar xf boost_1_76_0.tar.bz2 || exit 1
55+
cd boost_1_76_0
56+
./bootstrap.sh || exit 1
4057

4158
build()
4259
{
4360
if [ "$bit" = "both" ]; then
44-
build_boost $1 32
45-
build_boost $1 64
61+
build_boost $1 32 $prefix
62+
build_boost $1 64 $prefix
4663
else
47-
build_boost $1 $bit
64+
build_boost $1 $bit $prefix
4865
fi
4966
}
5067

.github/depends/zlib.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash
2+
3+
usage()
4+
{
5+
cat <<EOL
6+
-b - 32-bit or 64-bit library, maybe 32 or 64
7+
-p - installation prefix
8+
EOL
9+
}
10+
11+
bit="64"
12+
prefix="$HOME/zlib-prefix"
13+
14+
while getopts "b:t:p:" c; do
15+
case "$c" in
16+
b)
17+
bit="$OPTARG"
18+
[ "$bit" != "32" ] && [ "$bit" != "64" ] && usage && exit 1
19+
;;
20+
p)
21+
prefix="$OPTARG"
22+
;;
23+
?*)
24+
echo "invalid arguments." && exit 1
25+
;;
26+
esac
27+
done
28+
29+
wget https://zlib.net/zlib-1.2.11.tar.gz || exit 1
30+
tar -xf zlib-1.2.11.tar.gz || exit 1
31+
cd zlib-1.2.11
32+
33+
mkdir $prefix
34+
cmake \
35+
-D CMAKE_BUILD_TYPE=Release \
36+
-D CMAKE_INSTALL_PREFIX=$prefix \
37+
-D CMAKE_C_FLAGS="-m${bit}" \
38+
-D CMAKE_SHARED_LINKER_FLAGS="-m${bit}" \
39+
-S .
40+
cmake --build . --target install

.github/workflows/coverage.yml

Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ on:
1010
- '*'
1111

1212
jobs:
13-
1413
codecov:
1514
timeout-minutes: 30
1615
runs-on: ubuntu-latest
@@ -20,37 +19,49 @@ jobs:
2019
- name: install depends
2120
run: |
2221
sudo apt-get update
23-
sudo apt-get install g++-multilib lcov
22+
sudo apt-get install g++-10-multilib lcov -y
23+
./ci/set_gcc_10.sh
24+
2425
- name: Cache boost
2526
id: cache-boost
2627
uses: actions/cache@v1
2728
with:
28-
path: usr
29-
key: ${{ runner.os }}-boost-20210508-1-72-0
29+
path: ~/boost-prefix/
30+
key: ${{ runner.os }}-boost-64-1-76-0-20210613
31+
3032
- name: Build boost
3133
if: steps.cache-boost.outputs.cache-hit != 'true'
32-
run: ./.github/depends/boost.sh -b both -t gcc
34+
run: ./.github/depends/boost.sh -b 64 -t gcc -p $HOME/boost-prefix/
35+
36+
- name: Cache zlib
37+
id: cache-zlib
38+
uses: actions/cache@v1
39+
with:
40+
path: ~/zlib-prefix/
41+
key: ${{ runner.os }}-zlib-64-1-2-11-20210613
42+
43+
- name: Build zlib
44+
if: steps.cache-zlib.outputs.cache-hit != 'true'
45+
run: ./.github/depends/zlib.sh -b 64 -p $HOME/zlib-prefix/
46+
3347
- name: Compile tests
3448
run: |
35-
# install gtest
36-
BASE=`pwd`
37-
wget https://github.com/google/googletest/archive/release-1.7.0.zip -O googletest-release-1.7.0.zip
38-
unzip -q googletest-release-1.7.0.zip
39-
cd googletest-release-1.7.0
40-
g++ -m64 src/gtest-all.cc -I. -Iinclude -c -fPIC
41-
g++ -m64 src/gtest_main.cc -I. -Iinclude -c -fPIC
42-
ar -rv libgtest.a gtest-all.o
43-
ar -rv libgtest_main.a gtest_main.o
44-
mkdir -p ${BASE}/usr/include
45-
cp -r include/gtest ${BASE}/usr/include
46-
mkdir -p ${BASE}/usr/lib
47-
mv *.a ${BASE}/usr/lib
48-
cd ..
49-
50-
mkdir build && cd build
51-
CMAKE_LIBRARY_PATH="${BASE}/build" GTEST_ROOT="${BASE}/usr" CMAKE_PREFIX_PATH="${BASE}/usr/gcc/lib64/cmake" cmake -DMSGPACK_CXX17=ON -DMSGPACK_32BIT=OFF -DMSGPACK_CHAR_SIGN=signed -DMSGPACK_USE_X3_PARSE=ON -DMSGPACK_BUILD_EXAMPLES=ON -DMSGPACK_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Debug -DMSGPACK_GEN_COVERAGE=ON ..
52-
make -j4
53-
make test
49+
mkdir build
50+
cmake \
51+
-D MSGPACK_CXX20=ON \
52+
-D MSGPACK_32BIT=OFF \
53+
-D MSGPACK_CHAR_SIGN=signed \
54+
-D MSGPACK_USE_X3_PARSE=ON \
55+
-D MSGPACK_BUILD_EXAMPLES=ON \
56+
-D MSGPACK_BUILD_TESTS=ON \
57+
-D CMAKE_BUILD_TYPE=Debug \
58+
-D MSGPACK_GEN_COVERAGE=ON \
59+
-D CMAKE_PREFIX_PATH="$HOME/zlib-prefix;$HOME/boost-prefix" \
60+
-B build \
61+
-S . || exit 1
62+
cmake --build build --target all || exit 1
63+
ctest --test-dir build || exit 1
64+
5465
- name: Upload coverage to Codecov
5566
working-directory: build
5667
run: |

0 commit comments

Comments
 (0)