From 6a480fd764872cb27172159f3b4e1749a0c0f852 Mon Sep 17 00:00:00 2001 From: lordmulder Date: Wed, 10 Nov 2010 17:03:01 +0100 Subject: [PATCH] Refactor deployment script --- LameXP.vcproj | 8 +++--- etc/Deployment/_build.bat | 24 +++++------------ etc/Deployment/_error.bat | 5 ++++ etc/Deployment/_version.bat | 29 +++++++++++++++++++++ etc/Deployment/release.bat | 52 ++++++++++++++++++------------------- etc/NSIS/setup.nsi | 3 ++- 6 files changed, 71 insertions(+), 50 deletions(-) create mode 100644 etc/Deployment/_error.bat create mode 100644 etc/Deployment/_version.bat diff --git a/LameXP.vcproj b/LameXP.vcproj index 2e47af49..8ad22241 100644 --- a/LameXP.vcproj +++ b/LameXP.vcproj @@ -93,7 +93,7 @@ @@ -510,7 +510,7 @@ @@ -520,7 +520,7 @@ diff --git a/etc/Deployment/_build.bat b/etc/Deployment/_build.bat index eb2085b5..52bc197b 100644 --- a/etc/Deployment/_build.bat +++ b/etc/Deployment/_build.bat @@ -1,5 +1,5 @@ @echo off -set "LAMEXP_BUILD_SUCCESS=NO" +set "LAMEXP_ERROR=1" echo ---------------------------------------------------------------- echo Solution File: %1 echo Configuration: %~n2 @@ -9,23 +9,11 @@ call "%PATH_MSVC90%\VC\bin\vcvars32.bat" call "%PATH_QTMSVC%\bin\qtvars.bat" REM ----------------------------------------------------------------- msbuild.exe /property:Configuration=%~n2 /target:Clean /verbosity:d %1 -if exist "%~d1%~p1bin\%~n2\*.exe" ( - echo. - echo CLEANUP HAS FAILED! - echo. - GOTO:EOF -) -if exist "%~d1%~p1obj\%~n2\*.obj" ( - echo. - echo CLEANUP HAS FAILED! - echo. - GOTO:EOF -) +if exist "%~d1%~p1bin\%~n2\*.exe" GOTO:EOF +if exist "%~d1%~p1obj\%~n2\*.obj" GOTO:EOF echo ---------------------------------------------------------------- msbuild.exe /property:Configuration=%~n2 /target:Rebuild /verbosity:d %1 echo ---------------------------------------------------------------- -if not exist "%~d1%~p1bin\%~n2\%~n1.exe" ( - echo BUILD HAS FAILED! - exit -) -set "LAMEXP_BUILD_SUCCESS=YES" +if not exist "%~d1%~p1bin\%~n2\%~n1.exe" GOTO:EOF +REM ----------------------------------------------------------------- +set "LAMEXP_ERROR=0" diff --git a/etc/Deployment/_error.bat b/etc/Deployment/_error.bat new file mode 100644 index 00000000..8e457dee --- /dev/null +++ b/etc/Deployment/_error.bat @@ -0,0 +1,5 @@ +@echo off +echo. +echo %~n1%~x1 !!! +echo. +pause diff --git a/etc/Deployment/_version.bat b/etc/Deployment/_version.bat new file mode 100644 index 00000000..1d5a145d --- /dev/null +++ b/etc/Deployment/_version.bat @@ -0,0 +1,29 @@ +@echo off +set "LAMEXP_ERROR=1" +REM ------------------------------------------ +set "VER_LAMEXP_MAJOR=" +set "VER_LAMEXP_MINOR_HI=" +set "VER_LAMEXP_MINOR_LO=" +set "VER_LAMEXP_BUILD=" +set "VER_LAMEXP_SUFFIX=" +REM ------------------------------------------ +FOR /F "tokens=2,3" %%s IN (..\..\src\Resource.h) DO ( + if "%%s"=="VER_LAMEXP_MAJOR" set "VER_LAMEXP_MAJOR=%%t" + if "%%s"=="VER_LAMEXP_MINOR_HI" set "VER_LAMEXP_MINOR_HI=%%t" + if "%%s"=="VER_LAMEXP_MINOR_LO" set "VER_LAMEXP_MINOR_LO=%%t" + if "%%s"=="VER_LAMEXP_BUILD" set "VER_LAMEXP_BUILD=%%t" + if "%%s"=="VER_LAMEXP_SUFFIX" set "VER_LAMEXP_SUFFIX=%%t" +) +REM ------------------------------------------ +set "LAMEXP_ERROR=1" +if "%VER_LAMEXP_MAJOR%"=="" GOTO:EOF +if "%VER_LAMEXP_MINOR_HI%"=="" GOTO:EOF +if "%VER_LAMEXP_MINOR_LO%"=="" GOTO:EOF +if "%VER_LAMEXP_BUILD%"=="" GOTO:EOF +if "%VER_LAMEXP_SUFFIX%"=="" GOTO:EOF +REM ------------------------------------------ +echo LameXP Version: +echo %VER_LAMEXP_MAJOR%.%VER_LAMEXP_MINOR_HI%%VER_LAMEXP_MINOR_LO%, Build #%VER_LAMEXP_BUILD% (%VER_LAMEXP_SUFFIX%) +echo. +REM ------------------------------------------ +set "LAMEXP_ERROR=0" diff --git a/etc/Deployment/release.bat b/etc/Deployment/release.bat index f18074a7..97c6937a 100644 --- a/etc/Deployment/release.bat +++ b/etc/Deployment/release.bat @@ -6,44 +6,29 @@ set "OUT_DATE=%DATE:~6,4%-%DATE:~3,2%-%DATE:~0,2%" set "OUT_FILE=%OUT_PATH%\..\LameXP.%OUT_DATE%.Release" set "TMP_PATH=%TEMP%\~LameXP.%OUT_DATE%.tmp" REM ------------------------------------------ -set "VER_LAMEXP_MAJOR=X" -set "VER_LAMEXP_MINOR_HI=X" -set "VER_LAMEXP_MINOR_LO=X" -set "VER_LAMEXP_BUILD=X" -set "VER_LAMEXP_SUFFIX=X" -REM ------------------------------------------ -FOR /F "tokens=2,3" %%s IN (..\..\src\Resource.h) DO ( - if "%%s"=="VER_LAMEXP_MAJOR" set "VER_LAMEXP_MAJOR=%%t" - if "%%s"=="VER_LAMEXP_MINOR_HI" set "VER_LAMEXP_MINOR_HI=%%t" - if "%%s"=="VER_LAMEXP_MINOR_LO" set "VER_LAMEXP_MINOR_LO=%%t" - if "%%s"=="VER_LAMEXP_BUILD" set "VER_LAMEXP_BUILD=%%t" - if "%%s"=="VER_LAMEXP_SUFFIX" set "VER_LAMEXP_SUFFIX=%%t" +call _version.bat +if not "%LAMEXP_ERROR%"=="0" ( + call _error.bat "FAILD TO READ VERSION INFO!" + GOTO:EOF ) REM ------------------------------------------ -echo Version: %VER_LAMEXP_MAJOR%.%VER_LAMEXP_MINOR_HI%%VER_LAMEXP_MINOR_LO%, Build #%VER_LAMEXP_BUILD% (%VER_LAMEXP_SUFFIX%) -REM ------------------------------------------ del "%OUT_FILE%.exe" del "%OUT_FILE%.zip" if exist "%OUT_FILE%.exe" ( - echo BUILD HAS FAILED !!! - pause - exit + call _error.bat "FAILD TO DELET EXISTING FILE" + GOTO:EOF ) if exist "%OUT_FILE%.zip" ( - echo BUILD HAS FAILED !!! - pause - exit + call _error.bat "FAILD TO DELET EXISTING FILE" + GOTO:EOF ) REM ------------------------------------------ call _build.bat "..\..\LameXP.sln" Release -REM ------------------------------------------ -if not "%LAMEXP_BUILD_SUCCESS%"=="YES" ( - echo. - echo BUILD HAS FAILED !!! - echo. - pause - exit +if not "%LAMEXP_ERROR%"=="0" ( + call _error.bat "BUILD HAS FAILED" + GOTO:EOF ) + REM ------------------------------------------ rd /S /Q "%TMP_PATH%" mkdir "%TMP_PATH%" @@ -70,4 +55,17 @@ REM ------------------------------------------ "%PATH_MKNSIS%" "/DLAMEXP_SOURCE_PATH=%TMP_PATH%" "/DLAMEXP_OUTPUT_FILE=%OUT_FILE%.exe" "/DLAMEXP_DATE=%OUT_DATE%" "/DLAMEXP_VERSION=%VER_LAMEXP_MAJOR%.%VER_LAMEXP_MINOR_HI%%VER_LAMEXP_MINOR_LO%" "/DLAMEXP_BUILD=%VER_LAMEXP_BUILD%" "/DLAMEXP_SUFFIX=%VER_LAMEXP_SUFFIX%" "..\NSIS\setup.nsi" rd /S /Q "%TMP_PATH%" REM ------------------------------------------ +if not exist "%OUT_FILE%.zip" ( + call _error.bat "PACKAGING HAS FAILED" + GOTO:EOF +) +if not exist "%OUT_FILE%.exe" ( + call _error.bat "PACKAGING HAS FAILED" + GOTO:EOF +) +REM ------------------------------------------ +echo. +echo BUIDL COMPLETED SUCCESSFULLY :-) +echo. +REM ------------------------------------------ pause diff --git a/etc/NSIS/setup.nsi b/etc/NSIS/setup.nsi index 348c3ef5..9dc65d7e 100644 --- a/etc/NSIS/setup.nsi +++ b/etc/NSIS/setup.nsi @@ -1,8 +1,9 @@ -!define ZIP2EXE_NAME `LameXP v${LAMEXP_VERSION} ${LAMEXP_SUFFIX}, Build #${LAMEXP_BUILD} [${LAMEXP_DATE}]` +!define ZIP2EXE_NAME `LameXP v${LAMEXP_VERSION} ${LAMEXP_SUFFIX} [Build #${LAMEXP_BUILD}]` !define ZIP2EXE_OUTFILE `${LAMEXP_OUTPUT_FILE}` !define ZIP2EXE_COMPRESSOR_LZMA !define ZIP2EXE_COMPRESSOR_SOLID !define ZIP2EXE_INSTALLDIR `$PROGRAMFILES\${ZIP2EXE_NAME}` +BrandingText `Date created: ${LAMEXP_DATE}` !include `${NSISDIR}\Contrib\zip2exe\Base.nsh` !include `${NSISDIR}\Contrib\zip2exe\Modern.nsh` !insertmacro SECTION_BEGIN