Skip to content

Commit

Permalink
Build bootloader: wscript: When using MSVC set minimum target OS to XP.
Browse files Browse the repository at this point in the history
Set the minimum version of Windows this application will run on.
This is required because since Visual Studio 2012 the default
minimal target was set to Vista (win ver. 6.0).
5.01 is the version number for 32-bit XP, 5.02 for 64-bit XP.

Basically this makes the linker use the option /SUBSYSTEM, with
its four combinations:

/SUBSYSTEM:WINDOWS,5.01
/SUBSYSTEM:CONSOLE,5.01
/SUBSYSTEM:WINDOWS,5.02
/SUBSYSTEM:CONSOLE,5.02
  • Loading branch information
tenuki authored and htgoebel committed Dec 7, 2017
1 parent eb908f7 commit 4496bf1
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions bootloader/wscript
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,10 @@ def configure(ctx):
# Use Unicode entry point wmain/wWinMain and wchar_t WinAPI
ctx.env.append_value('CFLAGS', '-DUNICODE')
ctx.env.append_value('CFLAGS', '-D_UNICODE')
# set XP target as minimal target OS ver. when using Windows w/MSVC
# https://blogs.msdn.microsoft.com/vcblog/2012/10/08/windows-xp-targeting-with-c-in-visual-studio-2012/
ctx.env.append_value('LINKFLAGS', '/SUBSYSTEM:CONSOLE,%s' % (
'5.01' if ctx.env.PYI_ARCH == '32bit' else '5.02'))
else:
# Use Visual C++ compatible alignment
ctx.env.append_value('CFLAGS', '-mms-bitfields')
Expand All @@ -645,11 +649,19 @@ def configure(ctx):
ctx.setenv(name, baseenv) # Inherit from `baseenv`.
ctx.env.append_value('DEFINES', 'WINDOWED')

if ctx.env.DEST_OS == 'win32' and ctx.env.CC_NAME != 'msvc':
# For MinGW disable console window on Windows - MinGW option
# TODO Is it necessary to have -mwindows for C and LINK flags?
ctx.env.append_value('LINKFLAGS', '-mwindows')
ctx.env.append_value('CFLAGS', '-mwindows')
if ctx.env.DEST_OS == 'win32':
if ctx.env.CC_NAME != 'msvc':
# For MinGW disable console window on Windows - MinGW option
# TODO Is it necessary to have -mwindows for C and LINK flags?
ctx.env.append_value('LINKFLAGS', '-mwindows')
ctx.env.append_value('CFLAGS', '-mwindows')
else:
_link_flags = ctx.env._get_list_value_for_modification('LINKFLAGS')
_subsystem = [x for x in _link_flags if x.startswith('/SUBSYSTEM:')]
for parameter in _subsystem:
_link_flags.remove(parameter)
ctx.env.append_value('LINKFLAGS', '/SUBSYSTEM:WINDOWS,%s' % (
'5.01' if ctx.env.PYI_ARCH == '32bit' else '5.02'))
elif ctx.env.DEST_OS == 'darwin':
# To support catching AppleEvents and running as ordinary OSX GUI
# app, we have to link against the Carbon framework.
Expand Down

3 comments on commit 4496bf1

@dhruvinsh
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With Python 2.7.13 32-Bit, Host OS Win 7 64-Bit, Target OS XP 32-Bit Fail to Execute single EXE file made from PyInstaller-3.4.dev0+dd7aefc2e.
Do I need to change bootloader (run.exe, run_d.exe) with something new version?

@htgoebel
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, indeed I missed updating the bootloader. I just did it.

@dhruvinsh
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it working. Thanks for awesome support!

Please sign in to comment.