summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Dower <steve.dower@microsoft.com>2015-01-15 09:10:16 -0800
committerSteve Dower <steve.dower@microsoft.com>2015-01-15 09:10:16 -0800
commitbca6b406fe0355732a4bcab88931f596df37d0b6 (patch)
treece4e9b8fcce5f3c1e2147bfdd0f88da5ed70fe94
parent0f87814ab3d88b8474afcac9f6b940d4b064e066 (diff)
downloadcpython-bca6b406fe0355732a4bcab88931f596df37d0b6.tar.gz
Fixes sys.winver generation and removes dependency on user32.dll
-rw-r--r--PC/dl_nt.c8
-rw-r--r--PCbuild/pyproject.props2
-rw-r--r--PCbuild/python.props8
-rw-r--r--PCbuild/pythoncore.vcxproj8
4 files changed, 20 insertions, 6 deletions
diff --git a/PC/dl_nt.c b/PC/dl_nt.c
index ae10fb5623..c87c51eb55 100644
--- a/PC/dl_nt.c
+++ b/PC/dl_nt.c
@@ -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.
diff --git a/PCbuild/pyproject.props b/PCbuild/pyproject.props
index 85aebebe2f..33570d7842 100644
--- 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
index 99eebf0fe2..788df56bdd 100644
--- 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
index 4ecfd102c1..479f68df55 100644
--- 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 &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" />