improve build.bat

git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@309 99eadd0c-20b8-1223-b5c4-2a2b2df33de2
This commit is contained in:
XhmikosR 2011-02-03 10:43:13 +00:00
parent 10baee3373
commit aea7a50f7d

116
build.bat
View File

@ -2,56 +2,96 @@
SETLOCAL SETLOCAL
TITLE Compiling Subtitle Edit... TITLE Compiling Subtitle Edit...
IF NOT DEFINED VS100COMNTOOLS ECHO:Visual Studio 2010 wasn't found&&GOTO :EndWithError CD /D %~dp0
IF NOT DEFINED VS100COMNTOOLS (
ECHO Visual Studio 2010 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 "%VS100COMNTOOLS%vsvars32.bat"
devenv SubtitleEdit.sln /%BUILDTYPE% "Release|Any CPU"
IF %ERRORLEVEL% NEQ 0 GOTO EndWithError
ECHO.
POPD
IF /I "%BUILDTYPE%" == "Clean" GOTO END
CALL :SubDetectInno
IF DEFINED InnoSetupPath (
PUSHD "InnoSetupScript"
"%InnoSetupPath%\iscc.exe" /Q "Subtitle_Edit_installer.iss"
IF %ERRORLEVEL% NEQ 0 GOTO EndWithError
ECHO. & ECHO Installer compiled successfully!
MOVE /Y "SubtitleEdit-*-setup.exe" ".." >NUL 2>&1
POPD
) ELSE (
ECHO Inno Setup wasn't found; the installer wasn't built
)
:END
ECHO.
ENDLOCAL
PAUSE
EXIT /B
:EndWithError
Title Compiling Subtitle Edit [ERROR]
ECHO. & ECHO.
ECHO **ERROR: Build failed and aborted!**
PAUSE
ENDLOCAL
EXIT
:SubDetectInno
REM Detect if we are running on 64bit WIN and use Wow6432Node, and set the path REM Detect if we are running on 64bit WIN and use Wow6432Node, and set the path
REM of Inno Setup accordingly REM of Inno Setup accordingly
IF "%PROGRAMFILES(x86)%zzz"=="zzz" (SET "U_=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" IF "%PROGRAMFILES(x86)%zzz"=="zzz" (
SET "U_=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
) ELSE ( ) ELSE (
SET "U_=HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall" SET "U_=HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall"
) )
SET "I_=Inno Setup" SET "I_=Inno Setup"
SET "A_=%I_% 5" SET "A_=%I_% 5"
FOR /f "delims=" %%a IN ( FOR /f "delims=" %%a IN (
'REG QUERY "%U_%\%A_%_is1" /v "%I_%: App Path"2^>Nul^|FIND "REG_"') DO ( 'REG QUERY "%U_%\%A_%_is1" /v "%I_%: App Path"2^>Nul^|FIND "REG_"') DO (
SET "InnoSetupPath=%%a"&CALL :SubIS %%InnoSetupPath:*Z=%%) SET "InnoSetupPath=%%a" & CALL :SubIS %%InnoSetupPath:*Z=%%)
CD /D %~dp0
PUSHD "src"
CALL "%VS100COMNTOOLS%vsvars32.bat" >NUL
devenv SubtitleEdit.sln /Rebuild "Release|Any CPU"
IF %ERRORLEVEL% NEQ 0 GOTO :EndWithError
ECHO.
POPD
IF DEFINED InnoSetupPath (
PUSHD "InnoSetupScript"
"%InnoSetupPath%\iscc.exe" /Q "Subtitle_Edit_installer.iss"
IF %ERRORLEVEL% NEQ 0 GOTO :EndWithError
ECHO.&&ECHO:Installer compiled successfully!
MOVE /Y "SubtitleEdit-*-setup.exe" ".." >NUL 2>&1
POPD
) ELSE (
ECHO:Inno Setup wasn't found; the installer wasn't built
)
:END
ECHO.
ENDLOCAL && PAUSE
EXIT /B EXIT /B
:EndWithError
Title Compiling Subtitle Edit [ERROR]
ECHO. && ECHO.
ECHO: **ERROR: Build failed and aborted!**
PAUSE
ENDLOCAL
EXIT
:SubIS :SubIS
SET InnoSetupPath=%* SET InnoSetupPath=%*
GOTO :EOF EXIT /B