Skip to content

Commit 324dd16

Browse files
jaimecbernardoCommit Bot
authored andcommitted
gyp: show descriptive Windows SDK detection error
When building with Visual Studio 2017, gyp may fail with a non-descriptive message if Windows has stale registry keys for a version of Windows SDK that was previously uninstalled. This commit adds a specific warning message when the directory for a detected SDK version doesn't exist and adds some Fixes to avoid Python crashes that were blocking the detection of other SDK versions: - Only try to run listdir on a path if it exists and is a dir. - Avoid accessing names[0] if it has no elements. - Use %s instead of %o to print compatible_sdks (to avoid TypeError, since %o is the octal number format specifier in Python and %s can be used as a generic format specifier for objects). Refs: nodejs/node#14597 Bug: nodejs/node#14103 Change-Id: Ifd50fe239f65b7b4a2d69c1c02038bada03066cb Reviewed-on: https://chromium-review.googlesource.com/602133 Reviewed-by: Mark Mentovai <[email protected]> Commit-Queue: Mark Mentovai <[email protected]>
1 parent 4801a53 commit 324dd16

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

pylib/gyp/generator/msvs.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,9 +306,19 @@ def _ConfigWindowsTargetPlatformVersion(config_data, version):
306306
continue
307307
version = MSVSVersion._RegistryGetValue(key % ver, 'ProductVersion') or ''
308308
# Find a matching entry in sdk_dir\include.
309-
names = sorted([x for x in os.listdir(r'%s\include' % sdk_dir)
309+
expected_sdk_dir=r'%s\include' % sdk_dir
310+
names = sorted([x for x in (os.listdir(expected_sdk_dir)
311+
if os.path.isdir(expected_sdk_dir)
312+
else []
313+
)
310314
if x.startswith(version)], reverse=True)
311-
return names[0]
315+
if names:
316+
return names[0]
317+
else:
318+
print >> sys.stdout, (
319+
'Warning: No include files found for '
320+
'detected Windows SDK version %s' % (version)
321+
)
312322

313323

314324
def _BuildCommandLineForRuleRaw(spec, cmd, cygwin_shell, has_input_path,
@@ -2721,7 +2731,7 @@ def _GetMSBuildGlobalProperties(spec, version, guid, gyp_file_name):
27212731
properties[0].append(['WindowsTargetPlatformVersion',
27222732
str(msvs_windows_sdk_version)])
27232733
elif version.compatible_sdks:
2724-
raise GypError('%s requires any SDK of %o version, but non were found' %
2734+
raise GypError('%s requires any SDK of %s version, but none were found' %
27252735
(version.description, version.compatible_sdks))
27262736

27272737
if platform_name == 'ARM':

0 commit comments

Comments
 (0)