changeset 261:f6a99b984b8e

Clean up build script a bit.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 24 Dec 2019 05:38:12 +0200
parents 2552756f2876
children 847917a62ea2
files build-win32.sh
diffstat 1 files changed, 43 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/build-win32.sh	Tue Dec 24 05:15:09 2019 +0200
+++ b/build-win32.sh	Tue Dec 24 05:38:12 2019 +0200
@@ -8,7 +8,28 @@
 QT5_PREFIX="/misc/packages/qt5-src"
 QT5_BASE="${QT5_PREFIX}/qtbase"
 
-MINGWPATH=$(dirname $(i686-w64-mingw32-g++ -print-prog-name=cc1))
+MINGWPATH="$(dirname $(i686-w64-mingw32-g++ -print-prog-name=cc1))"
+MINGWLIBS="/usr/i686-w64-mingw32/lib/"
+
+
+fatal()
+{
+    echo "ERROR: $1"
+    exit 1
+}
+
+
+do_cp()
+{
+    cp -f "$1" "$2" || fatal "Could not copy file '$1' to '$2'."
+}
+
+
+do_mkdir()
+{
+    mkdir -p "$1" || fatal "Could not create directory '$1'."
+}
+
 
 do_cpinstall()
 {
@@ -17,41 +38,44 @@
     # $3 common sub path
     # $4 filename
 
-    mkdir -p "$2/$3"
-    cp -f "$1/$3/$4" "$2/$3/$4"
+    do_mkdir "$2/$3"
+    do_cp "$1/$3/$4" "$2/$3/$4"
 }
 
 do_install()
 {
     TARGET="$1"
+
     if test -d "$TARGET"; then
         rm -fr "$TARGET"
-    else
-        echo "ERROR: Target '$TARGET' exists but is not a directory!"
-        return 1
-    fi
-    if ! mkdir -p "$TARGET"; then
-        echo "ERROR: Could not create target directory '$TARGET'."
-        return 1
+    elif test -e "$TARGET"; then
+        fatal "Target '$TARGET' exists but is not a directory!"
     fi
 
-    echo "Installing to '$TARGET' ..."
+    mkdir -p "$TARGET" || fatal "Could not create target directory '$TARGET'."
+
+    echo "Installing to '${TARGET}' ..."
 
-    do_cpinstall "$QT5_BASE/plugins/" "$TARGET" "platforms" "qwindows.dll"
-    do_cpinstall "$QT5_BASE/plugins/" "$TARGET" "sqldrivers" "qsqlite.dll"
-    do_cpinstall "$QT5_BASE/plugins/" "$TARGET" "printsupport" "windowsprintersupport.dll"
+    do_cpinstall "${QT5_BASE}/plugins/" "$TARGET" "platforms" "qwindows.dll"
+    do_cpinstall "${QT5_BASE}/plugins/" "$TARGET" "sqldrivers" "qsqlite.dll"
+    do_cpinstall "${QT5_BASE}/plugins/" "$TARGET" "printsupport" "windowsprintersupport.dll"
 
     for i in Core Gui Sql Widgets PrintSupport Network; do
-        cp -f "$QT5_BASE/lib/Qt5$i.dll" "$TARGET"
+        do_cp "${QT5_BASE}/lib/Qt5${i}.dll" "$TARGET"
     done
 
     for i in libstdc++-6 libgcc_s_sjlj-1; do
-        cp -f "$MINGWPATH/$i.dll" "$TARGET"
-        strip "$TARGET/$i.dll"
+        do_cp "${MINGWPATH}/${i}.dll" "$TARGET"
+        strip "${TARGET}/${i}.dll"
     done
 
-    cp -f "$BUILDPATH/Syntilista.exe" "$TARGET"
-    unix2dos -n "COPYING.html" "$TMPFILE" && cp -f "$TMPFILE" "$TARGET/COPYING.txt"
+    for i in zlib1.dll; do
+        do_cp "${MINGWLIBS}/${i}" "$TARGET"
+    done
+
+    do_cp "$BUILDPATH/Syntilista.exe" "$TARGET"
+    unix2dos -n "COPYING.html" "$TMPFILE" || fatal "Could not unix2dos."
+    do_cp "$TMPFILE" "$TARGET/COPYING.txt"
     rm -f "$TMPFILE"
     return 0
 }