Skip to content

Commit cf445f1

Browse files
authored
bpo-27593: Updates Windows build to use information from git (#262) (#449)
* bpo-27593: Updates Windows build to use information from git
1 parent 4d0630d commit cf445f1

File tree

3 files changed

+18
-17
lines changed

3 files changed

+18
-17
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 & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -400,23 +400,24 @@
400400
</ImportGroup>
401401
<Target Name="_GetBuildInfo" BeforeTargets="PrepareForBuild">
402402
<PropertyGroup>
403-
<HG Condition="$(HG) == ''">hg</HG>
404-
<_HG>$(HG)</_HG>
405-
<_HG Condition="$(HG.Contains(` `))">"$(HG)"</_HG>
403+
<GIT Condition="$(GIT) == ''">git</GIT>
404+
<_GIT>$(GIT)</_GIT>
405+
<_GIT Condition="$(GIT.Contains(` `))">"$(GIT)"</_GIT>
406406
</PropertyGroup>
407-
<Message Text="Getting build info from $(_HG)" Importance="high" />
407+
<Message Text="Getting build info from $(_GIT)" Importance="high" />
408408
<MakeDir Directories="$(IntDir)" Condition="!Exists($(IntDir))" />
409-
<Exec Command="$(_HG) id -b &gt; &quot;$(IntDir)hgbranch.txt&quot;" ContinueOnError="true" />
410-
<Exec Command="$(_HG) id -i &gt; &quot;$(IntDir)hgversion.txt&quot;" ContinueOnError="true" />
411-
<Exec Command="$(_HG) id -t &gt; &quot;$(IntDir)hgtag.txt&quot;" ContinueOnError="true" />
409+
<Exec Command="$(_GIT) name-rev --name-only HEAD &gt; &quot;$(IntDir)gitbranch.txt&quot;" ContinueOnError="true" />
410+
<Exec Command="$(_GIT) rev-parse HEAD &gt; &quot;$(IntDir)gitversion.txt&quot;" ContinueOnError="true" />
411+
<Exec Command="$(_GIT) name-rev --tags --name id -t &gt; &quot;$(IntDir)gittag.txt&quot;" ContinueOnError="true" />
412412
<PropertyGroup>
413-
<HgBranch Condition="Exists('$(IntDir)hgbranch.txt')">$([System.IO.File]::ReadAllText('$(IntDir)hgbranch.txt').Trim())</HgBranch>
414-
<HgVersion Condition="Exists('$(IntDir)hgversion.txt')">$([System.IO.File]::ReadAllText('$(IntDir)hgversion.txt').Trim())</HgVersion>
415-
<HgTag Condition="Exists('$(IntDir)hgtag.txt')">$([System.IO.File]::ReadAllText('$(IntDir)hgtag.txt').Trim())</HgTag>
413+
<GitBranch Condition="Exists('$(IntDir)gitbranch.txt')">$([System.IO.File]::ReadAllText('$(IntDir)gitbranch.txt').Trim())</GitBranch>
414+
<GitVersion Condition="Exists('$(IntDir)gitversion.txt')">$([System.IO.File]::ReadAllText('$(IntDir)gitversion.txt').Trim())</GitVersion>
415+
<GitTag Condition="Exists('$(IntDir)gittag.txt')">$([System.IO.File]::ReadAllText('$(IntDir)gittag.txt').Trim())</GitTag>
416416
</PropertyGroup>
417+
<Message Text="Building $(GitTag):$(GitVersion) $(GitBranch)" Importance="high" />
417418
<ItemGroup>
418419
<ClCompile Include="..\Modules\getbuildinfo.c">
419-
<PreprocessorDefinitions>HGVERSION="$(HgVersion)";HGTAG="$(HgTag)";HGBRANCH="$(HgBranch)";%(PreprocessorDefinitions)</PreprocessorDefinitions>
420+
<PreprocessorDefinitions>GITVERSION="$(GitVersion)";GITTAG="$(GitTag)";GITBRANCH="$(GitBranch)";%(PreprocessorDefinitions)</PreprocessorDefinitions>
420421
</ClCompile>
421422
</ItemGroup>
422423
</Target>

Tools/msi/buildrelease.bat

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

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

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

7070
call "%D%get_externals.bat"
7171

0 commit comments

Comments
 (0)