rainmeter-studio/Build/Build.bat

170 lines
6.5 KiB
Batchfile
Raw Normal View History

2012-03-14 19:18:19 +00:00
@echo off
setlocal EnableDelayedExpansion
2012-12-22 13:56:10 +00:00
set VCVARSALL=%VS110COMNTOOLS%..\..\VC\vcvarsall.bat
2012-03-14 19:18:19 +00:00
set MAKENSIS=%PROGRAMFILES%\NSIS\MakeNSIS.exe
set GIT=%PROGRAMFILES%\Git\bin\git.exe
2012-06-27 10:13:14 +00:00
:: Set VERSION_REVISION to non-zero value to override
2013-03-25 13:41:11 +00:00
set VERSION_MAJOR=3
set VERSION_MINOR=0
2012-06-27 10:13:14 +00:00
set VERSION_SUBMINOR=0
set VERSION_REVISION=0
2012-03-31 12:27:06 +00:00
set ISBETA=true
2012-03-14 19:18:19 +00:00
2012-03-31 12:27:06 +00:00
if "%1" == "RELEASE" set ISBETA=false
2012-03-14 19:18:19 +00:00
if "%1" == "BUILDVERSION" goto BUILDVERSION
echo Rainmeter Build
echo ----------------------------------------------
echo.
if not exist "%VCVARSALL%" echo ERROR: vcvarsall.bat not found & goto END
call "%VCVARSALL%" x86 > nul
2012-12-22 14:08:53 +00:00
set MSBUILD="msbuild.exe" /p:PlatformToolset=v110_xp;VisualStudioVersion=11.0
2012-12-22 12:58:59 +00:00
2012-12-22 13:56:10 +00:00
if exist "Certificate.bat" call "Certificate.bat" > nul
2012-12-22 12:58:59 +00:00
set SIGNTOOL="signtool.exe" sign /t http://time.certum.pl /f "%CERTFILE%" /p "%CERTKEY%"
2012-03-14 19:18:19 +00:00
if "%1" == "BUILDLANGUAGES" goto BUILDLANGUAGES
if exist "%MAKENSIS%" goto NSISFOUND
set MAKENSIS=%MAKENSIS:Program Files\=Program Files (x86)\%
if not exist "%MAKENSIS%" echo ERROR: MakeNSIS.exe not found & goto END
:NSISFOUND
:BUILDVERSION
if not exist "..\.git" goto UPDATEVERSION
2012-06-27 10:13:14 +00:00
if not "%VERSION_REVISION%" == "0" goto UPDATEVERSION
2012-03-14 19:18:19 +00:00
:: git
if exist "%GIT%" goto GITFOUND
set GIT=%GIT:Program Files\=Program Files (x86)\%
if not exist "%GIT%" echo ERROR: git.exe not found & goto END
:GITFOUND
2012-06-27 10:13:14 +00:00
set /a VERSION_REVISION=0
2012-09-19 17:15:00 +00:00
for /f "usebackq delims= " %%G in (`"%GIT%" rev-list --all --count`) do set VERSION_REVISION=%%G
2012-03-14 19:18:19 +00:00
:UPDATEVERSION
2012-06-27 10:13:14 +00:00
set VERSION=%VERSION_MAJOR%.%VERSION_MINOR%.%VERSION_SUBMINOR%.%VERSION_REVISION%
2012-03-14 19:18:19 +00:00
:: Update Version.h
> "..\Version.h" echo #pragma once
2012-06-27 10:15:04 +00:00
>>"..\Version.h" echo #define FILEVER %VERSION_MAJOR%,%VERSION_MINOR%,%VERSION_SUBMINOR%,%VERSION_REVISION%
2012-03-14 19:18:19 +00:00
>>"..\Version.h" echo #define PRODUCTVER FILEVER
2012-06-27 10:13:14 +00:00
>>"..\Version.h" echo #define STRFILEVER "%VERSION%"
2012-03-14 19:18:19 +00:00
>>"..\Version.h" echo #define STRPRODUCTVER STRFILEVER
2012-06-27 10:13:14 +00:00
>>"..\Version.h" echo #define APPVERSION L"%VERSION_MAJOR%.%VERSION_MINOR%.%VERSION_SUBMINOR%"
>>"..\Version.h" echo #define RAINMETER_VERSION ((%VERSION_MAJOR% * 1000000) + (%VERSION_MINOR% * 1000) + %VERSION_SUBMINOR%)
>>"..\Version.h" echo const int revision_number = %VERSION_REVISION%;
2012-03-14 19:18:19 +00:00
>>"..\Version.h" echo const bool revision_beta = %ISBETA%;
:: Update Version.cs
> "..\Version.cs" echo namespace Rainmeter
>>"..\Version.cs" echo {
>>"..\Version.cs" echo public class Version
>>"..\Version.cs" echo {
>>"..\Version.cs" echo #if X64
2012-06-27 10:13:14 +00:00
>>"..\Version.cs" echo public const string Informational = "%VERSION% (64-bit)";
2012-03-14 19:18:19 +00:00
>>"..\Version.cs" echo #else
2012-06-27 10:13:14 +00:00
>>"..\Version.cs" echo public const string Informational = "%VERSION% (32-bit)";
2012-03-14 19:18:19 +00:00
>>"..\Version.cs" echo #endif
>>"..\Version.cs" echo }
>>"..\Version.cs" echo }
if "%1" == "BUILDVERSION" goto :eof
echo * Updated Version.h
:: Set vcbuild environment variables and begin build
2012-06-27 10:13:14 +00:00
echo * Starting build for %VERSION%
2013-06-08 10:23:19 +00:00
for /F "tokens=1-4 delims=:.," %%a in ("%TIME%") do (
2013-06-12 20:08:45 +00:00
set /A "BUILD_BEGIN_TIMESTAMP=(((%%a * 60) + 1%%b %% 100)* 60 + 1%%c %% 100) * 100 + 1%%d %% 100"
2013-06-08 10:23:19 +00:00
)
2012-03-14 19:18:19 +00:00
:: Build Library
echo * Building 32-bit projects
2012-12-22 12:58:59 +00:00
%MSBUILD% /t:rebuild /p:Configuration=Release;Platform=Win32 /v:q /m ..\Rainmeter.sln > "BuildLog.txt"
2012-03-14 19:18:19 +00:00
if not %ERRORLEVEL% == 0 echo ERROR %ERRORLEVEL%: Build failed & goto END
echo * Building 64-bit projects
2012-12-22 12:58:59 +00:00
%MSBUILD% /t:rebuild /p:Configuration=Release;Platform=x64 /v:q /m ..\Rainmeter.sln > "BuildLog.txt"
2012-03-14 19:18:19 +00:00
if not %ERRORLEVEL% == 0 echo ERROR %ERRORLEVEL%: Build failed & goto END
:BUILDLANGUAGES
echo * Building languages
:: Build all language libraries
>".\Installer\Languages.nsh" echo.
for /f "tokens=1,2,3 delims=," %%a in (..\Language\List) do (
> "..\Language\Language.rc" echo #include "%%a.h"
>>"..\Language\Language.rc" echo #include "Resource.rc"
2012-04-28 17:39:58 +00:00
>>".\Installer\Languages.nsh" echo ${IncludeLanguage} "%%b" "%%a"
set LANGUAGES='%%a - ${LANGFILE_%%b_NAME}' '${LANG_%%b}' '${LANG_%%b_CP}' !LANGUAGES!
2012-04-28 17:40:45 +00:00
2012-12-22 12:58:59 +00:00
%MSBUILD% /t:Language /p:Configuration=Release;Platform=Win32;TargetName=%%c /v:q ..\Rainmeter.sln > "BuildLog.txt"
2012-04-28 17:40:45 +00:00
if not %ERRORLEVEL% == 0 echo ERROR: Building language %%a failed & goto END
2012-03-14 19:18:19 +00:00
)
2012-04-28 17:39:58 +00:00
>>".\Installer\Languages.nsh" echo ^^!define LANGUAGES "%LANGUAGES%"
2012-03-14 19:18:19 +00:00
:: Restore English
echo #include "English.h"> "..\Language\Language.rc"
echo #include "Resource.rc">> "..\Language\Language.rc"
if "%1" == "BUILDLANGUAGES" (
xcopy /Q /S /Y ..\TestBench\x32\Release\Languages\*.dll ..\TestBench\x64\Release\Languages\ > nul
xcopy /Q /S /Y ..\TestBench\x32\Release\Languages\*.dll ..\TestBench\x32\Debug\Languages\ > nul
xcopy /Q /S /Y ..\TestBench\x32\Release\Languages\*.dll ..\TestBench\x64\Debug\Languages\ > nul
if exist "BuildLog.txt" del "BuildLog.txt"
goto END
)
:: Sign binaries
if not "%CERTFILE%" == "" (
echo * Signing binaries
for %%Z in (Rainmeter.dll Rainmeter.exe SkinInstaller.exe) do (
%SIGNTOOL% ..\TestBench\x32\Release\%%Z > BuildLog.txt
if not %ERRORLEVEL% == 0 echo ERROR %ERRORLEVEL%: Signing x32\%%Z failed & goto END
%SIGNTOOL% ..\TestBench\x64\Release\%%Z > BuildLog.txt
if not %ERRORLEVEL% == 0 echo ERROR %ERRORLEVEL%: Signing x64\%%Z failed & goto END
)
)
:: Build installer
echo * Building installer
2012-06-27 10:13:14 +00:00
set INSTALLER_VERSION=%VERSION_MAJOR%.%VERSION_MINOR%
if not "%VERSION_SUBMINOR%" == "0" set INSTALLER_VERSION=!INSTALLER_VERSION!.%VERSION_SUBMINOR%
2012-03-14 19:18:19 +00:00
if "%1" == "RELEASE" (
2012-06-27 10:13:14 +00:00
"%MAKENSIS%" /DREV="%VERSION_REVISION%" /DVER="%INSTALLER_VERSION%" .\Installer\Installer.nsi > "BuildLog.txt"
2012-03-14 19:18:19 +00:00
) else (
2012-06-27 10:13:14 +00:00
"%MAKENSIS%" /DBETA /DREV="%VERSION_REVISION%" /DVER="%INSTALLER_VERSION%" .\Installer\Installer.nsi > "BuildLog.txt"
2012-03-14 19:18:19 +00:00
)
if not %ERRORLEVEL% == 0 echo ERROR %ERRORLEVEL%: Building installer failed & goto END
:: Sign installer
if not "%CERTFILE%" == "" (
echo * Signing installer
if "%1" == "RELEASE" (
2012-06-27 10:13:14 +00:00
%SIGNTOOL% Rainmeter-%INSTALLER_VERSION%.exe > BuildLog.txt
2012-03-14 19:18:19 +00:00
) else (
2012-06-27 10:13:14 +00:00
%SIGNTOOL% Rainmeter-%INSTALLER_VERSION%-r%VERSION_REVISION%-beta.exe > BuildLog.txt
2012-03-14 19:18:19 +00:00
)
if not %ERRORLEVEL% == 0 echo ERROR %ERRORLEVEL%: Signing installer failed & goto END
)
:: If we got here, build was successful so delete BuildLog.txt
if exist "BuildLog.txt" del "BuildLog.txt"
2013-06-08 10:23:19 +00:00
for /F "tokens=1-4 delims=:.," %%a in ("%TIME%") do (
2013-06-12 20:08:45 +00:00
set /A "BUILD_END_TIMESTAMP=(((%%a * 60) + 1%%b %% 100)* 60 + %%c %% 100) * 100 + 1%%d %% 100"
2013-06-08 10:23:19 +00:00
)
set /A "BUILD_ELAPSED_TIME=(%BUILD_END_TIMESTAMP% - %BUILD_BEGIN_TIMESTAMP%) / 100"
echo * Build complete. Elapsed time: %BUILD_ELAPSED_TIME% sec
2012-03-14 19:18:19 +00:00
:END
if exist ".\Installer\Languages.nsh" del ".\Installer\Languages.nsh"
echo.
pause