Add custom step for Windows for git-version.c.

This commit is contained in:
Unknown W. Brackets 2013-03-02 01:31:37 -08:00
parent 13288a5de6
commit 96a22063e3
4 changed files with 81 additions and 0 deletions

1
.gitignore vendored
View File

@ -37,6 +37,7 @@ gen
libs libs
obj obj
build*/ build*/
/git-version.c
.pspsh.hist .pspsh.hist
__testoutput.txt __testoutput.txt

View File

@ -74,6 +74,10 @@
<Link> <Link>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
</Link> </Link>
<PreBuildEvent>
<Command>../Windows/git-version-gen.cmd</Command>
<Message>Updating git-version.c</Message>
</PreBuildEvent>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile> <ClCompile>
@ -87,6 +91,10 @@
<Link> <Link>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
</Link> </Link>
<PreBuildEvent>
<Command>../Windows/git-version-gen.cmd</Command>
<Message>Updating git-version.c</Message>
</PreBuildEvent>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile> <ClCompile>
@ -104,6 +112,11 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
</Link> </Link>
<CustomBuildStep />
<PreBuildEvent>
<Command>../Windows/git-version-gen.cmd</Command>
<Message>Updating git-version.c</Message>
</PreBuildEvent>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile> <ClCompile>
@ -120,11 +133,16 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
</Link> </Link>
<PreBuildEvent>
<Command>../Windows/git-version-gen.cmd</Command>
<Message>Updating git-version.c</Message>
</PreBuildEvent>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\ext\disarm.cpp" /> <ClCompile Include="..\ext\disarm.cpp" />
<ClCompile Include="..\ext\snappy\snappy-c.cpp" /> <ClCompile Include="..\ext\snappy\snappy-c.cpp" />
<ClCompile Include="..\ext\snappy\snappy.cpp" /> <ClCompile Include="..\ext\snappy\snappy.cpp" />
<ClCompile Include="..\git-version.c" />
<ClCompile Include="Config.cpp" /> <ClCompile Include="Config.cpp" />
<ClCompile Include="Core.cpp" /> <ClCompile Include="Core.cpp" />
<ClCompile Include="CoreTiming.cpp" /> <ClCompile Include="CoreTiming.cpp" />

View File

@ -382,6 +382,7 @@
<ClCompile Include="Font\PGF.cpp"> <ClCompile Include="Font\PGF.cpp">
<Filter>Font</Filter> <Filter>Font</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\git-version.c" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="ELF\ElfReader.h"> <ClInclude Include="ELF\ElfReader.h">

View File

@ -0,0 +1,61 @@
@echo off
rem // Copyright (c) 2012- PPSSPP Project.
rem // This program is free software: you can redistribute it and/or modify
rem // it under the terms of the GNU General Public License as published by
rem // the Free Software Foundation, version 2.0 or later versions.
rem // This program is distributed in the hope that it will be useful,
rem // but WITHOUT ANY WARRANTY; without even the implied warranty of
rem // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
rem // GNU General Public License 2.0 for more details.
rem // A copy of the GPL 2.0 should have been included with the program.
rem // If not, see http://www.gnu.org/licenses/
rem // Official git repository and contact information can be found at
rem // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
setlocal
set GIT_VERSION_FILE=%~p0..\git-version.c
if "%GIT%" == "" (
set GIT=git
)
if exist "%GIT_VERSION_FILE%" (
rem // Skip updating the file if PPSSPP_GIT_VERSION_NO_UPDATE is 1.
findstr /B /C:"#define PPSSPP_GIT_VERSION_NO_UPDATE 1" "%GIT_VERSION_FILE%" > NUL
if not errorlevel 1 (
goto done
)
)
"%GIT%" describe --always > NUL 2> NUL
if errorlevel 1 (
echo Unable to update git-version.c, %GIT% not on path.
echo // This is a generated file. > "%GIT_VERSION_FILE%"
echo. >> "%GIT_VERSION_FILE%"
echo const char *PPSSPP_GIT_VERSION = "unknown"; >> "%GIT_VERSION_FILE%"
goto done
)
for /F %%I IN ('"%GIT%" describe --always') do set GIT_VERSION=%%I
rem // Don't modify the file if it already has the current version.
if exist "%GIT_VERSION_FILE%" (
findstr /C:"%GIT_VERSION%" "%GIT_VERSION_FILE%" > NUL
if not errorlevel 1 (
goto done
)
)
echo // This is a generated file. > "%GIT_VERSION_FILE%"
echo. >> "%GIT_VERSION_FILE%"
echo const char *PPSSPP_GIT_VERSION = "%GIT_VERSION%"; >> "%GIT_VERSION_FILE%"
echo. >> "%GIT_VERSION_FILE%"
echo // If you don't want this file to update/recompile, change to 1. >> "%GIT_VERSION_FILE%"
echo #define PPSSPP_GIT_VERSION_NO_UPDATE 0 >> "%GIT_VERSION_FILE%"
:done