|
| 1 | +From 07277334521c3194b4415fad63ace78c13c42e34 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Bartosz Sosnowski <bartosz@janeasystems.com> |
| 3 | +Date: Mon, 30 Jan 2017 15:33:29 +0100 |
| 4 | +Subject: [PATCH] Add support for VS2017 to GYP |
| 5 | + |
| 6 | +Adds support for generating solutions and building with Visual Studio 2017 |
| 7 | +--- |
| 8 | + gyp/pylib/gyp/MSVSVersion.py | 31 ++++++++++++++++++++++++++++--- |
| 9 | + gyp/pylib/gyp/generator/msvs.py | 10 ++++++++-- |
| 10 | + 2 files changed, 36 insertions(+), 5 deletions(-) |
| 11 | + |
| 12 | +diff --git a/gyp/pylib/gyp/MSVSVersion.py b/gyp/pylib/gyp/MSVSVersion.py |
| 13 | +index edaf6ee..e34ebc5 100644 |
| 14 | +--- a/gyp/pylib/gyp/MSVSVersion.py |
| 15 | ++++ b/gyp/pylib/gyp/MSVSVersion.py |
| 16 | +@@ -86,6 +86,10 @@ class VisualStudioVersion(object): |
| 17 | + # vcvars32, which it can only find if VS??COMNTOOLS is set, which it |
| 18 | + # isn't always. |
| 19 | + if target_arch == 'x86': |
| 20 | ++ if self.short_name == '2017': |
| 21 | ++ return [os.path.normpath( |
| 22 | ++ ps.path.join(self.path, 'Common7/Tools/VsDevCmd.bat')), '/no_logo', |
| 23 | ++ '/arch=x86'] |
| 24 | + if self.short_name >= '2013' and self.short_name[-1] != 'e' and ( |
| 25 | + os.environ.get('PROCESSOR_ARCHITECTURE') == 'AMD64' or |
| 26 | + os.environ.get('PROCESSOR_ARCHITEW6432') == 'AMD64'): |
| 27 | +@@ -98,6 +102,10 @@ class VisualStudioVersion(object): |
| 28 | + os.path.join(self.path, 'Common7/Tools/vsvars32.bat'))] |
| 29 | + else: |
| 30 | + assert target_arch == 'x64' |
| 31 | ++ if self.short_name == '2017': |
| 32 | ++ return [os.path.normpath( |
| 33 | ++ ps.path.join(self.path, 'Common7/Tools/VsDevCmd.bat')), '/no_logo', |
| 34 | ++ '/arch=x64'] |
| 35 | + arg = 'x86_amd64' |
| 36 | + # Use the 64-on-64 compiler if we're not using an express |
| 37 | + # edition and we're running on a 64bit OS. |
| 38 | +@@ -236,6 +244,15 @@ def _CreateVersion(name, path, sdk_based=False): |
| 39 | + if path: |
| 40 | + path = os.path.normpath(path) |
| 41 | + versions = { |
| 42 | ++ '2017': VisualStudioVersion('2017', |
| 43 | ++ 'Visual Studio 2017', |
| 44 | ++ solution_version='12.00', |
| 45 | ++ project_version='14.0', |
| 46 | ++ flat_sln=False, |
| 47 | ++ uses_vcxproj=True, |
| 48 | ++ path=path, |
| 49 | ++ sdk_based=sdk_based, |
| 50 | ++ default_toolset='v141'), |
| 51 | + '2015': VisualStudioVersion('2015', |
| 52 | + 'Visual Studio 2015', |
| 53 | + solution_version='12.00', |
| 54 | +@@ -356,6 +373,7 @@ def _DetectVisualStudioVersions(versions_to_check, force_express): |
| 55 | + 2012(e) - Visual Studio 2012 (11) |
| 56 | + 2013(e) - Visual Studio 2013 (12) |
| 57 | + 2015 - Visual Studio 2015 (14) |
| 58 | ++ 2017 - Visual Studio 2017 (15) |
| 59 | + Where (e) is e for express editions of MSVS and blank otherwise. |
| 60 | + """ |
| 61 | + version_to_year = { |
| 62 | +@@ -365,6 +383,7 @@ def _DetectVisualStudioVersions(versions_to_check, force_express): |
| 63 | + '11.0': '2012', |
| 64 | + '12.0': '2013', |
| 65 | + '14.0': '2015', |
| 66 | ++ '15.0': '2017' |
| 67 | + } |
| 68 | + versions = [] |
| 69 | + for version in versions_to_check: |
| 70 | +@@ -395,13 +414,18 @@ def _DetectVisualStudioVersions(versions_to_check, force_express): |
| 71 | + |
| 72 | + # The old method above does not work when only SDK is installed. |
| 73 | + keys = [r'HKLM\Software\Microsoft\VisualStudio\SxS\VC7', |
| 74 | +- r'HKLM\Software\Wow6432Node\Microsoft\VisualStudio\SxS\VC7'] |
| 75 | ++ r'HKLM\Software\Wow6432Node\Microsoft\VisualStudio\SxS\VC7', |
| 76 | ++ r'HKLM\Software\Microsoft\VisualStudio\SxS\VS7', |
| 77 | ++ r'HKLM\Software\Wow6432Node\Microsoft\VisualStudio\SxS\VS7'] |
| 78 | + for index in range(len(keys)): |
| 79 | + path = _RegistryGetValue(keys[index], version) |
| 80 | + if not path: |
| 81 | + continue |
| 82 | + path = _ConvertToCygpath(path) |
| 83 | +- if version != '14.0': # There is no Express edition for 2015. |
| 84 | ++ if version == '15.0': |
| 85 | ++ if os.path.exists(path): |
| 86 | ++ versions.append(_CreateVersion('2017', path)) |
| 87 | ++ elif version != '14.0': # There is no Express edition for 2015. |
| 88 | + versions.append(_CreateVersion(version_to_year[version] + 'e', |
| 89 | + os.path.join(path, '..'), sdk_based=True)) |
| 90 | + |
| 91 | +@@ -420,7 +444,7 @@ def SelectVisualStudioVersion(version='auto', allow_fallback=True): |
| 92 | + if version == 'auto': |
| 93 | + version = os.environ.get('GYP_MSVS_VERSION', 'auto') |
| 94 | + version_map = { |
| 95 | +- 'auto': ('14.0', '12.0', '10.0', '9.0', '8.0', '11.0'), |
| 96 | ++ 'auto': ('15.0', '14.0', '12.0', '10.0', '9.0', '8.0', '11.0'), |
| 97 | + '2005': ('8.0',), |
| 98 | + '2005e': ('8.0',), |
| 99 | + '2008': ('9.0',), |
| 100 | +@@ -432,6 +456,7 @@ def SelectVisualStudioVersion(version='auto', allow_fallback=True): |
| 101 | + '2013': ('12.0',), |
| 102 | + '2013e': ('12.0',), |
| 103 | + '2015': ('14.0',), |
| 104 | ++ '2017': ('15.0',), |
| 105 | + } |
| 106 | + override_path = os.environ.get('GYP_MSVS_OVERRIDE_PATH') |
| 107 | + if override_path: |
| 108 | +diff --git a/gyp/pylib/gyp/generator/msvs.py b/gyp/pylib/gyp/generator/msvs.py |
| 109 | +index 25eb58e..d6a8ec7 100644 |
| 110 | +--- a/gyp/pylib/gyp/generator/msvs.py |
| 111 | ++++ b/gyp/pylib/gyp/generator/msvs.py |
| 112 | +@@ -2664,7 +2664,7 @@ def _GetMSBuildProjectConfigurations(configurations): |
| 113 | + return [group] |
| 114 | + |
| 115 | + |
| 116 | +-def _GetMSBuildGlobalProperties(spec, guid, gyp_file_name): |
| 117 | ++def _GetMSBuildGlobalProperties(spec, version, guid, gyp_file_name): |
| 118 | + namespace = os.path.splitext(gyp_file_name)[0] |
| 119 | + properties = [ |
| 120 | + ['PropertyGroup', {'Label': 'Globals'}, |
| 121 | +@@ -2712,6 +2712,11 @@ def _GetMSBuildGlobalProperties(spec, guid, gyp_file_name): |
| 122 | + _ConfigWindowsTargetPlatformVersion(configuration)) |
| 123 | + if platform_name and msvs_windows_sdk_version: |
| 124 | + break |
| 125 | ++ if msvs_windows_sdk_version == None and version.ShortName() == '2017': |
| 126 | ++ vs2017_sdk = '10.0.14393.0' |
| 127 | ++ vs2017_sdk = os.environ.get('vs2017_sdk', vs2017_sdk) |
| 128 | ++ if vs2017_sdk: |
| 129 | ++ msvs_windows_sdk_version = vs2017_sdk |
| 130 | + |
| 131 | + if platform_name == 'ARM': |
| 132 | + properties[0].append(['WindowsSDKDesktopARMSupport', 'true']) |
| 133 | +@@ -3366,7 +3371,8 @@ def _GenerateMSBuildProject(project, options, version, generator_flags): |
| 134 | + }] |
| 135 | + |
| 136 | + content += _GetMSBuildProjectConfigurations(configurations) |
| 137 | +- content += _GetMSBuildGlobalProperties(spec, project.guid, project_file_name) |
| 138 | ++ content += _GetMSBuildGlobalProperties(spec, version, project.guid, |
| 139 | ++ project_file_name) |
| 140 | + content += import_default_section |
| 141 | + content += _GetMSBuildConfigurationDetails(spec, project.build_file) |
| 142 | + if spec.get('msvs_enable_winphone'): |
| 143 | +-- |
| 144 | +2.11.0.windows.1 |
| 145 | + |
0 commit comments