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
|
2013-10-25 14:36:53 +00:00
|
|
|
set VERSION_MINOR=1
|
|
|
|
set VERSION_SUBMINOR=0
|
2013-10-19 14:18:02 +00:00
|
|
|
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
|
2013-06-13 19:14:57 +00:00
|
|
|
set MSBUILD="msbuild.exe" /nologo /p:PlatformToolset=v110_xp;VisualStudioVersion=11.0;ExcludeTests=true
|
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
|
|
|
|
|
2013-10-20 14:14:39 +00:00
|
|
|
set VERSION_FULL=%VERSION_MAJOR%.%VERSION_MINOR%.%VERSION_SUBMINOR%.%VERSION_REVISION%
|
|
|
|
set VERSION_SHORT=%VERSION_MAJOR%.%VERSION_MINOR%
|
|
|
|
if not "%VERSION_SUBMINOR%" == "0" set VERSION_SHORT=!VERSION_SHORT!.%VERSION_SUBMINOR%
|
|
|
|
|
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
|
2013-10-19 13:15:20 +00:00
|
|
|
>>"..\Version.h" echo #define STRFILEVER "%VERSION_FULL%"
|
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
|
2013-10-19 13:15:20 +00:00
|
|
|
>>"..\Version.cs" echo public const string Informational = "%VERSION_FULL% (64-bit)";
|
2012-03-14 19:18:19 +00:00
|
|
|
>>"..\Version.cs" echo #else
|
2013-10-19 13:15:20 +00:00
|
|
|
>>"..\Version.cs" echo public const string Informational = "%VERSION_FULL% (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
|
2013-10-20 14:14:39 +00:00
|
|
|
echo * Starting build for %VERSION_FULL%
|
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
|
|
|
|
2013-10-19 14:18:02 +00:00
|
|
|
:: Build Library
|
|
|
|
echo * Building 32-bit projects
|
|
|
|
%MSBUILD% /t:rebuild /p:Configuration=Release;Platform=Win32 /v:q /m ..\Rainmeter.sln > "BuildLog.txt"
|
|
|
|
if not %ERRORLEVEL% == 0 echo ERROR %ERRORLEVEL%: Build failed & goto END
|
|
|
|
|
|
|
|
echo * Building 64-bit projects
|
|
|
|
%MSBUILD% /t:rebuild /p:Configuration=Release;Platform=x64 /v:q /m ..\Rainmeter.sln > "BuildLog.txt"
|
|
|
|
if not %ERRORLEVEL% == 0 echo ERROR %ERRORLEVEL%: Build failed & goto END
|
|
|
|
|
2012-03-14 19:18:19 +00:00
|
|
|
: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"
|
2013-10-17 06:32:53 +00:00
|
|
|
set LANGDLL_PARAMS='%%a - ${LANGFILE_%%b_NAME}' '${LANG_%%b}' '${LANG_%%b_CP}' !LANGDLL_PARAMS!
|
|
|
|
set LANGUAGE_IDS=${LANG_%%b},!LANGUAGE_IDS!
|
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
|
|
|
)
|
2013-10-17 06:32:53 +00:00
|
|
|
>>".\Installer\Languages.nsh" echo ^^!define LANGDLL_PARAMS "%LANGDLL_PARAMS%"
|
|
|
|
>>".\Installer\Languages.nsh" echo ^^!define LANGUAGE_IDS "%LANGUAGE_IDS%"
|
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" (
|
2013-10-20 12:30:53 +00:00
|
|
|
xcopy /Q /S /Y ..\x32-Release\Languages\*.dll ..\x64-Release\Languages\ > nul
|
|
|
|
xcopy /Q /S /Y ..\x32-Release\Release\Languages\*.dll ..\x32-Debug\Languages\ > nul
|
|
|
|
xcopy /Q /S /Y ..\x32-Release\Release\Languages\*.dll ..\x64-Debug\Languages\ > nul
|
2012-03-14 19:18:19 +00:00
|
|
|
if exist "BuildLog.txt" del "BuildLog.txt"
|
|
|
|
goto END
|
|
|
|
)
|
|
|
|
|
|
|
|
:: Sign binaries
|
|
|
|
if not "%CERTFILE%" == "" (
|
|
|
|
echo * Signing binaries
|
2013-10-20 09:28:59 +00:00
|
|
|
for %%Z in (Rainmeter.dll Rainmeter.exe SkinInstaller.exe SkinInstaller.dll) do (
|
2013-10-20 12:30:53 +00:00
|
|
|
%SIGNTOOL% ..\x32-Release\%%Z > BuildLog.txt
|
2012-03-14 19:18:19 +00:00
|
|
|
if not %ERRORLEVEL% == 0 echo ERROR %ERRORLEVEL%: Signing x32\%%Z failed & goto END
|
2013-10-20 12:30:53 +00:00
|
|
|
%SIGNTOOL% ..\x64-Release\%%Z > BuildLog.txt
|
2012-03-14 19:18:19 +00:00
|
|
|
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
|
|
|
|
2013-10-19 13:15:20 +00:00
|
|
|
set INSTALLER_NAME=Rainmeter-%VERSION_SHORT%.exe
|
|
|
|
if not "%1" == "RELEASE" set INSTALLER_NAME=Rainmeter-%VERSION_SHORT%-r%VERSION_REVISION%-beta.exe
|
2012-06-27 10:13:14 +00:00
|
|
|
|
2013-10-19 13:15:20 +00:00
|
|
|
set INSTALLER_DEFINES=^
|
|
|
|
/DOUTFILE="%INSTALLER_NAME%"^
|
|
|
|
/DVERSION_FULL="%VERSION_FULL%"^
|
|
|
|
/DVERSION_SHORT="%VERSION_SHORT%"^
|
|
|
|
/DVERSION_REVISION="%VERSION_REVISION%"
|
|
|
|
if not "%1" == "RELEASE" set INSTALLER_DEFINES=!INSTALLER_DEFINES! /DBETA
|
|
|
|
|
|
|
|
"%MAKENSIS%" %INSTALLER_DEFINES% .\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
|
2013-10-19 13:15:20 +00:00
|
|
|
%SIGNTOOL% %INSTALLER_NAME% > 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
|