Skip to content

Commit fefea6b

Browse files
committed
[personal] Make buildable on vs2017
1 parent 4aab082 commit fefea6b

File tree

8 files changed

+472
-45
lines changed

8 files changed

+472
-45
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,4 @@ icu_config.gypi
107107
# Xcode workspaces and project folders
108108
*.xcodeproj
109109
*.xcworkspace
110+
/*.log

BUILDING.md

Lines changed: 3 additions & 1 deletion
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 >= 4.2.0, glibc >= 2.19 | ppc64be | |
@@ -176,6 +176,8 @@ Prerequisites:
176176
* [Visual Studio 2015 Update 3](https://www.visualstudio.com/), all editions
177177
including the Community edition (remember to select
178178
"Common Tools for Visual C++ 2015" feature during installation).
179+
* [Visual Studio 2017](https://www.visualstudio.com/downloads/), any edition (including the Build Tools SKU).
180+
__Required Components:__ "MSbuild", "VC++ 2017 v141 toolset" and one of the Windows SDKs (10 or 8.1).
179181
* Basic Unix tools required for some tests,
180182
[Git for Windows](http://git-scm.com/download/win) includes Git Bash
181183
and tools which can be included in the global `PATH`.

common.gypi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@
233233
'SuppressStartupBanner': 'true',
234234
},
235235
},
236-
'msvs_disabled_warnings': [4351, 4355, 4800],
236+
'msvs_disabled_warnings': [4351, 4355, 4800, 4251, 4244, 4312, 4275],
237237
'conditions': [
238238
['asan == 1 and OS != "mac"', {
239239
'cflags+': [

configure

Lines changed: 39 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,12 @@ parser.add_option('-C',
489489
dest='compile_commands_json',
490490
help=optparse.SUPPRESS_HELP)
491491

492+
parser.add_option('--verbose',
493+
action='store_true',
494+
dest='verbose',
495+
default=False,
496+
help='make output more verbose')
497+
492498
(options, args) = parser.parse_args()
493499

494500
# Expand ~ in the install prefix now, it gets written to multiple files.
@@ -1004,10 +1010,21 @@ def configure_static(o):
10041010
if options.enable_asan:
10051011
o['libraries'] += ['-static-libasan']
10061012

1013+
def config_vs2017(o):
1014+
if os.environ.get('VisualStudioVersion') != '15.0': return
1015+
sdk_ver = os.environ.get('WindowsSDKVersion', '').rstrip("\\")
1016+
if not sdk_ver:
1017+
print(' Error: could not find a compatible SDK, ' +
1018+
'make sure you have either a Windows 10 or 8.1 SDK installed')
1019+
sys.exit(1)
1020+
o['msvs_windows_target_platform_version'] = sdk_ver
1021+
o['msbuild_toolset'] = 'v141'
1022+
10071023

10081024
def write(filename, data):
10091025
filename = os.path.join(root_dir, filename)
1010-
print('creating %s' % filename)
1026+
if options.verbose:
1027+
print('creating %s' % filename)
10111028
f = open(filename, 'w+')
10121029
f.write(data)
10131030

@@ -1027,7 +1044,8 @@ def glob_to_var(dir_base, dir_sub, patch_dir):
10271044
patchfile = '%s/%s/%s' % (dir_base, patch_dir, file)
10281045
if os.path.isfile(patchfile):
10291046
srcfile = '%s/%s' % (patch_dir, file)
1030-
print('Using version-specific floating patch %s' % patchfile)
1047+
if options.verbose:
1048+
print('Using version-specific floating patch %s' % patchfile)
10311049
list.append(srcfile)
10321050
break
10331051
return list
@@ -1054,11 +1072,14 @@ def configure_intl(o):
10541072
if nodedownload.candownload(auto_downloads, "icu"):
10551073
nodedownload.retrievefile(url, targetfile)
10561074
else:
1057-
print('Re-using existing %s' % targetfile)
1075+
if options.verbose:
1076+
print('Re-using existing %s' % targetfile)
10581077
if os.path.isfile(targetfile):
1059-
print('Checking file integrity with MD5:\r')
1078+
if options.verbose:
1079+
print('Checking file integrity with MD5:\r')
10601080
gotmd5 = nodedownload.md5sum(targetfile)
1061-
print('MD5: %s %s' % (gotmd5, targetfile))
1081+
if options.verbose:
1082+
print('MD5: %s %s' % (gotmd5, targetfile))
10621083
if (md5 == gotmd5):
10631084
return targetfile
10641085
else:
@@ -1073,8 +1094,7 @@ def configure_intl(o):
10731094
return
10741095

10751096
# write an empty file to start with
1076-
write(icu_config_name, do_not_edit +
1077-
pprint.pformat(icu_config, indent=2) + '\n')
1097+
write(icu_config_name, do_not_edit + pprint.pformat(icu_config, indent=2) + '\n')
10781098

10791099
# always set icu_small, node.gyp depends on it being defined.
10801100
o['variables']['icu_small'] = b(False)
@@ -1220,7 +1240,8 @@ def configure_intl(o):
12201240
print('(Fix, or disable with "--with-intl=none" )')
12211241
sys.exit(1)
12221242
else:
1223-
print('* Using ICU in %s' % icu_full_path)
1243+
if options.verbose:
1244+
print('* Using ICU in %s' % icu_full_path)
12241245
# Now, what version of ICU is it? We just need the "major", such as 54.
12251246
# uvernum.h contains it as a #define.
12261247
uvernum_h = os.path.join(icu_full_path, 'source/common/unicode/uvernum.h')
@@ -1284,8 +1305,7 @@ def configure_intl(o):
12841305
path = '../../%s/source/%s' % (icu_full_path, icu_src[i])
12851306
icu_config['variables'][var] = glob_to_var('tools/icu', path, 'patches/%s/source/%s' % (icu_ver_major, icu_src[i]) )
12861307
# write updated icu_config.gypi with a bunch of paths
1287-
write(icu_config_name, do_not_edit +
1288-
pprint.pformat(icu_config, indent=2) + '\n')
1308+
write(icu_config_name, do_not_edit + pprint.pformat(icu_config, indent=2) + '\n')
12891309
return # end of configure_intl
12901310

12911311
def configure_inspector(o):
@@ -1325,6 +1345,7 @@ configure_openssl(output)
13251345
configure_intl(output)
13261346
configure_static(output)
13271347
configure_inspector(output)
1348+
config_vs2017(output)
13281349

13291350
# variables should be a root level element,
13301351
# move everything else to target_defaults
@@ -1337,8 +1358,7 @@ config_fips = { 'make_global_settings' : [] }
13371358
if 'make_fips_settings' in output:
13381359
config_fips['make_global_settings'] = output['make_fips_settings']
13391360
del output['make_fips_settings']
1340-
write('config_fips.gypi', do_not_edit +
1341-
pprint.pformat(config_fips, indent=2) + '\n')
1361+
write('config_fips.gypi', do_not_edit + pprint.pformat(config_fips, indent=2) + '\n')
13421362

13431363
# make_global_settings should be a root level element too
13441364
if 'make_global_settings' in output:
@@ -1354,10 +1374,10 @@ output = {
13541374
if make_global_settings:
13551375
output['make_global_settings'] = make_global_settings
13561376

1357-
pprint.pprint(output, indent=2)
1358-
1359-
write('config.gypi', do_not_edit +
1360-
pprint.pformat(output, indent=2) + '\n')
1377+
config_content = pprint.pformat(output, indent=2)
1378+
if options.verbose:
1379+
print(config_content)
1380+
write('config.gypi', do_not_edit + config_content + '\n')
13611381

13621382
config = {
13631383
'BUILDTYPE': 'Debug' if options.debug else 'Release',
@@ -1387,6 +1407,9 @@ else:
13871407
if options.compile_commands_json:
13881408
gyp_args += ['-f', 'compile_commands_json']
13891409

1410+
if options.verbose:
1411+
gyp_args += ['--verbose']
1412+
13901413
gyp_args += args
13911414

13921415
if warn.warned:

tools/gyp_node.py

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,14 @@
1313
output_dir = os.path.join(os.path.abspath(node_root), 'out')
1414

1515
def run_gyp(args):
16-
rc = gyp.main(args)
17-
if rc != 0:
18-
print 'Error running GYP'
19-
sys.exit(rc)
20-
21-
if __name__ == '__main__':
22-
args = sys.argv[1:]
23-
2416
# GYP bug.
2517
# On msvs it will crash if it gets an absolute path.
2618
# On Mac/make it will crash if it doesn't get an absolute path.
27-
if sys.platform == 'win32':
28-
args.append(os.path.join(node_root, 'node.gyp'))
29-
common_fn = os.path.join(node_root, 'common.gypi')
30-
options_fn = os.path.join(node_root, 'config.gypi')
31-
options_fips_fn = os.path.join(node_root, 'config_fips.gypi')
32-
else:
33-
args.append(os.path.join(os.path.abspath(node_root), 'node.gyp'))
34-
common_fn = os.path.join(os.path.abspath(node_root), 'common.gypi')
35-
options_fn = os.path.join(os.path.abspath(node_root), 'config.gypi')
36-
options_fips_fn = os.path.join(os.path.abspath(node_root), 'config_fips.gypi')
19+
arg_path = node_root if sys.platform == 'win32' else os.path.abspath(node_root)
20+
args.append(os.path.join(arg_path, 'node.gyp'))
21+
common_fn = os.path.join(arg_path, 'common.gypi')
22+
options_fn = os.path.join(arg_path, 'config.gypi')
23+
options_fips_fn = os.path.join(arg_path, 'config_fips.gypi')
3724

3825
if os.path.exists(common_fn):
3926
args.extend(['-I', common_fn])
@@ -58,10 +45,22 @@ def run_gyp(args):
5845
args.append('-Dlibrary=static_library')
5946

6047
# Don't compile with -B and -fuse-ld=, we don't bundle ld.gold. Can't be
61-
# set in common.gypi due to how deps/v8/build/toolchain.gypi uses them.
48+
# set in common.gypi due to deps/v8/build/toolchain.gypi overwriting them.
6249
args.append('-Dlinux_use_bundled_binutils=0')
6350
args.append('-Dlinux_use_bundled_gold=0')
6451
args.append('-Dlinux_use_gold_flags=0')
6552

53+
if '--verbose' in args:
54+
# TODO(refack) maybe set -D for `GYP` instead
55+
args.remove('--verbose')
56+
print('\nGYP args: {0}'.format(' '.join(args)))
57+
rc = gyp.main(args)
58+
if rc != 0:
59+
print 'Error running GYP'
60+
sys.exit(rc)
61+
62+
63+
if __name__ == '__main__':
64+
args = sys.argv[1:]
6665
gyp_args = list(args)
6766
run_gyp(gyp_args)

tools/msvs-com-helper/GetKey.ps1

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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.12.2
5+
6+
param (
7+
[Parameter(Mandatory=$false)]
8+
[string[]]$filters = "IsVcCompatible",
9+
[Parameter(Mandatory=$false)]
10+
[string[]]$keys = "VisualCppToolsCL",
11+
[Parameter(Mandatory=$false)]
12+
[switch]$Information
13+
)
14+
$invocation = (Get-Variable MyInvocation).Value
15+
cd (Split-Path $invocation.MyCommand.Path)
16+
if (-NOT (Test-Path 'Registry::HKEY_CLASSES_ROOT\CLSID\{177F0C4A-1CD3-4DE7-A32C-71DBBB9FA36D}')) { Exit 1 }
17+
Add-Type -Path GetVS2017Configuration.cs;
18+
$insts = [VisualStudioConfiguration.ComSurrogate]::QueryEx()
19+
if ($Information) {
20+
$insts | % { [Console]::Error.WriteLine('Found VS2017 "' +$_['Name'] + '" installed at "' + $_['InstallationPath'] + '"') }
21+
}
22+
$insts | % { $_.Add('Fail', @()) }
23+
foreach ($filter in $filters) {
24+
if ($filter -eq "*") { continue; }
25+
if ($filter -like "*=*") {
26+
$parts = $filter -Split "=";
27+
$filter = $parts[0];
28+
$criteria = $parts[1];
29+
$insts | % { if ($_.Get($filter) -ne $criteria) { $_['Fail'] += $filter } }
30+
} else {
31+
$insts | % { if (!($_.Get($filter))) { $_['Fail'] += $filter } }
32+
}
33+
}
34+
if ($Information) {
35+
$insts | % { if ($_['Fail'].length -ne 0) {[Console]::Error.WriteLine('"' +$_['Name'] + '" installed in "' + $_['InstallationPath'] + '" does not meet criteria "' + $_['Fail'] + '"') } }
36+
}
37+
$insts = $insts | where { $_['Fail'].length -eq 0 }
38+
foreach ($key in $keys) {
39+
if ($key -eq "*") { $insts | echo } else { $insts | % { $_.Get($key) } }
40+
}

0 commit comments

Comments
 (0)