OLD | NEW |
1 # Copyright (c) 2012 Google Inc. All rights reserved. | 1 # Copyright (c) 2012 Google Inc. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """ | 5 """ |
6 This module helps emulate Visual Studio 2008 behavior on top of other | 6 This module helps emulate Visual Studio 2008 behavior on top of other |
7 build systems, primarily ninja. | 7 build systems, primarily ninja. |
8 """ | 8 """ |
9 | 9 |
10 import os | 10 import os |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 class MsvsSettings(object): | 127 class MsvsSettings(object): |
128 """A class that understands the gyp 'msvs_...' values (especially the | 128 """A class that understands the gyp 'msvs_...' values (especially the |
129 msvs_settings field). They largely correpond to the VS2008 IDE DOM. This | 129 msvs_settings field). They largely correpond to the VS2008 IDE DOM. This |
130 class helps map those settings to command line options.""" | 130 class helps map those settings to command line options.""" |
131 | 131 |
132 def __init__(self, spec, generator_flags): | 132 def __init__(self, spec, generator_flags): |
133 self.spec = spec | 133 self.spec = spec |
134 self.vs_version = GetVSVersion(generator_flags) | 134 self.vs_version = GetVSVersion(generator_flags) |
135 self.dxsdk_dir = _FindDirectXInstallation() | 135 self.dxsdk_dir = _FindDirectXInstallation() |
136 | 136 |
| 137 # Try to find an installation location for the Windows DDK by checking |
| 138 # the WDK_DIR environment variable, may be None. |
| 139 self.wdk_dir = os.environ.get('WDK_DIR') |
| 140 |
137 supported_fields = [ | 141 supported_fields = [ |
138 ('msvs_configuration_attributes', dict), | 142 ('msvs_configuration_attributes', dict), |
139 ('msvs_settings', dict), | 143 ('msvs_settings', dict), |
140 ('msvs_system_include_dirs', list), | 144 ('msvs_system_include_dirs', list), |
141 ('msvs_disabled_warnings', list), | 145 ('msvs_disabled_warnings', list), |
142 ] | 146 ] |
143 configs = spec['configurations'] | 147 configs = spec['configurations'] |
144 for field, default in supported_fields: | 148 for field, default in supported_fields: |
145 setattr(self, field, {}) | 149 setattr(self, field, {}) |
146 for configname, config in configs.iteritems(): | 150 for configname, config in configs.iteritems(): |
(...skipping 12 matching lines...) Expand all Loading... |
159 '$(InputPath)': '${source}', | 163 '$(InputPath)': '${source}', |
160 '$(InputName)': '${root}', | 164 '$(InputName)': '${root}', |
161 '$(ProjectName)': self.spec['target_name'], | 165 '$(ProjectName)': self.spec['target_name'], |
162 '$(PlatformName)': 'Win32', # TODO(scottmg): Support for x64 toolchain. | 166 '$(PlatformName)': 'Win32', # TODO(scottmg): Support for x64 toolchain. |
163 } | 167 } |
164 # Chromium uses DXSDK_DIR in include/lib paths, but it may or may not be | 168 # Chromium uses DXSDK_DIR in include/lib paths, but it may or may not be |
165 # set. This happens when the SDK is sync'd via src-internal, rather than | 169 # set. This happens when the SDK is sync'd via src-internal, rather than |
166 # by typical end-user installation of the SDK. If it's not set, we don't | 170 # by typical end-user installation of the SDK. If it's not set, we don't |
167 # want to leave the unexpanded variable in the path, so simply strip it. | 171 # want to leave the unexpanded variable in the path, so simply strip it. |
168 replacements['$(DXSDK_DIR)'] = self.dxsdk_dir if self.dxsdk_dir else '' | 172 replacements['$(DXSDK_DIR)'] = self.dxsdk_dir if self.dxsdk_dir else '' |
| 173 replacements['$(WDK_DIR)'] = self.wdk_dir if self.wdk_dir else '' |
169 return replacements | 174 return replacements |
170 | 175 |
171 def ConvertVSMacros(self, s, base_to_build=None): | 176 def ConvertVSMacros(self, s, base_to_build=None): |
172 """Convert from VS macro names to something equivalent.""" | 177 """Convert from VS macro names to something equivalent.""" |
173 env = self.GetVSMacroEnv(base_to_build) | 178 env = self.GetVSMacroEnv(base_to_build) |
174 return ExpandMacros(s, env) | 179 return ExpandMacros(s, env) |
175 | 180 |
176 def AdjustLibraries(self, libraries): | 181 def AdjustLibraries(self, libraries): |
177 """Strip -l from library if it's specified with that.""" | 182 """Strip -l from library if it's specified with that.""" |
178 return [lib[2:] if lib.startswith('-l') else lib for lib in libraries] | 183 return [lib[2:] if lib.startswith('-l') else lib for lib in libraries] |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 return vs.SetupScript() | 468 return vs.SetupScript() |
464 | 469 |
465 def ExpandMacros(string, expansions): | 470 def ExpandMacros(string, expansions): |
466 """Expand $(Variable) per expansions dict. See MsvsSettings.GetVSMacroEnv | 471 """Expand $(Variable) per expansions dict. See MsvsSettings.GetVSMacroEnv |
467 for the canonical way to retrieve a suitable dict.""" | 472 for the canonical way to retrieve a suitable dict.""" |
468 if '$' in string: | 473 if '$' in string: |
469 for old, new in expansions.iteritems(): | 474 for old, new in expansions.iteritems(): |
470 assert '$(' not in new, new | 475 assert '$(' not in new, new |
471 string = string.replace(old, new) | 476 string = string.replace(old, new) |
472 return string | 477 return string |
OLD | NEW |