]> granicus.if.org Git - python/commitdiff
Fixes sys.winver generation and removes dependency on user32.dll
authorSteve Dower <steve.dower@microsoft.com>
Thu, 15 Jan 2015 17:10:16 +0000 (09:10 -0800)
committerSteve Dower <steve.dower@microsoft.com>
Thu, 15 Jan 2015 17:10:16 +0000 (09:10 -0800)
PC/dl_nt.c
PCbuild/pyproject.props
PCbuild/python.props
PCbuild/pythoncore.vcxproj

index ae10fb56231b2e3581a93f33b8146fa1ed622557..c87c51eb559f9734692e444e760c8da73f46075a 100644 (file)
@@ -12,7 +12,12 @@ forgotten) from the programmer.
 #include "windows.h"
 
 #ifdef Py_ENABLE_SHARED
+#ifdef MS_DLL_ID
+// The string is available at build, so fill the buffer immediately
+char dllVersionBuffer[16] = MS_DLL_ID;
+#else
 char dllVersionBuffer[16] = ""; // a private buffer
+#endif
 
 // Python Globals
 HMODULE PyWin_DLLhModule = NULL;
@@ -88,8 +93,11 @@ BOOL    WINAPI  DllMain (HANDLE hInst,
     {
         case DLL_PROCESS_ATTACH:
             PyWin_DLLhModule = hInst;
+#ifndef MS_DLL_ID
+            // If we have MS_DLL_ID, we don't need to load the string.
             // 1000 is a magic number I picked out of the air.  Could do with a #define, I spose...
             LoadString(hInst, 1000, dllVersionBuffer, sizeof(dllVersionBuffer));
+#endif
 
 #if HAVE_SXS
             // and capture our activation context for use when loading extensions.
index 85aebebe2f4e3b7f9b5a61663f3122efde94d868..33570d784269f4f8faee68111deb4fb5207875b4 100644 (file)
@@ -87,7 +87,7 @@
     <WriteLinesToFile File="$(PySourcePath)PC\pythonnt_rc$(PyDebugExt).h" Overwrite="true" Encoding="ascii"
                       Lines='/* This file created by python.props /t:GeneratePythonNtRcH */
 #define FIELD3 $(Field3Value)
-#define MS_DLL_ID "$(PythonMajorVersion).$(PythonMinorVersion)"
+#define MS_DLL_ID "$(SysWinVer)"
 #define PYTHON_DLL_NAME "$(PyDllName).dll"
 ' />
     <ItemGroup>
index 99eebf0fe28805023091ab2090f07f82f8fb41b2..788df56bddd727c7e0d371e053928e38a03e3583 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" TreatAsLocalProperty="Platform">
   <PropertyGroup>
-    <Platform Condition="'$(Platform)' == ''">Win32</Platform>
+    <Platform Condition="'$(Platform)' == '' or '$(Platform)' == 'x86'">Win32</Platform>
     <Configuration Condition="'$(Configuration)' == ''">Release</Configuration>
     <!--
     Use the latest available version of Visual Studio to build. To override
     <!-- The version and platform tag to include in .pyd filenames -->
     <PydTag Condition="$(Platform) == 'Win32'">.cp$(MajorVersionNumber)$(MinorVersionNumber)-win32</PydTag>
     <PydTag Condition="$(Platform) == 'x64'">.cp$(MajorVersionNumber)$(MinorVersionNumber)-win_amd64</PydTag>
+    
+    <!-- The version number for sys.winver -->
+    <SysWinVer>$(MajorVersionNumber).$(MinorVersionNumber)</SysWinVer>
+    <SysWinVer Condition="$(Platform) == 'Win32'">$(SysWinVer)-32</SysWinVer>
   </PropertyGroup>
   
   <!-- Displays the calculated version info -->
index 4ecfd102c16a95bed3e0a9e67b2151a0f70880fc..479f68df554356db2c62aadc95e737b92327fbb1 100644 (file)
@@ -67,7 +67,7 @@
     <ClCompile>
       <AdditionalOptions>/Zm200  %(AdditionalOptions)</AdditionalOptions>
       <AdditionalIncludeDirectories>$(PySourcePath)Python;$(PySourcePath)Modules\zlib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <PreprocessorDefinitions>_USRDLL;Py_BUILD_CORE;Py_ENABLE_SHARED;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>_USRDLL;Py_BUILD_CORE;Py_ENABLE_SHARED;MS_DLL_ID="$(SysWinVer)";%(PreprocessorDefinitions)</PreprocessorDefinitions>
     </ClCompile>
     <Link>
       <AdditionalDependencies>ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
     <ClCompile Include="..\Parser\tokenizer.c" />
     <ClCompile Include="..\PC\winreg.c" />
     <ClCompile Include="..\PC\config.c" />
-    <ClCompile Include="..\PC\dl_nt.c" />
     <ClCompile Include="..\PC\getpathp.c" />
     <ClCompile Include="..\PC\msvcrtmodule.c" />
     <ClCompile Include="..\Python\pyhash.c" />
     <ClCompile Include="..\Python\thread.c" />
     <ClCompile Include="..\Python\traceback.c" />
   </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="..\PC\dl_nt.c" />
+  </ItemGroup>
   <ItemGroup>
     <ResourceCompile Include="..\PC\python_nt.rc" />
   </ItemGroup>
   <ImportGroup Label="ExtensionTargets">
   </ImportGroup>
   
-  <Target Name="_GetBuildInfo" AfterTargets="PrepareForBuild">
+  <Target Name="_GetBuildInfo" BeforeTargets="PrepareForBuild">
     <Exec Command='hg id -b &gt; "$(IntDir)hgbranch.txt"' ContinueOnError="true" />
     <Exec Command='hg id -i &gt; "$(IntDir)hgversion.txt"' ContinueOnError="true" />
     <Exec Command='hg id -t &gt; "$(IntDir)hgtag.txt"' ContinueOnError="true" />