Skip to content

Commit 4efc336

Browse files
authored
bpo-41054: Simplify resource compilation on Windows (GH-21004)
Remove auto-generated resource header. Pass definitions required by resource files (ORIGINAL_FILENAME and FIELD3) directly to resource compiler. Remove unused MS_DLL_ID resource string and related dead code.
1 parent 930f451 commit 4efc336

File tree

4 files changed

+3
-36
lines changed

4 files changed

+3
-36
lines changed

PC/dl_nt.c

+1-12
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,10 @@ forgotten) from the programmer.
1212
#include "windows.h"
1313

1414
#ifdef Py_ENABLE_SHARED
15-
#ifdef MS_DLL_ID
16-
// The string is available at build, so fill the buffer immediately
17-
char dllVersionBuffer[16] = MS_DLL_ID;
18-
#else
19-
char dllVersionBuffer[16] = ""; // a private buffer
20-
#endif
2115

2216
// Python Globals
2317
HMODULE PyWin_DLLhModule = NULL;
24-
const char *PyWin_DLLVersionString = dllVersionBuffer;
18+
const char *PyWin_DLLVersionString = MS_DLL_ID;
2519

2620
BOOL WINAPI DllMain (HANDLE hInst,
2721
ULONG ul_reason_for_call,
@@ -31,11 +25,6 @@ BOOL WINAPI DllMain (HANDLE hInst,
3125
{
3226
case DLL_PROCESS_ATTACH:
3327
PyWin_DLLhModule = hInst;
34-
#ifndef MS_DLL_ID
35-
// If we have MS_DLL_ID, we don't need to load the string.
36-
// 1000 is a magic number I picked out of the air. Could do with a #define, I spose...
37-
LoadString(hInst, 1000, dllVersionBuffer, sizeof(dllVersionBuffer));
38-
#endif
3928
break;
4029

4130
case DLL_PROCESS_DETACH:

PC/python_nt.rc

+1-7
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@
77
#include <winuser.h>
88
2 RT_MANIFEST "python.manifest"
99

10-
// String Tables
11-
STRINGTABLE DISCARDABLE
12-
BEGIN
13-
1000, MS_DLL_ID
14-
END
15-
1610
/////////////////////////////////////////////////////////////////////////////
1711
//
1812
// Version
@@ -40,7 +34,7 @@ BEGIN
4034
VALUE "FileVersion", PYTHON_VERSION
4135
VALUE "InternalName", "Python DLL\0"
4236
VALUE "LegalCopyright", PYTHON_COPYRIGHT "\0"
43-
VALUE "OriginalFilename", PYTHON_DLL_NAME "\0"
37+
VALUE "OriginalFilename", ORIGINAL_FILENAME "\0"
4438
VALUE "ProductName", "Python\0"
4539
VALUE "ProductVersion", PYTHON_VERSION
4640
END

PC/python_ver_rc.h

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#define MS_WINDOWS
1010
#include "modsupport.h"
1111
#include "patchlevel.h"
12-
#include <pythonnt_rc.h>
1312
#ifdef _DEBUG
1413
# define PYTHON_DEBUG_EXT "_d"
1514
#else

PCbuild/pyproject.props

+1-16
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
</Lib>
8181
<ResourceCompile>
8282
<AdditionalIncludeDirectories>$(PySourcePath)PC;$(PySourcePath)Include;$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
83-
<PreprocessorDefinitions>$(_DebugPreprocessorDefinition)%(PreprocessorDefinitions)</PreprocessorDefinitions>
83+
<PreprocessorDefinitions>ORIGINAL_FILENAME=\"$(TargetName)$(TargetExt)\";FIELD3=$(Field3Value);$(_DebugPreprocessorDefinition)%(PreprocessorDefinitions)</PreprocessorDefinitions>
8484
<Culture>0x0409</Culture>
8585
</ResourceCompile>
8686
<Midl>
@@ -95,21 +95,6 @@
9595
</Midl>
9696
</ItemDefinitionGroup>
9797

98-
<Target Name="GeneratePythonNtRcH"
99-
BeforeTargets="ClCompile"
100-
Inputs="$(PySourcePath)Include\patchlevel.h"
101-
Outputs="$(IntDir)pythonnt_rc.h">
102-
<WriteLinesToFile File="$(IntDir)pythonnt_rc.h" Overwrite="true" Encoding="ascii"
103-
Lines='/* This file created by pyproject.props /t:GeneratePythonNtRcH */
104-
#define FIELD3 $(Field3Value)
105-
#define MS_DLL_ID "$(SysWinVer)"
106-
#define PYTHON_DLL_NAME "$(TargetName)$(TargetExt)"
107-
' />
108-
<ItemGroup>
109-
<FileWrites Include="$(IntDir)pythonnt_rc.h" />
110-
</ItemGroup>
111-
</Target>
112-
11398
<UsingTask TaskName="KillPython" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
11499
<ParameterGroup>
115100
<FileName Required="true" />

0 commit comments

Comments
 (0)