-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathDeploy.bat
184 lines (138 loc) · 4.33 KB
/
Deploy.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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
:: Deploy script for PasHi.
::
:: This script creates a release of PasHi as a zip file that contains a setup
:: and read-me file.
::
:: The script has the following dependencies:
::
:: 1) MSBuild & Delphi.
:: 2) InfoZip's zip.exe. See https://delphidabbler.com/extras/info-zip
:: 3) Inno Setup v5.6.1 or later Unicode version (not v6). See
:: https://www.innosetup.com/
:: 4) DelphiDabbler Version Information Editor v2.15.1 or later. See
:: https://delphidabbler.com/software/vied
:: 5) PowerShell.
::
:: To use the script:
::
:: 1) Start the Embarcadero RAD Studio Command Prompt to set the required
:: environment variables for MSBuild.
:: 2) Set the ZipRoot environment variable to the directory where zip.exe is
:: installed.
:: 3) Set the VIEdRoot environment variable to the directory where VIEd.exe is
:: installed.
:: 4) Set the InnoSetupRoot environment variable to the directoty where Inno
:: Setup is installed.
:: 5) Change directory to that where this script is located.
:: 6) Run the script by entering Deploy with no parameters.
::
:: The script does the following:
::
:: 1) Builds the PasHi and PasHiGUI executables using MSBuild, Delphi and
:: VIEd.
:: 2) Uses PowerShell to extract the release version from version information
:: embedded in the PasHi executable. This is used to set the version of
:: the setup program and to name the setup program and zip file.
:: 3) Builds the setup file using Inno Setup.
:: 4) Creates the release zip file using Zip.exe.
@echo off
echo ======================
echo Creating PasHi Release
echo ======================
:: Check for required environment variables
if "%ZipRoot%"=="" goto envvarerror
if "%VIEdRoot%"=="" goto envvarerror
if "%InnoSetupRoot%"=="" goto envvarerror
:: Set other variables that don't depend on version
set PasHiExeStub=PasHi
set PasHiGUIExeStub=PasHiGUI
set BuildRoot=_build
set Win32ExeDir=%BuildRoot%\Win32\Release\exe
set ReleaseDir=%BuildRoot%\release
set TempDir=%ReleaseDir%\~temp
set PasHiSrcDir=Src
set PasHiGUISrcDir=%PasHiSrcDir%\GUI
set InstallSrcDir=%PasHiSrcDir%\Install
set DocsDir=Docs
set ConfigDir=Config
set ReadMeFile=%DocsDir%\README.txt
set ISCC="%InnoSetupRoot%\ISCC.exe"
:: Make a clean directory structure
if exist %BuildRoot% rmdir /S /Q %BuildRoot%
mkdir %ReleaseDir%
mkdir %TempDir%
:: Build Pascal
echo.
echo -------
echo --- Building executable programs
echo -------
echo.
setlocal
cd %PasHiSrcDir%
msbuild %PasHiExeStub%.dproj /p:config=Release /p:platform=Win32
endlocal
setlocal
cd %PasHiGUISrcDir%
msbuild %PasHiGUIExeStub%.dproj /p:config=Release /p:platform=Win32
endlocal
:: Get product version and set variables that depend on version
echo.
echo -------
echo --- Extracting version information
echo -------
echo.
PowerShell(Get-Command %Win32ExeDir%\%PasHiExeStub%.exe).FileVersionInfo.ProductVersion > "%TempDir%\~version"
set /p Version= < "%TempDir%\~version"
set SetupFileName=PasHi-Setup-%Version%
set ZipFile=%ReleaseDir%\pashi-exe-%Version%.zip
:: Split Version into prefix and suffix with "-" delimiter: suffix may be empty
for /f "tokens=1,2 delims=-" %%a in ("%Version%") do (
:: prefix and suffix required for Inno Setup
set VersionPrefix=%%a
set VersionSuffix=%%b
)
if not [%VersionSuffix%] == [] (
:: prepend "-" to suffic when suffix not empty
set VersionSuffix=-%VersionSuffix%
)
echo Release version number: %Version%
:: Build Setup
echo.
echo -------
echo --- Building setup program
echo -------
echo.
setlocal
cd %InstallSrcDir%
%ISCC% /DPasHiShortName=%PasHiExeStub% /DPasHiGUIShortName=%PasHiGUIExeStub% /DAppVersion=%VersionPrefix% /DAppVersionSuffix=%VersionSuffix% /DSetupOutDir=%TempDir% /DSetupFileName=%SetupFileName% /DExeInDir=%Win32ExeDir% /DDocsInDir=%DocsDir% /DConfigInDir=%ConfigDir% Install.iss
endlocal
:: Create zip files
echo.
echo -------
echo --- Creating zip files
echo -------
echo.
%ZipRoot%\zip.exe -j -9 %ZipFile% %TempDir%\%SetupFileName%.exe
%ZipRoot%\zip.exe -j -9 %ZipFile% %ReadMeFile%
:: Tidy up
echo.
echo -------
echo --- Tidying up
echo -------
echo.
echo Deleting %TempDir%
if exist %TempDir% rmdir /S /Q %TempDir%
:: Done
echo.
echo -------
echo --- Build completed
echo -------
goto end
:: Error messages
:envvarerror
echo.
echo ***ERROR: ZipRoot, VIEdRoot or InnoSetupRoot environment variable not set
echo.
goto end
:: End
:end