Debian Codegraph @

scripts/release_windows.cmd

raw
1 @echo off
2 setlocal enabledelayedexpansion
3
4 if "%1" == "" (
5 echo Please specify x86 ^(32-bit^) or x64 ^(64-bit^) architecture in cmdline
6 goto :eof
7 )
8
9 set BOTH=0
10 if not "%1" == "x86" if not "%1" == "x64" set BOTH=1
11
12 if %BOTH% == 1 (
13 echo Only x86 ^(32-bit^) or x64 ^(64-bit^) architectures are supported!
14 goto :eof
15 )
16
17 set ARCH=%1
18 call "c:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" %ARCH%
19
20 if "%ARCH%" == "x86" (
21 set QT=C:\Qt\5.13.2\msvc2017\
22 ) else (
23 set QT=C:\Qt\5.13.2\msvc2017_64\
24 )
25 set PATH=%QT%\bin;%PATH%
26
27 set ROOT="%~dp0.."
28 set BUILD="%~dp0..\build\build\release"
29 set CMAKEGEN="Visual Studio 16 2019"
30
31 set /p VERSION=<"%ROOT%\VERSION"
32
33 where /q git.exe
34 if "%ERRORLEVEL%" equ "0" (
35 for /f "tokens=*" %%t in ('git.exe rev-parse --short HEAD') do (
36 set COMMIT=%%t
37 )
38 set VERSION_COMMIT=%VERSION%-!COMMIT!
39 )
40
41 if "%ARCH%" == "x86" (
42 set TARGET="%~dp0\..\release\rclone-browser-%VERSION_COMMIT%-win-32-bit"
43 set TARGET_EXE="%~dp0\..\release\rclone-browser-%VERSION_COMMIT%-32-bit"
44 ) else (
45 set TARGET="%~dp0\..\release\rclone-browser-%VERSION_COMMIT%-win-64-bit"
46 set TARGET_EXE="%~dp0\..\release\rclone-browser-%VERSION_COMMIT%-64-bit"
47 )
48
49 pushd "%ROOT%"
50
51 if not exist release mkdir release
52
53 if exist "%TARGET%" rd /s /q "%TARGET%"
54 if exist "%TARGET%.zip" del "%TARGET%.zip"
55 if exist "%TARGET_EXE%.exe" del "%TARGET_EXE%.exe"
56
57 if exist build rd /s /q build
58 mkdir build
59 cd build
60
61 if "%ARCH%" == "x86" (
62 cmake -G %CMAKEGEN% -A Win32 -DCMAKE_CONFIGURATION_TYPES="Release" -DCMAKE_PREFIX_PATH=%QT% ..
63 ) else (
64 cmake -G %CMAKEGEN% -A x64 -DCMAKE_CONFIGURATION_TYPES="Release" -DCMAKE_PREFIX_PATH=%QT% ..
65 )
66
67 cmake --build . --config Release
68 popd
69
70 mkdir "%TARGET%" 2>nul
71
72 copy "%ROOT%\README.md" "%TARGET%\Readme.md"
73 copy "%ROOT%\CHANGELOG.md" "%TARGET%\Changelog.md"
74 copy "%ROOT%\LICENSE" "%TARGET%\License.txt"
75 copy "%BUILD%\RcloneBrowser.exe" "%TARGET%"
76
77 windeployqt.exe --no-translations --no-angle --no-compiler-runtime --no-svg "%TARGET%\RcloneBrowser.exe"
78 rd /s /q "%TARGET%\imageformats"
79
80 rem include all MSVCruntime dlls
81 copy "%VCToolsRedistDir%\%ARCH%\Microsoft.VC142.CRT\msvcp140.dll" "%TARGET%\"
82 copy "%VCToolsRedistDir%\%ARCH%\Microsoft.VC142.CRT\vcruntime140*.dll" "%TARGET%\"
83
84 rem for Windows 32 bits build include relevant openssl libraries
85 if "%ARCH%" == "x86" (
86 copy "c:\Program Files (x86)\openssl-1.1.1d-win32\libssl-1_1.dll" "%TARGET%\"
87 copy "c:\Program Files (x86)\openssl-1.1.1d-win32\libcrypto-1_1.dll" "%TARGET%\"
88 )
89
90 (
91 echo [Paths]
92 echo Prefix = .
93 echo LibraryExecutables = .
94 echo Plugins = .
95 )>"%TARGET%\qt.conf"
96
97 rem https://www.7-zip.org/
98 rem create zip archive of all files
99 "c:\Program Files\7-Zip\7z.exe" a -mx=9 -r -tzip "%TARGET%.zip" "%TARGET%"
100
101 rem create proper installer
102 rem Inno Setup installer by https://github.com/jrsoftware/issrc
103 rem in case user wants to install both 32bits and 64bits versions we need two AppId
104 rem 64bits ;AppId={{0AF9BF43-8D44-4AFF-AE60-6CECF1BF0D31}
105 rem 32bits ;AppId={{5644ED3A-6028-47C0-9796-29548EF7CEA3}
106 if "%ARCH%" == "x86" (
107 "c:\Program Files (x86)\Inno Setup 6"\iscc "/dMyAppVersion=%VERSION%" "/dMyAppId={{5644ED3A-6028-47C0-9796-29548EF7CEA3}" "/dMyAppDir=rclone-browser-%VERSION_COMMIT%-win-32-bit" "/dMyAppArch=x86" /O"../release" /F"rclone-browser-%VERSION_COMMIT%-32-bit" rclone-browser-win-installer.iss
108 ) else (
109 "c:\Program Files (x86)\Inno Setup 6"\iscc "/dMyAppVersion=%VERSION%" "/dMyAppId={{0AF9BF43-8D44-4AFF-AE60-6CECF1BF0D31}" "/dMyAppDir=rclone-browser-%VERSION_COMMIT%-win-64-bit" "/dMyAppArch=x64" /O"../release" /F"rclone-browser-%VERSION_COMMIT%-64-bit" rclone-browser-win-installer.iss
110 )