]> granicus.if.org Git - python/commitdiff
bpo-27593: Updates Windows build to use information from git (#262) (#450)
authorSteve Dower <steve.dower@microsoft.com>
Sat, 4 Mar 2017 05:32:17 +0000 (21:32 -0800)
committerGitHub <noreply@github.com>
Sat, 4 Mar 2017 05:32:17 +0000 (21:32 -0800)
* bpo-27593: Updates Windows build to use information from git

PCbuild/build.bat
PCbuild/pythoncore.vcxproj
Tools/msi/buildrelease.bat

index 70ab340905e4c95959e167f43f02a13c1bb79449..f7f2858d7d9d99c61b820a1e4cc65912918aa764 100644 (file)
@@ -105,9 +105,9 @@ if "%platf%"=="x64" (
     )\r
 )\r
 \r
-if not exist "%HG%" where hg > "%TEMP%\hg.loc" 2> nul && set /P HG= < "%TEMP%\hg.loc" & del "%TEMP%\hg.loc"\r
-if exist "%HG%" set HGProperty=/p:HG="%HG%"\r
-if not exist "%HG%" echo Cannot find Mercurial on PATH & set HGProperty=\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
@@ -145,7 +145,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:UseTestMarker=%UseTestMarker% %HGProperty%^\r
+ /p:UseTestMarker=%UseTestMarker% %GITProperty%^\r
  %1 %2 %3 %4 %5 %6 %7 %8 %9\r
 \r
 @echo off\r
index 6b23d8ecacce3b9d4091e68a7e97310098c8d0b2..8f8bede8a8818ebdc76380f797b0f1b336c9bed8 100644 (file)
   </ImportGroup>
   <Target Name="_GetBuildInfo" BeforeTargets="PrepareForBuild">
     <PropertyGroup>
-      <HG Condition="$(HG) == ''">hg</HG>
-      <_HG>$(HG)</_HG>
-      <_HG Condition="$(HG.Contains(` `))">"$(HG)"</_HG>
+      <GIT Condition="$(GIT) == ''">git</GIT>
+      <_GIT>$(GIT)</_GIT>
+      <_GIT Condition="$(GIT.Contains(` `))">"$(GIT)"</_GIT>
     </PropertyGroup>
-    <Message Text="Getting build info from $(_HG)" Importance="high" />
+    <Message Text="Getting build info from $(_GIT)" Importance="high" />
     <MakeDir Directories="$(IntDir)" Condition="!Exists($(IntDir))" />
-    <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" />
+    <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 id -t &gt; &quot;$(IntDir)gittag.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>
+      <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 $(HgTag):$(HgVersion) $(HgBranch)" Importance="high" />
+    <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>
index 4659a32b838cc1793cc0bbb3d4edec308055b46e..81a3f86cab36b039d7964d6ea2dc89416db05718 100644 (file)
@@ -65,8 +65,8 @@ if "%1" NEQ "" echo Invalid option: "%1" && exit /B 1
 \r
 if not defined BUILDX86 if not defined BUILDX64 (set BUILDX86=1) && (set BUILDX64=1)\r
 \r
-if not exist "%HG%" where hg > "%TEMP%\hg.loc" 2> nul && set /P HG= < "%TEMP%\hg.loc" & del "%TEMP%\hg.loc"\r
-if not exist "%HG%" echo Cannot find Mercurial on PATH && exit /B 1\r
+if not exist "%GIT%" where git > "%TEMP%\git.loc" 2> nul && set /P GIT= < "%TEMP%\git.loc" & del "%TEMP%\git.loc"\r
+if not exist "%GIT%" echo Cannot find Git on PATH && exit /B 1\r
 \r
 call "%D%get_externals.bat"\r
 \r