Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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).

Fixes: #14103
  • Loading branch information
jaimecbernardo committed Aug 1, 2017
commit 4715d00bf96cf9f770d9e572656df97484e19cea
16 changes: 13 additions & 3 deletions tools/gyp/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 @@ -2718,7 +2728,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