From 0a06ca6f873fdb64ab3c095b6addd71681d83dc3 Mon Sep 17 00:00:00 2001
From: Olivier SOLDANO <olivier.soldano@savoirfairelinux.com>
Date: Tue, 1 Aug 2017 11:37:31 -0400
Subject: [PATCH] modify windows compilation script
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

the script used to cross compile windows legacy clients had two
issues:
    - some dirs were not parametric,
    - it was used for compilation checking on our CI infra.

this patch makes the dirs parametric, and provides another script
that builds the client with bare minimum for checking; e.g. not
building the daemon and contrib to save time.

Change-Id: Idd0d9ebbfcd15b0caf72e09d4ddb3841de9c3d42
Reviewed-by: Anthony Léonard <anthony.leonard@savoirfairelinux.com>
---
 scripts/win_compile.sh       |  6 ++--
 scripts/win_compile_check.sh | 62 ++++++++++++++++++++++++++++++++++++
 2 files changed, 65 insertions(+), 3 deletions(-)
 create mode 100755 scripts/win_compile_check.sh

diff --git a/scripts/win_compile.sh b/scripts/win_compile.sh
index d56285e1..b7e81324 100755
--- a/scripts/win_compile.sh
+++ b/scripts/win_compile.sh
@@ -23,7 +23,7 @@ HOST=x86_64-w64-mingw32
 CMAKE_TOOLCHAIN_FILE=$rootdir/lrc/cmake/winBuild64.cmake
 fi
 
-INSTALL_PREFIX=$rootdir/daemon/_win${ARCH}
+INSTALL_PREFIX=$rootdir/install_win${ARCH}
 
 
 cd daemon/contrib
@@ -51,7 +51,7 @@ cd $rootdir
 
 cd client-windows
 git submodule update --init
-if [ ! -f "../daemon/_win${ARCH}/bin/WinSparkle.dll" ]
+if [ ! -f "$INSTALL_PREFIX/bin/WinSparkle.dll" ]
 then
 cd winsparkle
 git submodule init && git submodule update
@@ -61,7 +61,7 @@ make -j4 || exit 1
 make install
 cd ../../
 fi
-if [ ! -f "../daemon/_win${ARCH}/bin/libqrencode.dll" ]
+if [ ! -f "$INSTALL_PREFIX/bin/libqrencode.dll" ]
 then
 cd libqrencode
 ./autogen.sh || exit 1
diff --git a/scripts/win_compile_check.sh b/scripts/win_compile_check.sh
new file mode 100755
index 00000000..aad68a70
--- /dev/null
+++ b/scripts/win_compile_check.sh
@@ -0,0 +1,62 @@
+#!/bin/bash
+
+rootdir=$(pwd)
+HOST=i686-w64-mingw32
+ARCH=32
+CMAKE_TOOLCHAIN_FILE=$rootdir/lrc/cmake/winBuild.cmake
+
+while test -n "$1"
+do
+  case "$1" in
+  --clean)
+  ;;
+  --arch=*)
+  ARCH="${1#--arch=}"
+  ;;
+  esac
+  shift
+done
+
+if [ "$ARCH" = "64" ]
+then
+HOST=x86_64-w64-mingw32
+CMAKE_TOOLCHAIN_FILE=$rootdir/lrc/cmake/winBuild64.cmake
+fi
+
+INSTALL_PREFIX=$rootdir/install_win${ARCH}
+
+cd lrc
+mkdir -p build${ARCH}
+cd build${ARCH}
+export CMAKE_PREFIX_PATH=/usr/${HOST}/sys-root/mingw/lib/cmake
+cmake -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX -DRING_BUILD_DIR=$rootdir/daemon/src -DENABLE_LIBWRAP=true ..
+make -j4 install || exit 1
+cd $rootdir
+
+cd client-windows
+git submodule update --init
+if [ ! -f "$INSTALL_PREFIX/bin/WinSparkle.dll" ]
+then
+cd winsparkle
+git submodule init && git submodule update
+mkdir -p build${ARCH} && cd build${ARCH}
+cmake -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX ../cmake
+make -j4 || exit 1
+make install
+cd ../../
+fi
+if [ ! -f "$INSTALL_PREFIX/bin/libqrencode.dll" ]
+then
+cd libqrencode
+./autogen.sh || exit 1
+mkdir -p build${ARCH} && cd build${ARCH}
+../configure --host=${HOST} --prefix=$INSTALL_PREFIX
+make -j4 || exit 1
+make install
+cd ../..
+fi
+mkdir -p build${ARCH}
+cd build${ARCH}
+${HOST}-qmake-qt5 ../RingWinClient.pro -r -spec win32-g++ RING=$INSTALL_PREFIX INCLUDEPATH=$rootdir/client-windows/winsparkle
+make -j4 || exit 1
+make install
-- 
GitLab