Skip to content

Commit 1c93e8c

Browse files
refackgibfahn
authored andcommittedMay 5, 2017
win: make buildable on VS2017
* Set default to `vs2015` since `vs2017` is not CI-green yet * changes vcbuild.bat arg from `vc2015` to `vs2015`/`vs2017` `vc` as in Visual C++ is actually versions 14.0 or 14.10 `vs` as in Visual Studio is 2015 or 2017 Ref: http://lists.boost.org/Archives/boost/2017/03/233597.php 🤦 * keep `vc2015` for backward compatibility but "undocumented" * tools: transplant vswhere wrapper from `msvs-com-helper` Ref: https://github.com/node4good/msvs-com-helper PR-URL: #11852 Reviewed-By: João Reis <[email protected]> Reviewed-By: Bartosz Sosnowski <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]>
1 parent bc05436 commit 1c93e8c

File tree

3 files changed

+60
-6
lines changed

3 files changed

+60
-6
lines changed
 

‎BUILDING.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Support is divided into three tiers:
3737
|--------------|--------------|----------------------------------|----------------------|------------------|
3838
| GNU/Linux | Tier 1 | kernel >= 2.6.18, glibc >= 2.5 | x86, x64, arm, arm64 | |
3939
| macOS | Tier 1 | >= 10.10 | x64 | |
40-
| Windows | Tier 1 | >= Windows 7 or >= Windows2008R2 | x86, x64 | |
40+
| Windows | Tier 1 | >= Windows 7 / 2008 R2 | x86, x64 | vs2015 or vs2017 |
4141
| SmartOS | Tier 2 | >= 15 < 16.4 | x86, x64 | see note1 |
4242
| FreeBSD | Tier 2 | >= 10 | x64 | |
4343
| GNU/Linux | Tier 2 | kernel >= 3.13.0, glibc >= 2.19 | ppc64le >=power8 | |
@@ -175,6 +175,8 @@ Prerequisites:
175175
* [Visual Studio 2015 Update 3](https://www.visualstudio.com/), all editions
176176
including the Community edition (remember to select
177177
"Common Tools for Visual C++ 2015" feature during installation).
178+
* [Visual Studio 2017](https://www.visualstudio.com/downloads/), any edition (including the Build Tools SKU).
179+
__Required Components:__ "MSbuild", "VC++ 2017 v141 toolset" and one of the Windows SDKs (10 or 8.1).
178180
* Basic Unix tools required for some tests,
179181
[Git for Windows](http://git-scm.com/download/win) includes Git Bash
180182
and tools which can be included in the global `PATH`.
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
:: Copyright 2017 - Refael Ackermann
2+
:: Distributed under MIT style license
3+
:: See accompanying file LICENSE at https://github.com/node4good/windows-autoconf
4+
:: version: 1.14.0
5+
6+
@if not defined DEBUG_HELPER @ECHO OFF
7+
setlocal
8+
set VSWHERE_REQ=-requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64
9+
set VSWHERE_PRP=-property installationPath
10+
set VSWHERE_LMT=-version "[15.0,16.0)"
11+
SET VSWHERE_ARGS=-latest -products * %VSWHERE_REQ% %VSWHERE_PRP% %VSWHERE_LMT%
12+
set "VSWHERE=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer"
13+
if not exist "%VSWHERE%" set "VSWHERE=%ProgramFiles%\Microsoft Visual Studio\Installer"
14+
if not exist "%VSWHERE%" exit /B 1
15+
set Path=%Path%;%VSWHERE%
16+
for /f "usebackq tokens=*" %%i in (`vswhere %VSWHERE_ARGS%`) do (
17+
endlocal
18+
set "VCINSTALLDIR=%%i\VC\"
19+
set "VS150COMNTOOLS=%%i\Common7\Tools\"
20+
exit /B 0)

‎vcbuild.bat

+37-5
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ if /i "%1"=="/?" goto help
1515
set config=Release
1616
set target=Build
1717
set target_arch=x64
18-
set target_env=
18+
set target_env=vs2015
1919
set noprojgen=
2020
set nobuild=
2121
set sign=
@@ -53,7 +53,10 @@ if /i "%1"=="clean" set target=Clean&goto arg-ok
5353
if /i "%1"=="ia32" set target_arch=x86&goto arg-ok
5454
if /i "%1"=="x86" set target_arch=x86&goto arg-ok
5555
if /i "%1"=="x64" set target_arch=x64&goto arg-ok
56-
if /i "%1"=="vc2015" set target_env=vc2015&goto arg-ok
56+
@rem args should be vs2017 and vs2015. keeping vc2015 for backward combatibility (undocumented)
57+
if /i "%1"=="vc2015" set target_env=vs2015&goto arg-ok
58+
if /i "%1"=="vs2015" set target_env=vs2015&goto arg-ok
59+
if /i "%1"=="vs2017" set target_env=vs2017&goto arg-ok
5760
if /i "%1"=="noprojgen" set noprojgen=1&goto arg-ok
5861
if /i "%1"=="nobuild" set nobuild=1&goto arg-ok
5962
if /i "%1"=="nosign" set "sign="&echo Note: vcbuild no longer signs by default. "nosign" is redundant.&goto arg-ok
@@ -88,7 +91,7 @@ if /i "%1"=="upload" set upload=1&goto arg-ok
8891
if /i "%1"=="small-icu" set i18n_arg=%1&goto arg-ok
8992
if /i "%1"=="full-icu" set i18n_arg=%1&goto arg-ok
9093
if /i "%1"=="intl-none" set i18n_arg=%1&goto arg-ok
91-
if /i "%1"=="without-intl" set i18n_arg=%1&goto arg-ok
94+
if /i "%1"=="without-intl" set i18n_arg=%1&goto arg-ok
9295
if /i "%1"=="download-all" set download_arg="--download=all"&goto arg-ok
9396
if /i "%1"=="ignore-flaky" set test_args=%test_args% --flaky-tests=dontcare&goto arg-ok
9497
if /i "%1"=="enable-vtune" set enable_vtune_arg=1&goto arg-ok
@@ -149,7 +152,33 @@ if defined noprojgen if defined nobuild if not defined sign if not defined msi g
149152

150153
@rem Set environment for msbuild
151154

155+
set msvs_host_arch=x86
156+
if _%PROCESSOR_ARCHITECTURE%_==_AMD64_ set msvs_host_arch=amd64
157+
if _%PROCESSOR_ARCHITEW6432%_==_AMD64_ set msvs_host_arch=amd64
158+
@rem usualy vcvarsall takes an argument: host + '_' + target
159+
set vcvarsall_arg=%msvs_host_arch%_%target_arch%
160+
@rem unless both host and taget are x64
161+
if %target_arch%==x64 if %msvs_host_arch%==amd64 set vcvarsall_arg=amd64
162+
163+
@rem Look for Visual Studio 2017
164+
:vs-set-2017
165+
if "%target_env%" NEQ "vs2017" goto vs-set-2015
166+
echo Looking for Visual Studio 2017
167+
if "_%VSCMD_ARG_TGT_ARCH%_"=="_%target_arch%_" goto found_vs2017
168+
call tools\msvs\vswhere_usability_wrapper.cmd
169+
if "_%VCINSTALLDIR%_" == "__" goto vs-set-2015
170+
set vcvars_call="%VCINSTALLDIR%\Auxiliary\Build\vcvarsall.bat" %vcvarsall_arg%
171+
echo calling: %vcvars_call%
172+
call %vcvars_call%
173+
:found_vs2017
174+
echo Found MSVS version %VisualStudioVersion%
175+
set GYP_MSVS_VERSION=2017
176+
set PLATFORM_TOOLSET=v141
177+
goto msbuild-found
178+
152179
@rem Look for Visual Studio 2015
180+
:vs-set-2015
181+
if "%target_env%" NEQ "vs2015" goto msbuild-not-found
153182
echo Looking for Visual Studio 2015
154183
if not defined VS140COMNTOOLS goto msbuild-not-found
155184
if not exist "%VS140COMNTOOLS%\..\..\vc\vcvarsall.bat" goto msbuild-not-found
@@ -172,7 +201,9 @@ set PLATFORM_TOOLSET=v140
172201
goto msbuild-found
173202

174203
:msbuild-not-found
175-
echo Failed to find Visual Studio installation.
204+
echo Failed to find a suitable Visual Studio installation.
205+
echo Try to run in a "Developer Command Prompt" or consult
206+
echo https://github.com/nodejs/node/blob/master/BUILDING.md#windows-1
176207
goto exit
177208

178209
:wix-not-found
@@ -298,6 +329,7 @@ if not defined SSHCONFIG (
298329
echo SSHCONFIG is not set for upload
299330
exit /b 1
300331
)
332+
301333
if not defined STAGINGSERVER set STAGINGSERVER=node-www
302334
ssh -F %SSHCONFIG% %STAGINGSERVER% "mkdir -p nodejs/%DISTTYPEDIR%/v%FULLVERSION%/win-%target_arch%"
303335
scp -F %SSHCONFIG% Release\node.exe %STAGINGSERVER%:nodejs/%DISTTYPEDIR%/v%FULLVERSION%/win-%target_arch%/node.exe
@@ -455,7 +487,7 @@ echo Failed to create vc project files.
455487
goto exit
456488

457489
:help
458-
echo vcbuild.bat [debug/release] [msi] [test-all/test-uv/test-inspector/test-internet/test-pummel/test-simple/test-message] [clean] [noprojgen] [small-icu/full-icu/without-intl] [nobuild] [sign] [x86/x64] [vc2015] [download-all] [enable-vtune] [lint/lint-ci] [no-NODE-OPTIONS]
490+
echo vcbuild.bat [debug/release] [msi] [test-all/test-uv/test-inspector/test-internet/test-pummel/test-simple/test-message] [clean] [noprojgen] [small-icu/full-icu/without-intl] [nobuild] [sign] [x86/x64] [vs2015/vs2017] [download-all] [enable-vtune] [lint/lint-ci] [no-NODE-OPTIONS]
459491
echo Examples:
460492
echo vcbuild.bat : builds release build
461493
echo vcbuild.bat debug : builds debug build

0 commit comments

Comments
 (0)
Please sign in to comment.