[Python-checkins] cpython: Fixes sys.winver generation and removes dependency on user32.dll

steve.dower python-checkins at python.org
Thu Jan 15 18:12:45 CET 2015


https://hg.python.org/cpython/rev/36b0a5c1bc9e
changeset: 94179:36b0a5c1bc9e
user: Steve Dower <steve.dower at microsoft.com>
date: Thu Jan 15 09:10:16 2015 -0800
summary:
 Fixes sys.winver generation and removes dependency on user32.dll
files:
 PC/dl_nt.c | 8 ++++++++
 PCbuild/pyproject.props | 2 +-
 PCbuild/python.props | 8 ++++++--
 PCbuild/pythoncore.vcxproj | 8 +++++---
 4 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/PC/dl_nt.c b/PC/dl_nt.c
--- a/PC/dl_nt.c
+++ b/PC/dl_nt.c
@@ -12,7 +12,12 @@
 #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 @@
 {
 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.
diff --git a/PCbuild/pyproject.props b/PCbuild/pyproject.props
--- a/PCbuild/pyproject.props
+++ b/PCbuild/pyproject.props
@@ -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>
diff --git a/PCbuild/python.props b/PCbuild/python.props
--- a/PCbuild/python.props
+++ b/PCbuild/python.props
@@ -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
@@ -100,6 +100,10 @@
 <!-- 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 -->
diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj
--- a/PCbuild/pythoncore.vcxproj
+++ b/PCbuild/pythoncore.vcxproj
@@ -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>
@@ -335,7 +335,6 @@
 <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" />
@@ -387,13 +386,16 @@
 <ClCompile Include="..\Python\traceback.c" />
 </ItemGroup>
 <ItemGroup>
+ <ClCompile Include="..\PC\dl_nt.c" />
+ </ItemGroup>
+ <ItemGroup>
 <ResourceCompile Include="..\PC\python_nt.rc" />
 </ItemGroup>
 <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
 <ImportGroup Label="ExtensionTargets">
 </ImportGroup>
 
- <Target Name="_GetBuildInfo" AfterTargets="PrepareForBuild">
+ <Target Name="_GetBuildInfo" BeforeTargets="PrepareForBuild">
 <Exec Command='hg id -b > "$(IntDir)hgbranch.txt"' ContinueOnError="true" />
 <Exec Command='hg id -i > "$(IntDir)hgversion.txt"' ContinueOnError="true" />
 <Exec Command='hg id -t > "$(IntDir)hgtag.txt"' ContinueOnError="true" />
-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /