Skip to content

bpo-41054: Simplify resource compilation on Windows #21004

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions PC/dl_nt.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,10 @@ 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;
const char *PyWin_DLLVersionString = dllVersionBuffer;
const char *PyWin_DLLVersionString = MS_DLL_ID;

BOOL WINAPI DllMain (HANDLE hInst,
ULONG ul_reason_for_call,
Expand All @@ -31,11 +25,6 @@ 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
break;

case DLL_PROCESS_DETACH:
Expand Down
8 changes: 1 addition & 7 deletions PC/python_nt.rc
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@
#include <winuser.h>
2 RT_MANIFEST "python.manifest"

// String Tables
STRINGTABLE DISCARDABLE
BEGIN
1000, MS_DLL_ID
END

/////////////////////////////////////////////////////////////////////////////
//
// Version
Expand Down Expand Up @@ -40,7 +34,7 @@ BEGIN
VALUE "FileVersion", PYTHON_VERSION
VALUE "InternalName", "Python DLL\0"
VALUE "LegalCopyright", PYTHON_COPYRIGHT "\0"
VALUE "OriginalFilename", PYTHON_DLL_NAME "\0"
VALUE "OriginalFilename", ORIGINAL_FILENAME "\0"
VALUE "ProductName", "Python\0"
VALUE "ProductVersion", PYTHON_VERSION
END
Expand Down
1 change: 0 additions & 1 deletion PC/python_ver_rc.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#define MS_WINDOWS
#include "modsupport.h"
#include "patchlevel.h"
#include <pythonnt_rc.h>
#ifdef _DEBUG
# define PYTHON_DEBUG_EXT "_d"
#else
Expand Down
17 changes: 1 addition & 16 deletions PCbuild/pyproject.props
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
</Lib>
<ResourceCompile>
<AdditionalIncludeDirectories>$(PySourcePath)PC;$(PySourcePath)Include;$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>$(_DebugPreprocessorDefinition)%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>ORIGINAL_FILENAME=\"$(TargetName)$(TargetExt)\";FIELD3=$(Field3Value);$(_DebugPreprocessorDefinition)%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0409</Culture>
</ResourceCompile>
<Midl>
Expand All @@ -95,21 +95,6 @@
</Midl>
</ItemDefinitionGroup>

<Target Name="GeneratePythonNtRcH"
BeforeTargets="ClCompile"
Inputs="$(PySourcePath)Include\patchlevel.h"
Outputs="$(IntDir)pythonnt_rc.h">
<WriteLinesToFile File="$(IntDir)pythonnt_rc.h" Overwrite="true" Encoding="ascii"
Lines='/* This file created by pyproject.props /t:GeneratePythonNtRcH */
#define FIELD3 $(Field3Value)
#define MS_DLL_ID "$(SysWinVer)"
#define PYTHON_DLL_NAME "$(TargetName)$(TargetExt)"
' />
<ItemGroup>
<FileWrites Include="$(IntDir)pythonnt_rc.h" />
</ItemGroup>
</Target>

<UsingTask TaskName="KillPython" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<FileName Required="true" />
Expand Down