bpo-27593: Updates Windows build to use information from git (#262) (#450)
* bpo-27593: Updates Windows build to use information from git
diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj
index 6b23d8e..8f8bede 100644
--- a/PCbuild/pythoncore.vcxproj
+++ b/PCbuild/pythoncore.vcxproj
@@ -407,24 +407,24 @@
</ImportGroup>
<Target Name="_GetBuildInfo" BeforeTargets="PrepareForBuild">
<PropertyGroup>
- <HG Condition="$(HG) == ''">hg</HG>
- <_HG>$(HG)</_HG>
- <_HG Condition="$(HG.Contains(` `))">"$(HG)"</_HG>
+ <GIT Condition="$(GIT) == ''">git</GIT>
+ <_GIT>$(GIT)</_GIT>
+ <_GIT Condition="$(GIT.Contains(` `))">"$(GIT)"</_GIT>
</PropertyGroup>
- <Message Text="Getting build info from $(_HG)" Importance="high" />
+ <Message Text="Getting build info from $(_GIT)" Importance="high" />
<MakeDir Directories="$(IntDir)" Condition="!Exists($(IntDir))" />
- <Exec Command="$(_HG) id -b > "$(IntDir)hgbranch.txt"" ContinueOnError="true" />
- <Exec Command="$(_HG) id -i > "$(IntDir)hgversion.txt"" ContinueOnError="true" />
- <Exec Command="$(_HG) id -t > "$(IntDir)hgtag.txt"" ContinueOnError="true" />
+ <Exec Command="$(_GIT) name-rev --name-only HEAD > "$(IntDir)gitbranch.txt"" ContinueOnError="true" />
+ <Exec Command="$(_GIT) rev-parse HEAD > "$(IntDir)gitversion.txt"" ContinueOnError="true" />
+ <Exec Command="$(_GIT) name-rev --tags --name id -t > "$(IntDir)gittag.txt"" ContinueOnError="true" />
<PropertyGroup>
- <HgBranch Condition="Exists('$(IntDir)hgbranch.txt')">$([System.IO.File]::ReadAllText('$(IntDir)hgbranch.txt').Trim())</HgBranch>
- <HgVersion Condition="Exists('$(IntDir)hgversion.txt')">$([System.IO.File]::ReadAllText('$(IntDir)hgversion.txt').Trim())</HgVersion>
- <HgTag Condition="Exists('$(IntDir)hgtag.txt')">$([System.IO.File]::ReadAllText('$(IntDir)hgtag.txt').Trim())</HgTag>
+ <GitBranch Condition="Exists('$(IntDir)gitbranch.txt')">$([System.IO.File]::ReadAllText('$(IntDir)gitbranch.txt').Trim())</GitBranch>
+ <GitVersion Condition="Exists('$(IntDir)gitversion.txt')">$([System.IO.File]::ReadAllText('$(IntDir)gitversion.txt').Trim())</GitVersion>
+ <GitTag Condition="Exists('$(IntDir)gittag.txt')">$([System.IO.File]::ReadAllText('$(IntDir)gittag.txt').Trim())</GitTag>
</PropertyGroup>
- <Message Text="Building $(HgTag):$(HgVersion) $(HgBranch)" Importance="high" />
+ <Message Text="Building $(GitTag):$(GitVersion) $(GitBranch)" Importance="high" />
<ItemGroup>
<ClCompile Include="..\Modules\getbuildinfo.c">
- <PreprocessorDefinitions>HGVERSION="$(HgVersion)";HGTAG="$(HgTag)";HGBRANCH="$(HgBranch)";%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>GITVERSION="$(GitVersion)";GITTAG="$(GitTag)";GITBRANCH="$(GitBranch)";%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemGroup>
</Target>