Skip to content

Commit 6120484

Browse files
authored
bpo-27593: Updates Windows build to use information from git (#262) (#448)
* bpo-27593: Updates Windows build to use information from git (#262) * bpo-27593: Updates Windows build to use information from git * Fixes git command (#451)
1 parent f9a6516 commit 6120484

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

Demo/turtle/tdemo_two_canvases.py

100644100755
File mode changed.

PCbuild/build.bat

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ if "%platf%"=="x64" (
104104
)
105105
)
106106

107+
if not exist "%GIT%" where git > "%TEMP%\git.loc" 2> nul && set /P GIT= < "%TEMP%\git.loc" & del "%TEMP%\git.loc"
108+
if exist "%GIT%" set GITProperty=/p:GIT="%GIT%"
109+
if not exist "%GIT%" echo Cannot find Git on PATH & set GITProperty=
110+
107111
rem Setup the environment
108112
call "%dir%env.bat" %vs_platf% >nul
109113

@@ -140,7 +144,7 @@ msbuild "%dir%pcbuild.proj" /t:%target% %parallel% %verbose%^
140144
/p:Configuration=%conf% /p:Platform=%platf%^
141145
/p:IncludeExternals=%IncludeExternals%^
142146
/p:IncludeSSL=%IncludeSSL% /p:IncludeTkinter=%IncludeTkinter%^
143-
/p:IncludeBsddb=%IncludeBsddb%^
147+
/p:IncludeBsddb=%IncludeBsddb% %GITProperty%^
144148
%1 %2 %3 %4 %5 %6 %7 %8 %9
145149

146150
@echo off

PCbuild/pythoncore.vcxproj

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -391,17 +391,25 @@
391391
<ImportGroup Label="ExtensionTargets">
392392
</ImportGroup>
393393
<Target Name="_GetBuildInfo" BeforeTargets="PrepareForBuild">
394-
<Exec Command="hg id -b &gt; &quot;$(IntDir)hgbranch.txt&quot;" ContinueOnError="true" />
395-
<Exec Command="hg id -i &gt; &quot;$(IntDir)hgversion.txt&quot;" ContinueOnError="true" />
396-
<Exec Command="hg id -t &gt; &quot;$(IntDir)hgtag.txt&quot;" ContinueOnError="true" />
397394
<PropertyGroup>
398-
<HgBranch Condition="Exists('$(IntDir)hgbranch.txt')">$([System.IO.File]::ReadAllText('$(IntDir)hgbranch.txt').Trim())</HgBranch>
399-
<HgVersion Condition="Exists('$(IntDir)hgversion.txt')">$([System.IO.File]::ReadAllText('$(IntDir)hgversion.txt').Trim())</HgVersion>
400-
<HgTag Condition="Exists('$(IntDir)hgtag.txt')">$([System.IO.File]::ReadAllText('$(IntDir)hgtag.txt').Trim())</HgTag>
395+
<GIT Condition="$(GIT) == ''">git</GIT>
396+
<_GIT>$(GIT)</_GIT>
397+
<_GIT Condition="$(GIT.Contains(` `))">"$(GIT)"</_GIT>
401398
</PropertyGroup>
399+
<Message Text="Getting build info from $(_GIT)" Importance="high" />
400+
<MakeDir Directories="$(IntDir)" Condition="!Exists($(IntDir))" />
401+
<Exec Command="$(_GIT) name-rev --name-only HEAD &gt; &quot;$(IntDir)gitbranch.txt&quot;" ContinueOnError="true" />
402+
<Exec Command="$(_GIT) rev-parse HEAD &gt; &quot;$(IntDir)gitversion.txt&quot;" ContinueOnError="true" />
403+
<Exec Command="$(_GIT) name-rev --tags --name-only HEAD &gt; &quot;$(IntDir)gittag.txt&quot;" ContinueOnError="true" />
404+
<PropertyGroup>
405+
<GitBranch Condition="Exists('$(IntDir)gitbranch.txt')">$([System.IO.File]::ReadAllText('$(IntDir)gitbranch.txt').Trim())</GitBranch>
406+
<GitVersion Condition="Exists('$(IntDir)gitversion.txt')">$([System.IO.File]::ReadAllText('$(IntDir)gitversion.txt').Trim())</GitVersion>
407+
<GitTag Condition="Exists('$(IntDir)gittag.txt')">$([System.IO.File]::ReadAllText('$(IntDir)gittag.txt').Trim())</GitTag>
408+
</PropertyGroup>
409+
<Message Text="Building $(GitTag):$(GitVersion) $(GitBranch)" Importance="high" />
402410
<ItemGroup>
403411
<ClCompile Include="..\Modules\getbuildinfo.c">
404-
<PreprocessorDefinitions>HGVERSION="$(HgVersion)";HGTAG="$(HgTag)";HGBRANCH="$(HgBranch)";%(PreprocessorDefinitions)</PreprocessorDefinitions>
412+
<PreprocessorDefinitions>GITVERSION="$(GitVersion)";GITTAG="$(GitTag)";GITBRANCH="$(GitBranch)";%(PreprocessorDefinitions)</PreprocessorDefinitions>
405413
</ClCompile>
406414
</ItemGroup>
407415
</Target>

0 commit comments

Comments
 (0)