forked from SubtitleEdit/subtitleedit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.bat
158 lines (124 loc) · 5 KB
/
build.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
@ECHO OFF
SETLOCAL
SET "VERSION=3.3.15"
SET "SEVENZIP_PATH=%PROGRAMFILES%\7-Zip\7z.exe"
CD /D %~dp0
rem Check for the help switches
IF /I "%~1" == "help" GOTO SHOWHELP
IF /I "%~1" == "/help" GOTO SHOWHELP
IF /I "%~1" == "-help" GOTO SHOWHELP
IF /I "%~1" == "--help" GOTO SHOWHELP
IF /I "%~1" == "/?" GOTO SHOWHELP
IF NOT DEFINED VS120COMNTOOLS (
ECHO Visual Studio 2013 wasn't found
GOTO EndWithError
)
IF "%~1" == "" (
SET "BUILDTYPE=Build"
) ELSE (
IF /I "%~1" == "Build" SET "BUILDTYPE=Build" & GOTO START
IF /I "%~1" == "/Build" SET "BUILDTYPE=Build" & GOTO START
IF /I "%~1" == "-Build" SET "BUILDTYPE=Build" & GOTO START
IF /I "%~1" == "--Build" SET "BUILDTYPE=Build" & GOTO START
IF /I "%~1" == "Clean" SET "BUILDTYPE=Clean" & GOTO START
IF /I "%~1" == "/Clean" SET "BUILDTYPE=Clean" & GOTO START
IF /I "%~1" == "-Clean" SET "BUILDTYPE=Clean" & GOTO START
IF /I "%~1" == "--Clean" SET "BUILDTYPE=Clean" & GOTO START
IF /I "%~1" == "Rebuild" SET "BUILDTYPE=Rebuild" & GOTO START
IF /I "%~1" == "/Rebuild" SET "BUILDTYPE=Rebuild" & GOTO START
IF /I "%~1" == "-Rebuild" SET "BUILDTYPE=Rebuild" & GOTO START
IF /I "%~1" == "--Rebuild" SET "BUILDTYPE=Rebuild" & GOTO START
ECHO. & ECHO Unsupported commandline switch!
GOTO EndWithError
)
:START
PUSHD "src"
CALL "%VS120COMNTOOLS%vsvars32.bat" x86
TITLE %BUILDTYPE%ing SubtitleEdit - Release^|Any CPU...
"MSBuild.exe" SubtitleEdit.sln /t:%BUILDTYPE% /p:Configuration=Release /p:Platform="Any CPU"^
/maxcpucount /consoleloggerparameters:DisableMPLogging;Summary;Verbosity=minimal
IF %ERRORLEVEL% NEQ 0 GOTO EndWithError
ECHO.
POPD
IF /I "%BUILDTYPE%" == "Clean" GOTO END
IF DEFINED SEVENZIP_PATH IF EXIST "%SEVENZIP_PATH%" CALL :SubZipFile
CALL :SubDetectInnoSetup
IF DEFINED InnoSetupPath (
PUSHD "installer"
TITLE Compiling installer...
"%InnoSetupPath%\iscc.exe" /O.. /Q "Subtitle_Edit_installer.iss"
IF %ERRORLEVEL% NEQ 0 GOTO EndWithError
ECHO. & ECHO Installer compiled successfully!
POPD
) ELSE (
ECHO Inno Setup wasn't found; the installer wasn't built
)
:END
TITLE Compiling Subtitle Edit finished!
ECHO.
ENDLOCAL
PAUSE
EXIT /B
:SubZipFile
TITLE Creating the ZIP file...
PUSHD "src\bin\Release"
IF EXIST "temp_zip" RD /S /Q "temp_zip"
IF NOT EXIST "temp_zip" MD "temp_zip"
IF NOT EXIST "temp_zip\Languages" MD "temp_zip\Languages"
IF NOT EXIST "temp_zip\Tesseract" MD "temp_zip\Tesseract"
IF NOT EXIST "temp_zip\Tesseract\tessdata" MD "temp_zip\Tesseract\tessdata"
IF NOT EXIST "temp_zip\Tesseract\tessdata\configs" MD "temp_zip\Tesseract\tessdata\configs"
COPY /Y /V "..\..\..\gpl.txt" "temp_zip\"
COPY /Y /V "..\..\Changelog.txt" "temp_zip\"
COPY /Y /V "Interop.QuartzTypeLib.dll" "temp_zip\"
COPY /Y /V "Hunspellx86.dll" "temp_zip\"
COPY /Y /V "NHunspell.dll" "temp_zip\"
COPY /Y /V "SubtitleEdit.exe" "temp_zip\"
COPY /Y /V "Languages\*.xml" "temp_zip\Languages\"
COPY /Y /V "..\..\..\Tesseract\msvcp90.dll" "temp_zip\Tesseract\"
COPY /Y /V "..\..\..\Tesseract\msvcr90.dll" "temp_zip\Tesseract\"
COPY /Y /V "..\..\..\Tesseract\tesseract.exe" "temp_zip\Tesseract\"
COPY /Y /V "..\..\..\Tesseract\tessdata\configs\hocr" "temp_zip\Tesseract\tessdata\configs\"
COPY /Y /V "..\..\..\Tesseract\tessdata\eng.traineddata" "temp_zip\Tesseract\tessdata\"
PUSHD "temp_zip"
START "" /B /WAIT "%SEVENZIP_PATH%" a -tzip -mx=9 "SE%VERSION%.zip" * >NUL
IF %ERRORLEVEL% NEQ 0 GOTO EndWithError
MOVE /Y "SE%VERSION%.zip" "..\..\..\.." >NUL
POPD
IF EXIST "temp_zip" RD /S /Q "temp_zip"
POPD
EXIT /B
:EndWithError
Title Compiling Subtitle Edit [ERROR]
ECHO. & ECHO.
ECHO **ERROR: Build failed and aborted!**
PAUSE
ENDLOCAL
EXIT
:SHOWHELP
TITLE %~nx0 %1
ECHO. & ECHO.
ECHO Usage: %~nx0 [Clean^|Build^|Rebuild]
ECHO.
ECHO Notes: You can also prefix the commands with "-", "--" or "/".
ECHO The arguments are not case sensitive.
ECHO. & ECHO.
ECHO Executing %~nx0 without any arguments is equivalent to "%~nx0 build"
ECHO.
ENDLOCAL
EXIT /B
:SubDetectInnoSetup
rem Detect if we are running on 64bit Windows and use Wow6432Node since Inno Setup is
rem a 32-bit application, and set the registry key of Inno Setup accordingly
IF DEFINED PROGRAMFILES(x86) (
SET "U_=HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall"
) ELSE (
SET "U_=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
)
FOR /F "delims=" %%a IN (
'REG QUERY "%U_%\Inno Setup 5_is1" /v "Inno Setup: App Path"2^>Nul^|FIND "REG_"') DO (
SET "InnoSetupPath=%%a" & CALL :SubInnoSetup %%InnoSetupPath:*Z=%%)
EXIT /B
:SubInnoSetup
SET "InnoSetupPath=%*"
EXIT /B