]> granicus.if.org Git - libexpat/commitdiff
Makefile.in: Extend target "qa"
authorSebastian Pipping <sebastian@pipping.org>
Sun, 15 May 2016 12:11:11 +0000 (14:11 +0200)
committerSebastian Pipping <sebastian@pipping.org>
Sun, 15 May 2016 12:11:11 +0000 (14:11 +0200)
expat/Makefile.in
expat/qa.sh [new file with mode: 0755]

index 5cc189df797c519454d19fc73a64aadc73e864df..3310aa9aae9272195501f5af309d8380587bf507 100644 (file)
@@ -190,17 +190,12 @@ run-xmltest: xmlwf/xmlwf@EXEEXT@ tests/xmlconf
        tests/xmltest.sh 2>&1 | tee tests/xmltest.log
        diff -u tests/xmltest.log.expected tests/xmltest.log
 
-QA_CFLAGS := \
-       -fsanitize=address -g \
-       --coverage --no-inline \
-       -Wall -Wextra -std=c89 -pedantic \
-       -Wno-overlength-strings \
-
 .PHONY: qa
 qa:
-       CFLAGS="$(QA_CFLAGS)" ./configure
-       $(MAKE) clean all check run-xmltest
-       find -name '*.gcda' | sort | xargs gcov
+       ./qa.sh address
+       ./qa.sh memory
+       ./qa.sh undefined
+       ./qa.sh coverage
 
 .SUFFIXES: .c .cpp .lo .@OBJEXT@
 
diff --git a/expat/qa.sh b/expat/qa.sh
new file mode 100755 (executable)
index 0000000..070993a
--- /dev/null
@@ -0,0 +1,72 @@
+#! /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++}
+
+: ${CC:="${CLANG_CC}"}
+: ${CXX:="${CLANG_CXX}"}
+: ${MAKE:=make}
+
+: ${BASE_FLAGS:="-pipe -Wall -Wextra -pedantic -Wno-overlength-strings"}
+
+main() {
+    local mode="${1:-}"
+    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"
+        ;;
+    memory)
+        # http://clang.llvm.org/docs/MemorySanitizer.html
+        BASE_FLAGS+=" -fsanitize=memory -fno-omit-frame-pointer -g -O2"
+        ;;
+    undefined)
+        # http://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html
+        BASE_FLAGS+=" -fsanitize=undefined"
+        export UBSAN_OPTIONS=print_stacktrace=1
+        ;;
+    *)
+        echo "Usage:" 1>&2
+        echo "  ${0##*/} (address|coverage|memory|undefined)" 1>&2
+        exit 1
+        ;;
+    esac
+
+    CFLAGS="-std=c89 ${BASE_FLAGS}"
+    CXXFLAGS="-std=c++98 ${BASE_FLAGS}"
+
+    (
+        PS4='# '
+        set -e
+        set -x
+
+        CC="${CC}" CFLAGS="${CFLAGS}" \
+            CXX="${CXX}" CXXFLAGS="${CXXFLAGS}" \
+            ./configure
+
+        "${MAKE}" clean all
+        "${MAKE}" check run-xmltest
+    ) || exit 1
+
+    if [[ "${mode}" = coverage ]]; then
+        find -name '*.gcda' | sort | xargs gcov
+    fi
+}
+
+main "$@"