From f90c2282569c79eb787ddf2ea8dd52a92ffb3516 Mon Sep 17 00:00:00 2001 From: Alexis Campailla Date: Thu, 23 Apr 2015 07:26:59 -0700 Subject: [PATCH 1/4] win: backport set env before generating projects Backport commit a58b17456a7fa4ff846c4883b96d6dee7e46a62f from branch v0.12. Original commit message: vcbuild.bat calls python configure before setting GYP_MSVS_VERSION, so SelectVisualStudioVersion (tools\gyp\pylib\gyp\MSVSVersion.py) defaults to 'auto' and selects VS 2005. vcbuild sets the environment in the current shell, so this issue would manifest itself only on the first invocation of the script in any given shell windows. Reviewed-By: Julien Gilli PR-URL: https://github.com/joyent/node/pull/20109 Conflicts: vcbuild.bat --- vcbuild.bat | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/vcbuild.bat b/vcbuild.bat index 1fb9aa44ab3..511e1734b12 100644 --- a/vcbuild.bat +++ b/vcbuild.bat @@ -83,25 +83,6 @@ if defined nosnapshot set nosnapshot_arg=--without-snapshot if defined noetw set noetw_arg=--without-etw& set noetw_msi_arg=/p:NoETW=1 if defined noperfctr set noperfctr_arg=--without-perfctr& set noperfctr_msi_arg=/p:NoPerfCtr=1 -:project-gen -@rem Skip project generation if requested. -if defined noprojgen goto msbuild - -if defined NIGHTLY set TAG=nightly-%NIGHTLY% - -@rem Generate the VS project. -SETLOCAL - if defined VS100COMNTOOLS call "%VS100COMNTOOLS%\VCVarsQueryRegistry.bat" - python configure %debug_arg% %nosnapshot_arg% %noetw_arg% %noperfctr_arg% --dest-cpu=%target_arch% --tag=%TAG% - if errorlevel 1 goto create-msvs-files-failed - if not exist node.sln goto create-msvs-files-failed - echo Project files generated. -ENDLOCAL - -:msbuild -@rem Skip project generation if requested. -if defined nobuild goto sign - @rem Look for Visual Studio 2013 if not defined VS120COMNTOOLS goto vc-set-2012 if not exist "%VS120COMNTOOLS%\..\..\vc\vcvarsall.bat" goto vc-set-2012 @@ -124,13 +105,31 @@ if not defined VS100COMNTOOLS goto msbuild-not-found if not exist "%VS100COMNTOOLS%\..\..\vc\vcvarsall.bat" goto msbuild-not-found call "%VS100COMNTOOLS%\..\..\vc\vcvarsall.bat" if not defined VCINSTALLDIR goto msbuild-not-found +set GYP_MSVS_VERSION=2010 goto msbuild-found :msbuild-not-found -echo Build skipped. To build, this file needs to run from VS cmd prompt. -goto run +echo Failed to find Visual Studio installation. +goto exit :msbuild-found + +:project-gen +@rem Skip project generation if requested. +if defined noprojgen goto msbuild + +if defined NIGHTLY set TAG=nightly-%NIGHTLY% + +@rem Generate the VS project. +python configure %debug_arg% %nosnapshot_arg% %noetw_arg% %noperfctr_arg% --dest-cpu=%target_arch% --tag=%TAG% +if errorlevel 1 goto create-msvs-files-failed +if not exist node.sln goto create-msvs-files-failed +echo Project files generated. + +:msbuild +@rem Skip project generation if requested. +if defined nobuild goto sign + @rem Build the sln with msbuild. msbuild node.sln /m /t:%target% /p:Configuration=%config% /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo if errorlevel 1 goto exit From ee6d2707fbd4b617d4ea0b386a95ccef960778e4 Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Mon, 19 Jan 2015 16:53:56 +0100 Subject: [PATCH 2/4] win: backport bringing back xp/2k3 support Issue: https://github.com/joyent/node/issues/25348 The gyp/project files don't explicitly specify a subsystem version, which results in the default being used. The default changed from VS 2010 to VS 2012 and later. Backport 3122052890e838220b49794de924b323675b3b18, which itself backports e8d08503c7821e8c92e9fa236ed7328e9bdfe62a from io.js. Original commit message follows: Chrome still runs on Windows XP, so there is no reason that iojs couldn't. PR: https://github.com/iojs/io.js/pull/512 (cherry picked from commit e8d08503c7821e8c92e9fa236ed7328e9bdfe62a) Reviewed-By: Julien Gilli PR-URL: https://github.com/joyent/node/pull/25367 Conflicts: node.gyp --- common.gypi | 20 ++++++++++++++------ node.gyp | 5 ----- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/common.gypi b/common.gypi index 31fe5669938..887df4b2285 100644 --- a/common.gypi +++ b/common.gypi @@ -138,8 +138,21 @@ }, 'VCLinkerTool': { 'conditions': [ + ['target_arch=="ia32"', { + 'TargetMachine' : 1, # /MACHINE:X86 + 'target_conditions': [ + ['_type=="executable"', { + 'AdditionalOptions': [ '/SubSystem:Console,"5.01"' ], + }], + ], + }], ['target_arch=="x64"', { - 'TargetMachine' : 17 # /MACHINE:X64 + 'TargetMachine' : 17, # /MACHINE:AMD64 + 'target_conditions': [ + ['_type=="executable"', { + 'AdditionalOptions': [ '/SubSystem:Console,"5.02"' ], + }], + ], }], ], 'GenerateDebugInformation': 'true', @@ -147,11 +160,6 @@ 'DataExecutionPrevention': 2, # enable DEP 'AllowIsolation': 'true', 'SuppressStartupBanner': 'true', - 'target_conditions': [ - ['_type=="executable"', { - 'SubSystem': 1, # console executable - }], - ], }, }, 'conditions': [ diff --git a/node.gyp b/node.gyp index fbf0292a2ee..b641584c312 100644 --- a/node.gyp +++ b/node.gyp @@ -324,11 +324,6 @@ ], }], ], - 'msvs_settings': { - 'VCLinkerTool': { - 'SubSystem': 1, # /subsystem:console - }, - }, }, # generate ETW header and resource files { From c1670ff2a938b62a8f916254d54515721fd5d5b4 Mon Sep 17 00:00:00 2001 From: Julien Gilli Date: Fri, 19 Jun 2015 10:24:14 -0700 Subject: [PATCH 3/4] win: fix custom actions on Visual Studio != 2013 The original change that added support for running custom actions during the install process (e7c84f82c730bddb7450dc56065aab11b93ffd30) assumed that Visual Studio 2013 is used to generate the installer file. However, that is not always the case, and older versions of Visual Studio should allow users to generate Windows installer files. This change makes the custom actions visual studio project use the visual studio version that is found by vcbuild.bat. --- tools/msvs/msi/custom_actions.vcxproj | 28 ++++++++++----------- vcbuild.bat | 36 ++++++++++++++++++++++++++- 2 files changed, 49 insertions(+), 15 deletions(-) diff --git a/tools/msvs/msi/custom_actions.vcxproj b/tools/msvs/msi/custom_actions.vcxproj index e014a6981f5..ae82905cd4b 100644 --- a/tools/msvs/msi/custom_actions.vcxproj +++ b/tools/msvs/msi/custom_actions.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -27,24 +27,24 @@ DynamicLibrary - v120 + $(PlatformToolset) Unicode true DynamicLibrary - v120 + $(PlatformToolset) Unicode true DynamicLibrary - v120 + $(PlatformToolset) Unicode DynamicLibrary - v120 + $(PlatformToolset) Unicode @@ -81,7 +81,7 @@ Disabled - $(WIX)sdk\VS2013\inc;%(AdditionalIncludeDirectories) + $(WIX)sdk\VS$(GypMsvsVersion)\inc;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebug @@ -91,7 +91,7 @@ msi.lib;dutil.lib;wcautil.lib;version.lib;%(AdditionalDependencies) - $(WIX)sdk\VS2013\lib\x86;%(AdditionalLibraryDirectories) + $(WIX)sdk\VS$(GypMsvsVersion)\lib\x86;%(AdditionalLibraryDirectories) custom_actions.def true Windows @@ -100,7 +100,7 @@ Disabled - $(WIX)sdk\VS2013\inc;%(AdditionalIncludeDirectories) + $(WIX)sdk\VS$(GypMsvsVersion)\inc;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebug @@ -110,7 +110,7 @@ msi.lib;dutil.lib;wcautil.lib;version.lib;%(AdditionalDependencies) - $(WIX)sdk\VS2013\lib\x64;%(AdditionalLibraryDirectories) + $(WIX)sdk\VS$(GypMsvsVersion)\lib\x64;%(AdditionalLibraryDirectories) custom_actions.def true Windows @@ -120,7 +120,7 @@ MaxSpeed true - $(WIX)sdk\VS2013\inc;%(AdditionalIncludeDirectories) + $(WIX)sdk\VS$(GypMsvsVersion)\inc;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) MultiThreaded true @@ -134,7 +134,7 @@ msi.lib;dutil.lib;wcautil.lib;version.lib;%(AdditionalDependencies) - $(WIX)sdk\VS2013\lib\x86;%(AdditionalLibraryDirectories) + $(WIX)sdk\VS$(GypMsvsVersion)\lib\x86;%(AdditionalLibraryDirectories) custom_actions.def true Windows @@ -146,7 +146,7 @@ MaxSpeed true - $(WIX)sdk\VS2013\inc;%(AdditionalIncludeDirectories) + $(WIX)sdk\VS$(GypMsvsVersion)\inc;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) MultiThreaded true @@ -160,7 +160,7 @@ msi.lib;dutil.lib;wcautil.lib;version.lib;%(AdditionalDependencies) - $(WIX)sdk\VS2013\lib\x64;%(AdditionalLibraryDirectories) + $(WIX)sdk\VS$(GypMsvsVersion)\lib\x64;%(AdditionalLibraryDirectories) custom_actions.def true Windows @@ -178,4 +178,4 @@ - \ No newline at end of file + diff --git a/vcbuild.bat b/vcbuild.bat index 511e1734b12..4684769136c 100644 --- a/vcbuild.bat +++ b/vcbuild.bat @@ -84,34 +84,68 @@ if defined noetw set noetw_arg=--without-etw& set noetw_msi_arg=/p:NoETW=1 if defined noperfctr set noperfctr_arg=--without-perfctr& set noperfctr_msi_arg=/p:NoPerfCtr=1 @rem Look for Visual Studio 2013 +echo Looking for Visual Studio 2013 if not defined VS120COMNTOOLS goto vc-set-2012 if not exist "%VS120COMNTOOLS%\..\..\vc\vcvarsall.bat" goto vc-set-2012 +echo Found Visual Studio 2013 +if defined msi ( + echo Looking for WiX installation for Visual Studio 2013... + if not exist "%WIX%\SDK\VS2013" ( + echo Failed to find WiX install for Visual Studio 2013 + goto vc-set-2012 + ) +) call "%VS120COMNTOOLS%\..\..\vc\vcvarsall.bat" if not defined VCINSTALLDIR goto msbuild-not-found set GYP_MSVS_VERSION=2013 +set PLATFORM_TOOLSET=v120 goto msbuild-found :vc-set-2012 @rem Look for Visual Studio 2012 +echo Looking for Visual Studio 2012 if not defined VS110COMNTOOLS goto vc-set-2010 if not exist "%VS110COMNTOOLS%\..\..\vc\vcvarsall.bat" goto vc-set-2010 +echo Found Visual Studio 2012 +if defined msi ( + echo Looking for WiX installation for Visual Studio 2012... + if not exist "%WIX%\SDK\VS2012" ( + echo Failed to find WiX install for Visual Studio 2012 + goto vc-set-2010 + ) +) call "%VS110COMNTOOLS%\..\..\vc\vcvarsall.bat" if not defined VCINSTALLDIR goto msbuild-not-found set GYP_MSVS_VERSION=2012 +set PLATFORM_TOOLSET=v110 goto msbuild-found :vc-set-2010 +echo Looking for Visual Studio 2010 if not defined VS100COMNTOOLS goto msbuild-not-found if not exist "%VS100COMNTOOLS%\..\..\vc\vcvarsall.bat" goto msbuild-not-found +echo Found Visual Studio 2010 +if defined msi ( + echo Looking for WiX installation for Visual Studio 2010... + if not exist "%WIX%\SDK\VS2010" ( + echo Failed to find WiX install for Visual Studio 2010 + goto wix-not-found + ) +) call "%VS100COMNTOOLS%\..\..\vc\vcvarsall.bat" if not defined VCINSTALLDIR goto msbuild-not-found set GYP_MSVS_VERSION=2010 +set PLATFORM_TOOLSET=v100 goto msbuild-found :msbuild-not-found echo Failed to find Visual Studio installation. goto exit +:wix-not-found +echo Build skipped. To generate installer, you need to install Wix. +goto run + :msbuild-found :project-gen @@ -158,7 +192,7 @@ set NODE_VERSION=%NODE_VERSION%.%NIGHTLY% :msibuild echo Building node-%NODE_VERSION% -msbuild "%~dp0tools\msvs\msi\nodemsi.sln" /m /t:Clean,Build /p:Configuration=%config% /p:Platform=%msiplatform% /p:NodeVersion=%NODE_VERSION% %noetw_msi_arg% %noperfctr_msi_arg% /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo +msbuild "%~dp0tools\msvs\msi\nodemsi.sln" /m /t:Clean,Build /p:PlatformToolset=%PLATFORM_TOOLSET% /p:GypMsvsVersion=%GYP_MSVS_VERSION% /p:Configuration=%config% /p:Platform=%msiplatform% /p:NodeVersion=%NODE_VERSION% %noetw_msi_arg% %noperfctr_msi_arg% /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo if errorlevel 1 goto exit if defined nosign goto run From 24a7113e86e936d014b100b114e2a7da1ed4a4d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Reis?= Date: Tue, 21 Jul 2015 21:39:15 +0100 Subject: [PATCH 4/4] win: fix custom actions for WiX older than 3.9 Older WiX versions included a header with extern "C" declaration, hence the custom action source must be C++. --- tools/msvs/msi/{custom_actions.c => custom_actions.cc} | 4 ++-- tools/msvs/msi/custom_actions.vcxproj | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) rename tools/msvs/msi/{custom_actions.c => custom_actions.cc} (83%) diff --git a/tools/msvs/msi/custom_actions.c b/tools/msvs/msi/custom_actions.cc similarity index 83% rename from tools/msvs/msi/custom_actions.c rename to tools/msvs/msi/custom_actions.cc index 5e7d617f387..9a23d557476 100644 --- a/tools/msvs/msi/custom_actions.c +++ b/tools/msvs/msi/custom_actions.cc @@ -6,7 +6,7 @@ #include -UINT WINAPI BroadcastEnvironmentUpdate(MSIHANDLE hInstall) { +extern "C" UINT WINAPI BroadcastEnvironmentUpdate(MSIHANDLE hInstall) { HRESULT hr = S_OK; UINT er = ERROR_SUCCESS; @@ -27,7 +27,7 @@ UINT WINAPI BroadcastEnvironmentUpdate(MSIHANDLE hInstall) { } -BOOL WINAPI DllMain(HINSTANCE hInst, ULONG ulReason, VOID* dummy) { +extern "C" BOOL WINAPI DllMain(HINSTANCE hInst, ULONG ulReason, VOID* dummy) { switch (ulReason) { case DLL_PROCESS_ATTACH: WcaGlobalInitialize(hInst); diff --git a/tools/msvs/msi/custom_actions.vcxproj b/tools/msvs/msi/custom_actions.vcxproj index ae82905cd4b..3716f07ff6d 100644 --- a/tools/msvs/msi/custom_actions.vcxproj +++ b/tools/msvs/msi/custom_actions.vcxproj @@ -169,7 +169,7 @@ - +