forked from LineageOS/android_external_expat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqa.sh
executable file
·130 lines (113 loc) · 3.18 KB
/
qa.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
126
127
128
129
130
#! /bin/bash
# Copyright (C) 2016 Sebastian Pipping <[email protected]>
# Licensed under MIT license
set -o nounset
: ${GCC_CC:=gcc}
: ${GCC_CXX:=g++}
: ${CLANG_CC:=clang}
: ${CLANG_CXX:=clang++}
: ${AR:=ar}
: ${CC:="${CLANG_CC}"}
: ${CXX:="${CLANG_CXX}"}
: ${LD:=ld}
: ${MAKE:=make}
: ${BASE_COMPILE_FLAGS:="-pipe -Wall -Wextra -pedantic -Wno-overlength-strings -Wno-long-long"}
ANNOUNCE() {
local open='\e[1m'
local close='\e[0m'
echo -e -n "${open}"
echo -n "# $*"
echo -e "${close}"
}
RUN() {
ANNOUNCE "$@"
env "$@"
}
main() {
local mode="${1:-}"
shift
local RUNENV
local BASE_COMPILE_FLAGS="${BASE_COMPILE_FLAGS}"
case "${mode}" in
address)
# http://clang.llvm.org/docs/AddressSanitizer.html
local CC="${CLANG_CC}"
local CXX="${CLANG_CXX}"
BASE_COMPILE_FLAGS+=" -g -fsanitize=address -fno-omit-frame-pointer"
;;
coverage | lib-coverage | app-coverage)
local CC="${GCC_CC}"
local CXX="${GCC_CXX}"
BASE_COMPILE_FLAGS+=" --coverage --no-inline"
;;
egypt)
BASE_COMPILE_FLAGS+=" -fdump-rtl-expand"
;;
memory)
# http://clang.llvm.org/docs/MemorySanitizer.html
BASE_COMPILE_FLAGS+=" -fsanitize=memory -fno-omit-frame-pointer -g -O2 -fsanitize-memory-track-origins -fsanitize-blacklist=$PWD/memory-sanitizer-blacklist.txt"
;;
ncc)
# http://students.ceid.upatras.gr/~sxanth/ncc/
local CC="ncc -ncgcc -ncld -ncfabs"
local AR=nccar
local LD=nccld
BASE_COMPILE_FLAGS+=" -fPIC"
;;
undefined)
# http://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html
BASE_COMPILE_FLAGS+=" -fsanitize=undefined"
export UBSAN_OPTIONS=print_stacktrace=1
;;
*)
echo "Usage:" 1>&2
echo " ${0##*/} (address|coverage|lib-coverage|app-coverage|egypt|memory|ncc|undefined)" 1>&2
exit 1
;;
esac
local CFLAGS="-std=c89 ${BASE_COMPILE_FLAGS} ${CFLAGS:-}"
local CXXFLAGS="-std=c++98 ${BASE_COMPILE_FLAGS} ${CXXFLAGS:-}"
(
set -e
RUN CC="${CC}" CFLAGS="${CFLAGS}" \
CXX="${CXX}" CXXFLAGS="${CXXFLAGS}" \
AR="${AR}" \
LD="${LD}" \
./configure "$@"
RUN "${MAKE}" clean all
case "${mode}" in
egypt|ncc)
;;
*)
RUN "${MAKE}" check run-xmltest
;;
esac
)
[[ $? -ne 0 ]] && exit 1
case "${mode}" in
coverage)
find -name '*.gcda' | sort | xargs gcov
;;
lib-coverage)
find lib -name '*.gcda' | sort | xargs gcov
;;
app-coverage)
find lib xmlwf -name '*.gcda' | sort | xargs gcov
;;
egypt)
local DOT_FORMAT="${DOT_FORMAT:-svg}"
local o="callgraph.${DOT_FORMAT}"
ANNOUNCE "egypt ...... | dot ...... > ${o}"
find -name '*.expand' \
| sort \
| xargs -r egypt \
| unflatten -c 20 \
| dot -T${DOT_FORMAT} -Grankdir=LR \
> "${o}"
;;
ncc)
RUN nccnav ./.libs/libexpat.a.nccout
;;
esac
}
main "$@"