Skip to content

Commit d3e1e9d

Browse files
authored
bpo-27593: Updates Windows build to use information from git (#262) (#450)
* bpo-27593: Updates Windows build to use information from git
1 parent 226af23 commit d3e1e9d

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

PCbuild/build.bat

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ if "%platf%"=="x64" (
105105
)
106106
)
107107

108-
if not exist "%HG%" where hg > "%TEMP%\hg.loc" 2> nul && set /P HG= < "%TEMP%\hg.loc" & del "%TEMP%\hg.loc"
109-
if exist "%HG%" set HGProperty=/p:HG="%HG%"
110-
if not exist "%HG%" echo Cannot find Mercurial on PATH & set HGProperty=
108+
if not exist "%GIT%" where git > "%TEMP%\git.loc" 2> nul && set /P GIT= < "%TEMP%\git.loc" & del "%TEMP%\git.loc"
109+
if exist "%GIT%" set GITProperty=/p:GIT="%GIT%"
110+
if not exist "%GIT%" echo Cannot find Git on PATH & set GITProperty=
111111

112112
rem Setup the environment
113113
call "%dir%env.bat" %vs_platf% >nul
@@ -145,7 +145,7 @@ msbuild "%dir%pcbuild.proj" /t:%target% %parallel% %verbose%^
145145
/p:Configuration=%conf% /p:Platform=%platf%^
146146
/p:IncludeExternals=%IncludeExternals%^
147147
/p:IncludeSSL=%IncludeSSL% /p:IncludeTkinter=%IncludeTkinter%^
148-
/p:UseTestMarker=%UseTestMarker% %HGProperty%^
148+
/p:UseTestMarker=%UseTestMarker% %GITProperty%^
149149
%1 %2 %3 %4 %5 %6 %7 %8 %9
150150

151151
@echo off

PCbuild/pythoncore.vcxproj

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -407,24 +407,24 @@
407407
</ImportGroup>
408408
<Target Name="_GetBuildInfo" BeforeTargets="PrepareForBuild">
409409
<PropertyGroup>
410-
<HG Condition="$(HG) == ''">hg</HG>
411-
<_HG>$(HG)</_HG>
412-
<_HG Condition="$(HG.Contains(` `))">"$(HG)"</_HG>
410+
<GIT Condition="$(GIT) == ''">git</GIT>
411+
<_GIT>$(GIT)</_GIT>
412+
<_GIT Condition="$(GIT.Contains(` `))">"$(GIT)"</_GIT>
413413
</PropertyGroup>
414-
<Message Text="Getting build info from $(_HG)" Importance="high" />
414+
<Message Text="Getting build info from $(_GIT)" Importance="high" />
415415
<MakeDir Directories="$(IntDir)" Condition="!Exists($(IntDir))" />
416-
<Exec Command="$(_HG) id -b &gt; &quot;$(IntDir)hgbranch.txt&quot;" ContinueOnError="true" />
417-
<Exec Command="$(_HG) id -i &gt; &quot;$(IntDir)hgversion.txt&quot;" ContinueOnError="true" />
418-
<Exec Command="$(_HG) id -t &gt; &quot;$(IntDir)hgtag.txt&quot;" ContinueOnError="true" />
416+
<Exec Command="$(_GIT) name-rev --name-only HEAD &gt; &quot;$(IntDir)gitbranch.txt&quot;" ContinueOnError="true" />
417+
<Exec Command="$(_GIT) rev-parse HEAD &gt; &quot;$(IntDir)gitversion.txt&quot;" ContinueOnError="true" />
418+
<Exec Command="$(_GIT) name-rev --tags --name id -t &gt; &quot;$(IntDir)gittag.txt&quot;" ContinueOnError="true" />
419419
<PropertyGroup>
420-
<HgBranch Condition="Exists('$(IntDir)hgbranch.txt')">$([System.IO.File]::ReadAllText('$(IntDir)hgbranch.txt').Trim())</HgBranch>
421-
<HgVersion Condition="Exists('$(IntDir)hgversion.txt')">$([System.IO.File]::ReadAllText('$(IntDir)hgversion.txt').Trim())</HgVersion>
422-
<HgTag Condition="Exists('$(IntDir)hgtag.txt')">$([System.IO.File]::ReadAllText('$(IntDir)hgtag.txt').Trim())</HgTag>
420+
<GitBranch Condition="Exists('$(IntDir)gitbranch.txt')">$([System.IO.File]::ReadAllText('$(IntDir)gitbranch.txt').Trim())</GitBranch>
421+
<GitVersion Condition="Exists('$(IntDir)gitversion.txt')">$([System.IO.File]::ReadAllText('$(IntDir)gitversion.txt').Trim())</GitVersion>
422+
<GitTag Condition="Exists('$(IntDir)gittag.txt')">$([System.IO.File]::ReadAllText('$(IntDir)gittag.txt').Trim())</GitTag>
423423
</PropertyGroup>
424-
<Message Text="Building $(HgTag):$(HgVersion) $(HgBranch)" Importance="high" />
424+
<Message Text="Building $(GitTag):$(GitVersion) $(GitBranch)" Importance="high" />
425425
<ItemGroup>
426426
<ClCompile Include="..\Modules\getbuildinfo.c">
427-
<PreprocessorDefinitions>HGVERSION="$(HgVersion)";HGTAG="$(HgTag)";HGBRANCH="$(HgBranch)";%(PreprocessorDefinitions)</PreprocessorDefinitions>
427+
<PreprocessorDefinitions>GITVERSION="$(GitVersion)";GITTAG="$(GitTag)";GITBRANCH="$(GitBranch)";%(PreprocessorDefinitions)</PreprocessorDefinitions>
428428
</ClCompile>
429429
</ItemGroup>
430430
</Target>

Tools/msi/buildrelease.bat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ if "%1" NEQ "" echo Invalid option: "%1" && exit /B 1
6565

6666
if not defined BUILDX86 if not defined BUILDX64 (set BUILDX86=1) && (set BUILDX64=1)
6767

68-
if not exist "%HG%" where hg > "%TEMP%\hg.loc" 2> nul && set /P HG= < "%TEMP%\hg.loc" & del "%TEMP%\hg.loc"
69-
if not exist "%HG%" echo Cannot find Mercurial on PATH && exit /B 1
68+
if not exist "%GIT%" where git > "%TEMP%\git.loc" 2> nul && set /P GIT= < "%TEMP%\git.loc" & del "%TEMP%\git.loc"
69+
if not exist "%GIT%" echo Cannot find Git on PATH && exit /B 1
7070

7171
call "%D%get_externals.bat"
7272

0 commit comments

Comments
 (0)