Add some build scripts

This commit is contained in:
zilmar 2015-09-13 17:30:59 +10:00
parent b4d58cfb17
commit 897b27fc1d
2 changed files with 97 additions and 0 deletions

View File

@ -0,0 +1,56 @@
@echo off
SETLOCAL
set origdir=%cd%
cd /d %~dp0..\..
set base_dir=%cd%
cd /d %origdir%
if exist "C:\Program Files\Git\usr\bin\sed.exe" ( set SED="C:\Program Files\Git\usr\bin\sed.exe")
if exist "C:\Program Files (x86)\Git\bin\sed.exe" ( set SED="C:\Program Files (x86)\Git\bin\sed.exe")
if %SED% == "" (
echo can not find sed.exe
goto :end
)
SETLOCAL EnableDelayedExpansion
FOR /F "tokens=1 delims=" %%A in ('git describe --tags --long') do SET current_tag=%%A
FOR /F "tokens=1 delims=" %%A in ('echo !current_tag! ^| !sed! "s/v[0-9]*\.[0-9]*-\([0-9]*\).*/\1/"') do SET commits_since_tag=%%A
call :setVersion %base_dir%\Source\Project64\version.h !commits_since_tag!
call :setVersion %base_dir%\Source\nragev20\version.h !commits_since_tag!
call :setVersion %base_dir%\Source\RSP\version.h !commits_since_tag!
call :setVersion %base_dir%\Source\Glide64\version.h !commits_since_tag!
ENDLOCAL
goto :eof
:setVersion
set version_file=%~1
set out_file=%~1.out
set build_no=%~2
if exist "%out_file%" del "%out_file%"
SETLOCAL DisableDelayedExpansion
FOR /F "usebackq delims=" %%a in (`"findstr /n ^^ %version_file%"`) do (
set "line=%%a"
SETLOCAL EnableDelayedExpansion
set "line=!line:9999=%build_no%!"
set "line=!line:*:=!"
echo(!line!>>!out_file!
ENDLOCAL
)
ENDLOCAL
if exist "%out_file%" (
if exist "%version_file%" (
del "%version_file%"
move "%out_file%" "%version_file%"
)
)
goto :eof

41
Source/Script/build.cmd Normal file
View File

@ -0,0 +1,41 @@
@ECHO OFF
SETLOCAL
set BuildMode=Release
if not "%1" == "" set BuildMode=%1
if "%1" == "debug" set BuildMode=Debug
if "%1" == "release" set BuildMode=Release
set MSVC-BUILDER=
set origdir=%cd%
cd /d %~dp0..\..\
set base_dir=%cd%
cd /d %origdir%
if exist "C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe" ( set MSVC-BUILDER="C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe")
if exist "C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe" ( set MSVC-BUILDER="C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe")
if %MSVC-BUILDER% == "" (
echo can not find visual studio 2008
goto :end
)
:: Build Win32 version of the software
IF EXIST "%base_dir%\output.txt" del "%base_dir%\output.txt"
%MSVC-BUILDER% "%base_dir%\Project64.vs2008.sln" /build "%BuildMode%|Win32" /out "%base_dir%\output.txt"
set Result=%ERRORLEVEL%
type "%base_dir%\output.txt"
echo Done - ERRORLEVEL: %Result%
IF %Result% NEQ 0 goto :EndErr
echo Build ok
goto :end
:EndErr
ENDLOCAL
echo Build failed
exit /B 1
:End
ENDLOCAL
exit /B 0