-
Notifications
You must be signed in to change notification settings - Fork 0
/
TxsCreateInstaller.bat
151 lines (129 loc) · 3.7 KB
/
TxsCreateInstaller.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
@ECHO off
IF [%1]==[] GOTO InvalidNumberArguments REM TORXAKIS_VERSION
IF [%2]==[] GOTO InvalidNumberArguments REM CONFIG FILE
set TORXAKIS_VERSION=%1
set CONFIG_FILE=%2
set NOCACHE=%3
IF [%3]==[] set NOCACHE=0
SET ORIGINAL_PATH=%PATH%
SET ORIGINAL_LOC=%cd%
set TAG_NAME=v%TORXAKIS_VERSION%
:RemoveExistingRepo
IF %NOCACHE%==1 IF exist %TAG_NAME% (
echo removing existing tag folder...
rmdir %TAG_NAME% /s /q
)
IF not exist %TAG_NAME% (
mkdir %TAG_NAME%
)
cd %TAG_NAME%
:CheckoutSpecifiedVersion
echo checking out tagged version %TAG_NAME%
IF NOT EXIST TorXakis (
git clone https://github.com/torxakis/torxakis.git
)
cd TorXakis
git checkout tags/%TAG_NAME%
ECHO Finished.
:CreateTorXakisVersionInfo
ECHO Creating TorXakis VersionInfo.hs file
SET VERSIONINFOFILE=sys/core/src/VersionInfo.hs
for /f "delims=" %%a in ('git rev-parse HEAD') do @set COMMIT_HASH=%%a
ECHO at %VERSIONINFOFILE%
echo {- > %VERSIONINFOFILE%
type copyright.txt >> %VERSIONINFOFILE%
echo -} >> %VERSIONINFOFILE%
echo module VersionInfo >> %VERSIONINFOFILE%
echo where >> %VERSIONINFOFILE%
echo version :: String >> %VERSIONINFOFILE%
echo version = "%TORXAKIS_VERSION% (commit: %COMMIT_HASH:~0,7%)" >> %VERSIONINFOFILE%
ECHO Finished.
:CheckoutPlugins
cd ..
echo Checking out plugins
IF NOT EXIST SupportNotepadPlusPlus (
echo Checking out NPP plugin...
git clone https://github.com/TorXakis/SupportNotepadPlusPlus.git
cd SupportNotepadPlusPlus
git checkout master
cd ..
) ELSE (
ECHO Using local SupportNotepadPlusPlus repo
)
ECHO Finished!
:BuildTorXakis
cd torxakis
ECHO Removing old server and ui binaries
del bin\txsserver.exe 2>nul
del bin\torxakis.exe 2>nul
ECHO Creating BuildInfo.hs
copy %ORIGINAL_LOC%\buildinfo.bat .
call buildinfo.bat > sys/core/src/BuildInfo.hs
ECHO Building Torxakis executable
IF NOT EXIST bin (
mkdir bin
)
stack setup
SET /a TRY_COUNT=0
:TryBuild
ECHO Running 'stack build'
stack build
ECHO Returned from 'stack build', ErrorLevel: %ERRORLEVEL%
IF %ERRORLEVEL% NEQ 0 (
ECHO Error level %ERRORLEVEL% is not 0 %TRY_COUNT%
SET /a TRY_COUNT=%TRY_COUNT%+1
IF %TRY_COUNT% LSS 50 (
ECHO Build failed, trying again %TRY_COUNT%
GOTO TryBuild
)
)
REM no easy way to assign a variable from command's result, so we do this
for /f "tokens=* usebackq" %%f in (`stack.exe path --local-install-root`) do (
copy %%f\bin\txsserver.exe bin\txsserver.exe
copy %%f\bin\torxakis.exe bin\torxakis.exe
)
:CheckTorXakisBuild
IF NOT EXIST bin\txsserver.exe GOTO TorXakisBuildFailure
IF NOT EXIST bin\torxakis.exe GOTO TorXakisBuildFailure
cd %ORIGINAL_LOC%
ECHO Building TorXakis finished.
:EnsureWxsGenerator
IF %NOCACHE%==1 IF EXIST WxsGenerator.jar (
rm WxsGenerator.jar
)
if not exist WxsGenerator.jar (
ECHO Can't find WxsGenerator.jar - Building...
call buildWxsGenerator.bat
)
:CreateInstallerWxs
ECHO Generating Wxs file.
IF EXIST %TAG_NAME%\WindowsInstaller (
ECHO Removing old "%TAG_NAME%\WindowsInstaller" folder
rmdir %TAG_NAME%\WindowsInstaller /s /q
)
java -jar WxsGenerator.jar %TORXAKIS_VERSION% %CONFIG_FILE%
ECHO Finished.
:CopyInstallerImages
echo Copying installer images
copy *.bmp %TAG_NAME%\WindowsInstaller\
echo Done
:CopyDocs
echo Copying docs folder
copy docs %TAG_NAME%\WindowsInstaller\
echo Done
:CompileWxs
ECHO Compiling Wxs File
"%WIX%bin\candle" -arch x64 -o %TAG_NAME%\WindowsInstaller\ %TAG_NAME%\WindowsInstaller\TorXakis.wxs
ECHO Compiled.
:LinkWxs
ECHO Linking Wxs File
"%WIX%bin\light" -o %TAG_NAME%\WindowsInstaller\TorXakis.msi -ext WixUIExtension %TAG_NAME%\WindowsInstaller\TorXakis.wixobj
ECHO Linked.
CD %ORIGINAL_LOC%
GOTO END
:InvalidNumberArguments
ECHO Usage: TxsCreateInstaller TorXakisVersionNumber wxsConfigFile [NoCache]
GOTO END
:TorXakisBuildFailure
ECHO Build Failure
:END