Chromium Code Reviews| 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. Return None if the location was not | |
|
scottmg
2012/05/08 20:54:26
Not returning anything, maybe just "... variable,
alexeypa (please no reviews)
2012/05/08 20:58:25
Done.
| |
| 139 # found. | |
| 140 self.wdk_dir = os.environ.get('WDK_DIR') | |
| 141 | |
| 137 supported_fields = [ | 142 supported_fields = [ |
| 138 ('msvs_configuration_attributes', dict), | 143 ('msvs_configuration_attributes', dict), |
| 139 ('msvs_settings', dict), | 144 ('msvs_settings', dict), |
| 140 ('msvs_system_include_dirs', list), | 145 ('msvs_system_include_dirs', list), |
| 141 ('msvs_disabled_warnings', list), | 146 ('msvs_disabled_warnings', list), |
| 142 ] | 147 ] |
| 143 configs = spec['configurations'] | 148 configs = spec['configurations'] |
| 144 for field, default in supported_fields: | 149 for field, default in supported_fields: |
| 145 setattr(self, field, {}) | 150 setattr(self, field, {}) |
| 146 for configname, config in configs.iteritems(): | 151 for configname, config in configs.iteritems(): |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 159 '$(InputPath)': '${source}', | 164 '$(InputPath)': '${source}', |
| 160 '$(InputName)': '${root}', | 165 '$(InputName)': '${root}', |
| 161 '$(ProjectName)': self.spec['target_name'], | 166 '$(ProjectName)': self.spec['target_name'], |
| 162 '$(PlatformName)': 'Win32', # TODO(scottmg): Support for x64 toolchain. | 167 '$(PlatformName)': 'Win32', # TODO(scottmg): Support for x64 toolchain. |
| 163 } | 168 } |
| 164 # Chromium uses DXSDK_DIR in include/lib paths, but it may or may not be | 169 # 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 | 170 # 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 | 171 # 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. | 172 # 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 '' | 173 replacements['$(DXSDK_DIR)'] = self.dxsdk_dir if self.dxsdk_dir else '' |
| 174 replacements['$(WDK_DIR)'] = self.wdk_dir if self.wdk_dir else '' | |
| 169 return replacements | 175 return replacements |
| 170 | 176 |
| 171 def ConvertVSMacros(self, s, base_to_build=None): | 177 def ConvertVSMacros(self, s, base_to_build=None): |
| 172 """Convert from VS macro names to something equivalent.""" | 178 """Convert from VS macro names to something equivalent.""" |
| 173 env = self.GetVSMacroEnv(base_to_build) | 179 env = self.GetVSMacroEnv(base_to_build) |
| 174 return ExpandMacros(s, env) | 180 return ExpandMacros(s, env) |
| 175 | 181 |
| 176 def AdjustLibraries(self, libraries): | 182 def AdjustLibraries(self, libraries): |
| 177 """Strip -l from library if it's specified with that.""" | 183 """Strip -l from library if it's specified with that.""" |
| 178 return [lib[2:] if lib.startswith('-l') else lib for lib in libraries] | 184 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() | 469 return vs.SetupScript() |
| 464 | 470 |
| 465 def ExpandMacros(string, expansions): | 471 def ExpandMacros(string, expansions): |
| 466 """Expand $(Variable) per expansions dict. See MsvsSettings.GetVSMacroEnv | 472 """Expand $(Variable) per expansions dict. See MsvsSettings.GetVSMacroEnv |
| 467 for the canonical way to retrieve a suitable dict.""" | 473 for the canonical way to retrieve a suitable dict.""" |
| 468 if '$' in string: | 474 if '$' in string: |
| 469 for old, new in expansions.iteritems(): | 475 for old, new in expansions.iteritems(): |
| 470 assert '$(' not in new, new | 476 assert '$(' not in new, new |
| 471 string = string.replace(old, new) | 477 string = string.replace(old, new) |
| 472 return string | 478 return string |
| OLD | NEW |