-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathci-build.sh
125 lines (106 loc) · 4.42 KB
/
ci-build.sh
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
#!/bin/bash
# Run Travis setup
set -e
set -x
set -o errexit
set -o pipefail
function build_rust () {
VERBOSE=1 cargo test --all-features --all-targets --release -vv
VERBOSE=1 cargo build --all-features --all-targets --release -vv
}
function build_c() {
cd c
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=test_install -Dnov2sbp_BUILD=true ..
make -j8 VERBOSE=1
make do-all-tests
make run_test_novatel_parser
make install
cd ../..
}
function build_codecov() {
mkdir "${HOME}/.sonar"
# download build-wrapper
curl -sSLo "${HOME}/.sonar/build-wrapper-linux-x86.zip" https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip
unzip -o "${HOME}/.sonar/build-wrapper-linux-x86.zip" -d "${HOME}/.sonar/"
export PATH=${HOME}/.sonar/build-wrapper-linux-x86:${PATH}
# configure
cmake --version
cmake \
"-DCODE_COVERAGE=ON" \
"-DCMAKE_BUILD_TYPE=Debug" \
"-Dnov2sbp_BUILD=true" \
-S ./c -B ./build
# build with wrapper
build-wrapper-linux-x86-64 --out-dir ./bw-output cmake --build ./build --target ccov-all-export -j8
if [[ -z "${SONAR_SCANNER_VERSION}" ]]; then
echo "Error: SONAR_SCANNER_VERSION must be configured" >&2
exit 1
fi
export SONAR_SCANNER_HOME="${HOME}/.sonar/sonar-scanner-${SONAR_SCANNER_VERSION}-linux"
# download sonar-scanner
curl -sSLo "${HOME}/.sonar/sonar-scanner.zip" \
"https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${SONAR_SCANNER_VERSION}-linux.zip"
unzip -o "${HOME}/.sonar/sonar-scanner.zip" -d "${HOME}/.sonar/"
export PATH=${SONAR_SCANNER_HOME}/bin:${PATH}
export SONAR_SCANNER_OPTS="-server"
# Run sonar scanner
[[ -n "${SONAR_TOKEN:-}" ]] && SONAR_TOKEN_CMD_ARG="-Dsonar.login=${SONAR_TOKEN}"
[[ -n "${SONAR_ORGANIZATION:-}" ]] && SONAR_ORGANIZATION_CMD_ARG="-Dsonar.organization=${SONAR_ORGANIZATION}"
[[ -n "${SONAR_PROJECT_NAME:-}" ]] && SONAR_PROJECT_NAME_CMD_ARG="-Dsonar.projectName=${SONAR_PROJECT_NAME}"
# TODO: setup sonar.projectVersion so that it actually does something useful
# see https://swift-nav.atlassian.net/browse/DEVINFRA-504
SONAR_OTHER_ARGS="\
-Dsonar.projectVersion=1.0 \
-Dsonar.sources=. \
-Dsonar.cfamily.build-wrapper-output=./bw-output \
-Dsonar.cfamily.threads=1 \
-Dsonar.cfamily.cache.enabled=false \
-Dsonar.sourceEncoding=UTF-8"
# shellcheck disable=SC2086
sonar-scanner \
"-Dsonar.cfamily.llvm-cov.reportPath=./build/ccov/coverage.txt" \
"-Dsonar.host.url=${SONAR_HOST_URL}" \
"-Dsonar.projectKey=${SONAR_PROJECT_KEY}" \
${SONAR_OTHER_ARGS} \
"${SONAR_PROJECT_NAME_CMD_ARG}" \
"${SONAR_TOKEN_CMD_ARG}" \
"${SONAR_ORGANIZATION_CMD_ARG}"
}
if [ "$TESTENV" == "codecov" ]; then
build_codecov
elif [ "$TESTENV" == "rust" ]; then
build_rust
else
build_c
fi
if [[ "$TESTENV" == "rust" ]] && [[ "$OS_NAME" == "windows" ]]; then
cd target/release;
strip.exe rtcm3tosbp.exe sbp2rtcm.exe ubx2sbp.exe ixcom2sbp.exe nov2sbp.exe;
7z a -tzip ../../gnss_converters_windows.zip rtcm3tosbp.exe sbp2rtcm.exe ubx2sbp.exe ixcom2sbp.exe nov2sbp.exe;
cd ../..;
VERSION="$(git describe --always --tags)";
BUILD_TRIPLET="$($CC -dumpmachine)";
mv gnss_converters_windows.zip "gnss_converters-${VERSION}-windows-${BUILD_TRIPLET}.zip";
echo "gnss_converters-${VERSION}-windows-${BUILD_TRIPLET}.zip" >release-archive.filename;
ls -l;
fi
if [[ "$TESTENV" == "rust" ]] && [[ "$OS_NAME" == "osx" ]]; then
(cd target/release; strip rtcm3tosbp sbp2rtcm ubx2sbp ixcom2sbp nov2sbp);
tar -C "target/release" -czf gnss_converters_osx.tar.gz rtcm3tosbp sbp2rtcm ubx2sbp ixcom2sbp nov2sbp;
VERSION="$(git describe --always --tags --dirty)";
BUILD_TRIPLET="$($CC -dumpmachine)";
mv gnss_converters_osx.tar.gz "gnss_converters-${VERSION}-${BUILD_TRIPLET}.tar.gz";
echo "gnss_converters-${VERSION}-${BUILD_TRIPLET}.tar.gz" >release-archive.filename;
ls -l;
fi
if [[ "$TESTENV" == "rust" ]] && [[ "$OS_NAME" == "linux" ]]; then
(cd target/release; strip rtcm3tosbp sbp2rtcm ubx2sbp ixcom2sbp nov2sbp);
tar -C "target/release" -czf gnss_converters_linux.tar.gz rtcm3tosbp sbp2rtcm ubx2sbp ixcom2sbp nov2sbp;
VERSION="$(git describe --always --tags --dirty)";
BUILD_TRIPLET="$($CC -dumpmachine)";
mv gnss_converters_linux.tar.gz "gnss_converters-${VERSION}-${BUILD_TRIPLET}.tar.gz";
echo "gnss_converters-${VERSION}-${BUILD_TRIPLET}.tar.gz" >release-archive.filename;
ls -l;
fi