From c8e843b3d8b3c8995039dbcba76b7657df9240a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20De=C3=A1k?= Date: Mon, 20 Jul 2020 11:55:33 +1000 Subject: [PATCH] Work on windows build script. --- Documentation/buildWindows.txt | 36 ++++++++++++ buildWindows.cmd | 100 ++++++++++++++++++++++----------- 2 files changed, 103 insertions(+), 33 deletions(-) create mode 100644 Documentation/buildWindows.txt diff --git a/Documentation/buildWindows.txt b/Documentation/buildWindows.txt new file mode 100644 index 0000000..c7faeb9 --- /dev/null +++ b/Documentation/buildWindows.txt @@ -0,0 +1,36 @@ +NAME + + buildWindows.cmd - Build Linux Binaries for Synergy + +SYNOPSIS + + buildWindows.cmd [OPTION] + +DESCRIPTION + + This is a utility script for building Synergy binaries and distribution packages. + The script will build the latest snapshot from the Synergy-Core submodule. + + --help + + Display this help message. + + --msbuild + + Build binaries only with MSBuild. + + --msi + + Build an MSI package. + + --zip + + Build a standalone ZIP package. + + --all + + Build all packages. + + --clean + + Clean the build and output locations. diff --git a/buildWindows.cmd b/buildWindows.cmd index 80f0f35..0846241 100644 --- a/buildWindows.cmd +++ b/buildWindows.cmd @@ -3,51 +3,84 @@ set libQtPath=c:\Qt\Qt5.12.9\5.12.9\msvc2017_64 if not exist "%libQtPath%" ( - echo "error: Unable to resolve Qt library. Make sure the 'libQtPath' variable is correct." + echo error: Unable to resolve Qt library. Make sure the 'libQtPath' variable is correct. exit 1 - ) +) rem https://docs.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=vs-2019 set vcvarsallCommand=c:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat if not exist "%vcvarsallCommand%" ( - echo "error: Unable to resolve vcvarsall command file. Make sure the 'vcvarsallCommand' variable is correct." + echo error: Unable to resolve vcvarsall command file. Make sure the 'vcvarsallCommand' variable is correct. exit 1 - ) +) set upstreamURL=https://github.com/DEAKSoftware/Synergy-Binaries.git for /F "tokens=* USEBACKQ" %%F in (`git config --get remote.origin.url`) do ( set queriedURL=%%F - ) +) -if "%upstreamURL%" NEQ "%queriedURL%" ( - echo "error: Unrecognised Git upstream URL. This script must run within the top-level directory of the Synergy-Binaries repository." +if "%upstreamURL%" neq "%queriedURL%" ( + echo error: Unrecognised Git upstream URL. This script must run within the top-level directory of the Synergy-Binaries repository. exit 1 - ) +) for /F "tokens=* USEBACKQ" %%F in (`git rev-parse --show-toplevel`) do ( set toplevelPath=%%F - ) +) -if "%toplevelPath%" EQU "" ( - echo "error: Unrecognised top-level directory. This script must run within the top-level directory of the Synergy-Binaries repository." +if "%toplevelPath%" equ "" ( + echo error: Unrecognised top-level directory. This script must run within the top-level directory of the Synergy-Binaries repository. exit 1 - ) +) set synergyCorePath=%toplevelPath%\Synergy-Core set buildPath=%synergyCorePath%\build set binariesPath=%toplevelPath%\Binaries set toolsPath=%toplevelPath%\Tools -call "%vcvarsallCommand%" x64 - :main +if [%1] equ [--help] ( + + type "%toplevelPath%\Documentation\buildWindows.txt" + exit 0 + +) else if [%1] equ [--msbuild] ( + + call :configure + call :buildMSBuild + +) else if [%1] equ [--msi] ( + + call :configure + call :buildMSBuild + call :buildMSI -call :configure -call :buildStandalone +) else if [%1] equ [--zip] ( + call :configure + call :buildMSBuild + call :buildZIP + +) else if [%1] equ [--all] ( + + call :configure + call :buildMSBuild + call :buildMSI + call :buildZIP + +) else if [%1] equ [--clean] ( + + call :buildClean + +) else ( + + echo error: Bad or unknown option. Run with '--help' option for details. + exit 1 + +) exit 0 @@ -72,6 +105,7 @@ exit 0 :configure + call "%vcvarsallCommand%" x64 call :configureSubmodules call :configureCMake call :configureVersion @@ -88,7 +122,23 @@ exit 0 exit /b 0 -:buildStandalone +:buildMSI + + pushd "%buildPath%\installer" + + msbuild Synergy.sln /p:Configuration=Release + if %errorlevel% equ 1 exit 1 + + popd + + copy "%buildPath%\installer\bin\Release\Synergy.msi" "%binariesPath%" + if %errorlevel% equ 1 exit 1 + + ren "%binariesPath%\Synergy.msi" "%synergyReleaseName%.msi" + + exit /b 0 + +:buildZIP setlocal @@ -128,22 +178,6 @@ exit 0 endlocal exit /b 0 -:buildMSI - - pushd "%buildPath%\installer" - - msbuild Synergy.sln /p:Configuration=Release - if %errorlevel% equ 1 exit 1 - - popd - - copy "%buildPath%\installer\bin\Release\Synergy.msi" "%binariesPath%" - if %errorlevel% equ 1 exit 1 - - ren "%binariesPath%\Synergy.msi" "%synergyReleaseName%.msi" - - exit /b 0 - :buildClean pushd "%synergyCorePath%"