forked from misch7/nextcloud-client-building
-
Notifications
You must be signed in to change notification settings - Fork 0
/
single-build-desktop.bat
162 lines (127 loc) Β· 6.18 KB
/
single-build-desktop.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
@echo off
setlocal EnableDelayedExpansion
cls
echo "*** Build: desktop (%~nx0)"
Rem ******************************************************************************************
rem "environment Variables"
Rem ******************************************************************************************
call "%~dp0/common.inc.bat" %1 %2
Rem ******************************************************************************************
if "%TAG%" == "" set TAG=%TAG_DESKTOP%
set VERSION_SUFFIX=%VERSION_SUFFIX%-%BUILD_ARCH%
set MY_REPO=%PROJECT_PATH%/desktop
set MY_BUILD_PATH=%MY_REPO%/build
set MY_INSTALL_PATH=%PROJECT_PATH%/install/%BUILD_TYPE%/%BUILD_ARCH%
set MY_QT_DEPLOYMENT_PATH=%MY_INSTALL_PATH%/qt-libs
echo "* BUILD_TYPE=%BUILD_TYPE%"
echo "* BUILD_ARCH=%BUILD_ARCH%"
echo "* CMAKE_GENERATOR=%CMAKE_GENERATOR%"
echo "* CMAKE_EXTRA_FLAGS_DESKTOP=%CMAKE_EXTRA_FLAGS_DESKTOP%"
echo "* PROJECT_PATH=%PROJECT_PATH%"
echo "* QT_PATH=%QT_PATH%"
echo "* QT_BIN_PATH=%QT_BIN_PATH%"
echo "* VCINSTALLDIR=%VCINSTALLDIR%"
echo "* Png2Ico_EXECUTABLE=%Png2Ico_EXECUTABLE%"
echo "* QTKEYCHAIN_INCLUDE_DIR=%QTKEYCHAIN_INCLUDE_DIR%"
echo "* QTKEYCHAIN_LIBRARY=%QTKEYCHAIN_LIBRARY%"
echo "* OPENSSL_ROOT_DIR=%OPENSSL_ROOT_DIR%"
echo "* OPENSSL_INCLUDE_DIR=%OPENSSL_INCLUDE_DIR%"
echo "* OPENSSL_LIBRARIES=%OPENSSL_LIBRARIES%"
echo "* ZLIB_INCLUDE_DIR=%ZLIB_INCLUDE_DIR%"
echo "* ZLIB_LIBRARY=%ZLIB_LIBRARY%"
echo "* Build date %BUILD_DATE%"
echo "* VERSION_SUFFIX %VERSION_SUFFIX%"
echo "* TAG %TAG%"
echo "* MY_REPO=%MY_REPO%"
echo "* MY_BUILD_PATH=%MY_BUILD_PATH%"
echo "* MY_INSTALL_PATH=%MY_INSTALL_PATH%"
echo "* MY_QT_DEPLOYMENT_PATH=%MY_QT_DEPLOYMENT_PATH%"
echo "* PATH=%PATH%"
Rem ******************************************************************************************
rem "check for required environment variables"
Rem ******************************************************************************************
call :testEnv PROJECT_PATH
call :testEnv BUILD_TYPE
call :testEnv BUILD_ARCH
call :testEnv CMAKE_GENERATOR
call :testEnv QT_PATH
call :testEnv QT_BIN_PATH
call :testEnv VCINSTALLDIR
call :testEnv Png2Ico_EXECUTABLE
call :testEnv QTKEYCHAIN_INCLUDE_DIR
call :testEnv QTKEYCHAIN_LIBRARY
call :testEnv OPENSSL_ROOT_DIR
call :testEnv OPENSSL_INCLUDE_DIR
call :testEnv OPENSSL_LIBRARIES
call :testEnv ZLIB_INCLUDE_DIR
call :testEnv ZLIB_LIBRARY
call :testEnv BUILD_DATE
call :testEnv TAG
if %ERRORLEVEL% neq 0 goto onError
Rem ******************************************************************************************
rem "Test run?"
Rem ******************************************************************************************
if "%TEST_RUN%" == "1" (
echo "** TEST RUN - exit."
exit
)
Rem ******************************************************************************************
rem "clean up"
Rem ******************************************************************************************
echo "* Remove old installation files %MY_INSTALL_PATH% from previous build."
start "rm -rf" /B /wait rm -rf "%MY_INSTALL_PATH%/"*
if %ERRORLEVEL% neq 0 goto onError
echo "* Remove old dependencies files %MY_QT_DEPLOYMENT_PATH% from previous build."
start "rm -rf" /B /wait rm -rf "%MY_QT_DEPLOYMENT_PATH%/"*
if %ERRORLEVEL% neq 0 goto onError
echo "* Remove %MY_BUILD_PATH%/CMakeFiles from previous build."
start "rm -rf" /B /wait rm -rf "%MY_BUILD_PATH%/"*
if %ERRORLEVEL% neq 0 goto onError
Rem ******************************************************************************************
rem "git pull, build, collect dependencies"
Rem ******************************************************************************************
rem Reference: https://ss64.com/nt/setlocal.html
rem Reference: https://ss64.com/nt/start.html
echo "* git pull at %MY_REPO%/."
start "git pull" /D "%MY_REPO%/" /B /wait git pull --tags
if %ERRORLEVEL% neq 0 goto onError
echo "* git checkout %TAG% at %MY_REPO%/."
start "git checkout %TAG%" /D "%MY_REPO%/" /B /wait git checkout %TAG%
if %ERRORLEVEL% neq 0 goto onError
echo "* save git HEAD commit hash from repo %MY_REPO%/."
start "git rev-parse HEAD" /D "%MY_REPO%/" /B /wait git rev-parse HEAD > "%PROJECT_PATH%"/tmp
if %ERRORLEVEL% neq 0 goto onError
set /p GIT_REVISION= < "%PROJECT_PATH%"\tmp
if %ERRORLEVEL% neq 0 goto onError
del "%PROJECT_PATH%"\tmp
echo "* Run cmake with CMAKE_INSTALL_PREFIX and CMAKE_BUILD_TYPE set at %MY_BUILD_PATH%."
start "cmake.." /D "%MY_BUILD_PATH%" /B /wait cmake "-G%CMAKE_GENERATOR%" .. -DMIRALL_VERSION_SUFFIX="%VERSION_SUFFIX%" -DWITH_CRASHREPORTER=OFF -DMIRALL_VERSION_BUILD="%BUILD_DATE%" -DCMAKE_INSTALL_PREFIX="%MY_INSTALL_PATH%" -DCMAKE_BUILD_TYPE="%BUILD_TYPE%" -DNO_SHIBBOLETH=1 -DPng2Ico_EXECUTABLE="%Png2Ico_EXECUTABLE%" -DQTKEYCHAIN_LIBRARY="%QTKEYCHAIN_LIBRARY%" -DQTKEYCHAIN_INCLUDE_DIR="%QTKEYCHAIN_INCLUDE_DIR%" -DOPENSSL_ROOT_DIR="%OPENSSL_ROOT_DIR%" -DOPENSSL_INCLUDE_DIR="%OPENSSL_INCLUDE_DIR%" -DOPENSSL_LIBRARIES="%OPENSSL_LIBRARIES%" -DZLIB_INCLUDE_DIR="%ZLIB_INCLUDE_DIR%" -DZLIB_LIBRARY="%ZLIB_LIBRARY%" %CMAKE_EXTRA_FLAGS_DESKTOP%
if %ERRORLEVEL% neq 0 goto onError
echo "* Run cmake to compile and install."
start "cmake build" /D "%MY_BUILD_PATH%" /B /wait cmake --build . --config %BUILD_TYPE% --target install
if %ERRORLEVEL% neq 0 goto onError
if "%BUILD_TYPE%" == "Debug" (
set WINDEPLOYQT_BUILD_TYPE=debug
) else (
set WINDEPLOYQT_BUILD_TYPE=release
)
echo "* Run windeployqt to collect all nextcloud.exe dependencies and output it to %MY_QT_DEPLOYMENT_PATH%/."
start "windeployqt" /B /wait windeployqt.exe --%WINDEPLOYQT_BUILD_TYPE% --compiler-runtime "%MY_INSTALL_PATH%/bin/nextcloud.exe" --dir "%MY_QT_DEPLOYMENT_PATH%/"
if %ERRORLEVEL% neq 0 goto onError
echo "* git checkout master at %MY_REPO%/."
start "git checkout master" /D "%MY_REPO%/" /B /wait git checkout master
if %ERRORLEVEL% neq 0 goto onError
Rem ******************************************************************************************
echo "*** Finished Build: desktop %BUILD_TYPE% %BUILD_ARCH% (GIT_REVISION=%GIT_REVISION%) (%~nx0)"
exit 0
:onError
echo "*** Build FAILED: desktop %BUILD_TYPE% %BUILD_ARCH% (%~nx0)"
if %ERRORLEVEL% neq 0 exit %ERRORLEVEL%
if !ERRORLEVEL! neq 0 exit !ERRORLEVEL!
exit 1
:testEnv
if "!%*!" == "" (
echo "Missing environment variable: %*"
exit /B 1
)
exit /B