Skip to content

Commit

Permalink
gyp: show descriptive Windows SDK detection error
Browse files Browse the repository at this point in the history
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 <mark@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
  • Loading branch information
jaimecbernardo authored and Commit Bot committed Aug 7, 2017
1 parent 4801a53 commit 324dd16
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions pylib/gyp/generator/msvs.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,19 @@ def _ConfigWindowsTargetPlatformVersion(config_data, version):
continue
version = MSVSVersion._RegistryGetValue(key % ver, 'ProductVersion') or ''
# Find a matching entry in sdk_dir\include.
names = sorted([x for x in os.listdir(r'%s\include' % sdk_dir)
expected_sdk_dir=r'%s\include' % sdk_dir
names = sorted([x for x in (os.listdir(expected_sdk_dir)
if os.path.isdir(expected_sdk_dir)
else []
)
if x.startswith(version)], reverse=True)
return names[0]
if names:
return names[0]
else:
print >> sys.stdout, (
'Warning: No include files found for '
'detected Windows SDK version %s' % (version)
)


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

if platform_name == 'ARM':
Expand Down

0 comments on commit 324dd16

Please sign in to comment.