]> granicus.if.org Git - python/commitdiff
bpo-27593: Updates Windows build to use information from git (#262) (#448)
authorSteve Dower <steve.dower@microsoft.com>
Sat, 4 Mar 2017 18:08:09 +0000 (10:08 -0800)
committerGitHub <noreply@github.com>
Sat, 4 Mar 2017 18:08:09 +0000 (10:08 -0800)
* 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)

Demo/turtle/tdemo_two_canvases.py [changed mode: 0644->0755]
PCbuild/build.bat
PCbuild/pythoncore.vcxproj

old mode 100644 (file)
new mode 100755 (executable)
index 766378fb2daa9c9efd9c41c2f9d19a37f48be3fc..b8f4191fd1fc177c1dd8563afedb6cd57bb98097 100644 (file)
@@ -104,6 +104,10 @@ if "%platf%"=="x64" (
     )\r
 )\r
 \r
+if not exist "%GIT%" where git > "%TEMP%\git.loc" 2> nul && set /P GIT= < "%TEMP%\git.loc" & del "%TEMP%\git.loc"\r
+if exist "%GIT%" set GITProperty=/p:GIT="%GIT%"\r
+if not exist "%GIT%" echo Cannot find Git on PATH & set GITProperty=\r
+\r
 rem Setup the environment\r
 call "%dir%env.bat" %vs_platf% >nul\r
 \r
@@ -140,7 +144,7 @@ msbuild "%dir%pcbuild.proj" /t:%target% %parallel% %verbose%^
  /p:Configuration=%conf% /p:Platform=%platf%^\r
  /p:IncludeExternals=%IncludeExternals%^\r
  /p:IncludeSSL=%IncludeSSL% /p:IncludeTkinter=%IncludeTkinter%^\r
- /p:IncludeBsddb=%IncludeBsddb%^\r
+ /p:IncludeBsddb=%IncludeBsddb% %GITProperty%^\r
  %1 %2 %3 %4 %5 %6 %7 %8 %9\r
 \r
 @echo off\r
index da5d5d9ed3c8a85daa9643ffd34320b06169b36a..b894e27f83260c2a2da834b3fffefccc72b1b6dd 100644 (file)
   <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>