]> granicus.if.org Git - libexpat/commitdiff
qa.sh: Polish and make more flexible
authorSebastian Pipping <sebastian@pipping.org>
Tue, 24 May 2016 18:33:13 +0000 (20:33 +0200)
committerSebastian Pipping <sebastian@pipping.org>
Wed, 25 May 2016 17:04:03 +0000 (19:04 +0200)
expat/qa.sh

index 070993a55b2898da218887825c307f3b1c3035b7..a2e15c40e9681d88c3fcb176131231cae51fd3d7 100755 (executable)
@@ -15,8 +15,21 @@ set -o nounset
 
 : ${BASE_FLAGS:="-pipe -Wall -Wextra -pedantic -Wno-overlength-strings"}
 
+RUN() {
+    local open='\e[1m'
+    local close='\e[0m'
+
+    echo -e -n "${open}"
+    echo -n "# $*"
+    echo -e "${close}"
+
+    env "$@"
+}
+
 main() {
     local mode="${1:-}"
+    shift
+
     local RUNENV
     local BASE_FLAGS="${BASE_FLAGS}"
 
@@ -48,25 +61,25 @@ main() {
         ;;
     esac
 
-    CFLAGS="-std=c89 ${BASE_FLAGS}"
-    CXXFLAGS="-std=c++98 ${BASE_FLAGS}"
+    local CFLAGS="-std=c89 ${BASE_FLAGS} ${CFLAGS:-}"
+    local CXXFLAGS="-std=c++98 ${BASE_FLAGS} ${CXXFLAGS:-}"
 
     (
-        PS4='# '
         set -e
-        set -x
 
-        CC="${CC}" CFLAGS="${CFLAGS}" \
-            CXX="${CXX}" CXXFLAGS="${CXXFLAGS}" \
-            ./configure
+        RUN CC="${CC}" CFLAGS="${CFLAGS}" \
+                CXX="${CXX}" CXXFLAGS="${CXXFLAGS}" \
+                ./configure "$@"
 
-        "${MAKE}" clean all
-        "${MAKE}" check run-xmltest
+        RUN "${MAKE}" clean all
+        RUN "${MAKE}" check run-xmltest
     ) || exit 1
 
-    if [[ "${mode}" = coverage ]]; then
+    case "${mode}" in
+    coverage)
         find -name '*.gcda' | sort | xargs gcov
-    fi
+        ;;
+    esac
 }
 
 main "$@"