Skip to content

Commit

Permalink
bpo-27593: Updates Windows build to use information from git (python#262
Browse files Browse the repository at this point in the history
) (python#448)

* bpo-27593: Updates Windows build to use information from git (python#262)

* bpo-27593: Updates Windows build to use information from git

* Fixes git command (python#451)
  • Loading branch information
zooba authored Mar 4, 2017
1 parent f9a6516 commit 6120484
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
Empty file modified Demo/turtle/tdemo_two_canvases.py
100644 → 100755
Empty file.
6 changes: 5 additions & 1 deletion PCbuild/build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ if "%platf%"=="x64" (
)
)

if not exist "%GIT%" where git > "%TEMP%\git.loc" 2> nul && set /P GIT= < "%TEMP%\git.loc" & del "%TEMP%\git.loc"
if exist "%GIT%" set GITProperty=/p:GIT="%GIT%"
if not exist "%GIT%" echo Cannot find Git on PATH & set GITProperty=

rem Setup the environment
call "%dir%env.bat" %vs_platf% >nul

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

@echo off
Expand Down
22 changes: 15 additions & 7 deletions PCbuild/pythoncore.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -391,17 +391,25 @@
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
<Target Name="_GetBuildInfo" BeforeTargets="PrepareForBuild">
<Exec Command="hg id -b &gt; &quot;$(IntDir)hgbranch.txt&quot;" ContinueOnError="true" />
<Exec Command="hg id -i &gt; &quot;$(IntDir)hgversion.txt&quot;" ContinueOnError="true" />
<Exec Command="hg id -t &gt; &quot;$(IntDir)hgtag.txt&quot;" 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>
<GIT Condition="$(GIT) == ''">git</GIT>
<_GIT>$(GIT)</_GIT>
<_GIT Condition="$(GIT.Contains(` `))">"$(GIT)"</_GIT>
</PropertyGroup>
<Message Text="Getting build info from $(_GIT)" Importance="high" />
<MakeDir Directories="$(IntDir)" Condition="!Exists($(IntDir))" />
<Exec Command="$(_GIT) name-rev --name-only HEAD &gt; &quot;$(IntDir)gitbranch.txt&quot;" ContinueOnError="true" />
<Exec Command="$(_GIT) rev-parse HEAD &gt; &quot;$(IntDir)gitversion.txt&quot;" ContinueOnError="true" />
<Exec Command="$(_GIT) name-rev --tags --name-only HEAD &gt; &quot;$(IntDir)gittag.txt&quot;" ContinueOnError="true" />
<PropertyGroup>
<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 $(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>
Expand Down

0 comments on commit 6120484

Please sign in to comment.