libexpat/expat/qa.sh

124 lines
2.8 KiB
Bash
Raw Normal View History

2016-05-15 08:11:11 -04:00
#! /bin/bash
# Copyright (C) 2016 Sebastian Pipping <sebastian@pipping.org>
# Licensed under MIT license
set -o nounset
: ${GCC_CC:=gcc}
: ${GCC_CXX:=g++}
: ${CLANG_CC:=clang}
: ${CLANG_CXX:=clang++}
2016-05-24 14:34:07 -04:00
: ${AR:=ar}
2016-05-15 08:11:11 -04:00
: ${CC:="${CLANG_CC}"}
: ${CXX:="${CLANG_CXX}"}
2016-05-24 14:34:07 -04:00
: ${LD:=ld}
2016-05-15 08:11:11 -04:00
: ${MAKE:=make}
: ${BASE_FLAGS:="-pipe -Wall -Wextra -pedantic -Wno-overlength-strings"}
2016-05-30 14:56:00 -04:00
ANNOUNCE() {
2016-05-24 14:33:13 -04:00
local open='\e[1m'
local close='\e[0m'
echo -e -n "${open}"
echo -n "# $*"
echo -e "${close}"
2016-05-30 14:56:00 -04:00
}
2016-05-24 14:33:13 -04:00
2016-05-30 14:56:00 -04:00
RUN() {
ANNOUNCE "$@"
2016-05-24 14:33:13 -04:00
env "$@"
}
2016-05-15 08:11:11 -04:00
main() {
local mode="${1:-}"
2016-05-24 14:33:13 -04:00
shift
2016-05-15 08:11:11 -04:00
local RUNENV
local BASE_FLAGS="${BASE_FLAGS}"
case "${mode}" in
address)
# http://clang.llvm.org/docs/AddressSanitizer.html
local CC="${GCC_CC}"
local CXX="${GCC_CXX}"
BASE_FLAGS+=" -g -fsanitize=address -fno-omit-frame-pointer"
;;
coverage)
local CC="${GCC_CC}"
local CXX="${GCC_CXX}"
BASE_FLAGS+=" --coverage --no-inline"
;;
2016-05-30 14:29:33 -04:00
egypt)
BASE_FLAGS+=" -fdump-rtl-expand"
;;
2016-05-15 08:11:11 -04:00
memory)
# http://clang.llvm.org/docs/MemorySanitizer.html
BASE_FLAGS+=" -fsanitize=memory -fno-omit-frame-pointer -g -O2"
;;
2016-05-24 14:34:07 -04:00
ncc)
# http://students.ceid.upatras.gr/~sxanth/ncc/
local CC="ncc -ncgcc -ncld -ncfabs"
local AR=nccar
local LD=nccld
BASE_FLAGS+=" -fPIC"
;;
2016-05-15 08:11:11 -04:00
undefined)
# http://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html
BASE_FLAGS+=" -fsanitize=undefined"
export UBSAN_OPTIONS=print_stacktrace=1
;;
*)
echo "Usage:" 1>&2
2016-05-30 14:29:33 -04:00
echo " ${0##*/} (address|coverage|egypt|memory|ncc|undefined)" 1>&2
2016-05-15 08:11:11 -04:00
exit 1
;;
esac
2016-05-24 14:33:13 -04:00
local CFLAGS="-std=c89 ${BASE_FLAGS} ${CFLAGS:-}"
local CXXFLAGS="-std=c++98 ${BASE_FLAGS} ${CXXFLAGS:-}"
2016-05-15 08:11:11 -04:00
(
set -e
2016-05-24 14:33:13 -04:00
RUN CC="${CC}" CFLAGS="${CFLAGS}" \
CXX="${CXX}" CXXFLAGS="${CXXFLAGS}" \
2016-05-24 14:34:07 -04:00
AR="${AR}" \
LD="${LD}" \
2016-05-24 14:33:13 -04:00
./configure "$@"
2016-05-15 08:11:11 -04:00
2016-05-24 14:33:13 -04:00
RUN "${MAKE}" clean all
2016-05-24 14:34:07 -04:00
case "${mode}" in
2016-05-30 14:29:33 -04:00
egypt|ncc)
2016-05-24 14:34:07 -04:00
;;
*)
RUN "${MAKE}" check run-xmltest
;;
esac
2016-05-15 08:11:11 -04:00
) || exit 1
2016-05-24 14:33:13 -04:00
case "${mode}" in
coverage)
2016-05-15 08:11:11 -04:00
find -name '*.gcda' | sort | xargs gcov
2016-05-24 14:33:13 -04:00
;;
2016-05-30 14:29:33 -04:00
egypt)
local DOT_FORMAT="${DOT_FORMAT:-svg}"
2016-05-30 14:56:00 -04:00
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}"
2016-05-30 14:29:33 -04:00
;;
2016-05-24 14:34:07 -04:00
ncc)
RUN nccnav ./.libs/libexpat.a.nccout
;;
2016-05-24 14:33:13 -04:00
esac
2016-05-15 08:11:11 -04:00
}
main "$@"