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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 # the WDK_DIR environment variable, may be None. | 138 # the WDK_DIR environment variable, may be None. |
139 self.wdk_dir = os.environ.get('WDK_DIR') | 139 self.wdk_dir = os.environ.get('WDK_DIR') |
140 | 140 |
141 supported_fields = [ | 141 supported_fields = [ |
142 ('msvs_configuration_attributes', dict), | 142 ('msvs_configuration_attributes', dict), |
143 ('msvs_settings', dict), | 143 ('msvs_settings', dict), |
144 ('msvs_system_include_dirs', list), | 144 ('msvs_system_include_dirs', list), |
145 ('msvs_disabled_warnings', list), | 145 ('msvs_disabled_warnings', list), |
146 ('msvs_precompiled_header', str), | 146 ('msvs_precompiled_header', str), |
147 ('msvs_precompiled_source', str), | 147 ('msvs_precompiled_source', str), |
| 148 ('msvs_target_platform', str), |
148 ] | 149 ] |
149 configs = spec['configurations'] | 150 configs = spec['configurations'] |
150 for field, default in supported_fields: | 151 for field, default in supported_fields: |
151 setattr(self, field, {}) | 152 setattr(self, field, {}) |
152 for configname, config in configs.iteritems(): | 153 for configname, config in configs.iteritems(): |
153 getattr(self, field)[configname] = config.get(field, default()) | 154 getattr(self, field)[configname] = config.get(field, default()) |
154 | 155 |
155 self.msvs_cygwin_dirs = spec.get('msvs_cygwin_dirs', ['.']) | 156 self.msvs_cygwin_dirs = spec.get('msvs_cygwin_dirs', ['.']) |
156 | 157 |
157 def GetVSMacroEnv(self, base_to_build=None): | 158 def GetVSMacroEnv(self, base_to_build=None, config=None): |
158 """Get a dict of variables mapping internal VS macro names to their gyp | 159 """Get a dict of variables mapping internal VS macro names to their gyp |
159 equivalents.""" | 160 equivalents.""" |
| 161 target_platform = self.GetTargetPlatform(config) |
| 162 target_platform = {'x86': 'Win32'}.get(target_platform, target_platform) |
160 replacements = { | 163 replacements = { |
161 '$(VSInstallDir)': self.vs_version.Path(), | 164 '$(VSInstallDir)': self.vs_version.Path(), |
162 '$(VCInstallDir)': os.path.join(self.vs_version.Path(), 'VC') + '\\', | 165 '$(VCInstallDir)': os.path.join(self.vs_version.Path(), 'VC') + '\\', |
163 '$(OutDir)\\': base_to_build + '\\' if base_to_build else '', | 166 '$(OutDir)\\': base_to_build + '\\' if base_to_build else '', |
164 '$(IntDir)': '$!INTERMEDIATE_DIR', | 167 '$(IntDir)': '$!INTERMEDIATE_DIR', |
165 '$(InputPath)': '${source}', | 168 '$(InputPath)': '${source}', |
166 '$(InputName)': '${root}', | 169 '$(InputName)': '${root}', |
167 '$(ProjectName)': self.spec['target_name'], | 170 '$(ProjectName)': self.spec['target_name'], |
168 '$(PlatformName)': 'Win32', # TODO(scottmg): Support for x64 toolchain. | 171 '$(PlatformName)': target_platform, |
169 } | 172 } |
170 # Chromium uses DXSDK_DIR in include/lib paths, but it may or may not be | 173 # Chromium uses DXSDK_DIR in include/lib paths, but it may or may not be |
171 # set. This happens when the SDK is sync'd via src-internal, rather than | 174 # set. This happens when the SDK is sync'd via src-internal, rather than |
172 # by typical end-user installation of the SDK. If it's not set, we don't | 175 # by typical end-user installation of the SDK. If it's not set, we don't |
173 # want to leave the unexpanded variable in the path, so simply strip it. | 176 # want to leave the unexpanded variable in the path, so simply strip it. |
174 replacements['$(DXSDK_DIR)'] = self.dxsdk_dir if self.dxsdk_dir else '' | 177 replacements['$(DXSDK_DIR)'] = self.dxsdk_dir if self.dxsdk_dir else '' |
175 replacements['$(WDK_DIR)'] = self.wdk_dir if self.wdk_dir else '' | 178 replacements['$(WDK_DIR)'] = self.wdk_dir if self.wdk_dir else '' |
176 return replacements | 179 return replacements |
177 | 180 |
178 def ConvertVSMacros(self, s, base_to_build=None): | 181 def ConvertVSMacros(self, s, base_to_build=None, config=None): |
179 """Convert from VS macro names to something equivalent.""" | 182 """Convert from VS macro names to something equivalent.""" |
180 env = self.GetVSMacroEnv(base_to_build) | 183 env = self.GetVSMacroEnv(base_to_build, config=config) |
181 return ExpandMacros(s, env) | 184 return ExpandMacros(s, env) |
182 | 185 |
183 def AdjustLibraries(self, libraries): | 186 def AdjustLibraries(self, libraries): |
184 """Strip -l from library if it's specified with that.""" | 187 """Strip -l from library if it's specified with that.""" |
185 return [lib[2:] if lib.startswith('-l') else lib for lib in libraries] | 188 return [lib[2:] if lib.startswith('-l') else lib for lib in libraries] |
186 | 189 |
187 def _GetAndMunge(self, field, path, default, prefix, append, map): | 190 def _GetAndMunge(self, field, path, default, prefix, append, map): |
188 """Retrieve a value from |field| at |path| or return |default|. If | 191 """Retrieve a value from |field| at |path| or return |default|. If |
189 |append| is specified, and the item is found, it will be appended to that | 192 |append| is specified, and the item is found, it will be appended to that |
190 object instead of returned. If |map| is specified, results will be | 193 object instead of returned. If |map| is specified, results will be |
191 remapped through |map| before being returned or appended.""" | 194 remapped through |map| before being returned or appended.""" |
192 result = _GenericRetrieve(field, default, path) | 195 result = _GenericRetrieve(field, default, path) |
193 result = _DoRemapping(result, map) | 196 result = _DoRemapping(result, map) |
194 result = _AddPrefix(result, prefix) | 197 result = _AddPrefix(result, prefix) |
195 return _AppendOrReturn(append, result) | 198 return _AppendOrReturn(append, result) |
196 | 199 |
197 class _GetWrapper(object): | 200 class _GetWrapper(object): |
198 def __init__(self, parent, field, base_path, append=None): | 201 def __init__(self, parent, field, base_path, append=None): |
199 self.parent = parent | 202 self.parent = parent |
200 self.field = field | 203 self.field = field |
201 self.base_path = [base_path] | 204 self.base_path = [base_path] |
202 self.append = append | 205 self.append = append |
203 def __call__(self, name, map=None, prefix='', default=None): | 206 def __call__(self, name, map=None, prefix='', default=None): |
204 return self.parent._GetAndMunge(self.field, self.base_path + [name], | 207 return self.parent._GetAndMunge(self.field, self.base_path + [name], |
205 default=default, prefix=prefix, append=self.append, map=map) | 208 default=default, prefix=prefix, append=self.append, map=map) |
206 | 209 |
| 210 def GetTargetPlatform(self, config): |
| 211 target_platform = self.msvs_target_platform.get(config, '') |
| 212 if not target_platform: |
| 213 target_platform = 'Win32' |
| 214 return {'Win32': 'x86'}.get(target_platform, target_platform) |
| 215 |
| 216 def _RealConfig(self, config): |
| 217 target_platform = self.GetTargetPlatform(config) |
| 218 if target_platform == 'x64' and not config.endswith('_x64'): |
| 219 config += '_x64' |
| 220 return config |
| 221 |
207 def _Setting(self, path, config, | 222 def _Setting(self, path, config, |
208 default=None, prefix='', append=None, map=None): | 223 default=None, prefix='', append=None, map=None): |
209 """_GetAndMunge for msvs_settings.""" | 224 """_GetAndMunge for msvs_settings.""" |
| 225 config = self._RealConfig(config) |
210 return self._GetAndMunge( | 226 return self._GetAndMunge( |
211 self.msvs_settings[config], path, default, prefix, append, map) | 227 self.msvs_settings[config], path, default, prefix, append, map) |
212 | 228 |
213 def _ConfigAttrib(self, path, config, | 229 def _ConfigAttrib(self, path, config, |
214 default=None, prefix='', append=None, map=None): | 230 default=None, prefix='', append=None, map=None): |
215 """_GetAndMunge for msvs_configuration_attributes.""" | 231 """_GetAndMunge for msvs_configuration_attributes.""" |
| 232 config = self._RealConfig(config) |
216 return self._GetAndMunge( | 233 return self._GetAndMunge( |
217 self.msvs_configuration_attributes[config], | 234 self.msvs_configuration_attributes[config], |
218 path, default, prefix, append, map) | 235 path, default, prefix, append, map) |
219 | 236 |
220 def AdjustIncludeDirs(self, include_dirs, config): | 237 def AdjustIncludeDirs(self, include_dirs, config): |
221 """Updates include_dirs to expand VS specific paths, and adds the system | 238 """Updates include_dirs to expand VS specific paths, and adds the system |
222 include dirs used for platform SDK and similar.""" | 239 include dirs used for platform SDK and similar.""" |
| 240 config = self._RealConfig(config) |
223 includes = include_dirs + self.msvs_system_include_dirs[config] | 241 includes = include_dirs + self.msvs_system_include_dirs[config] |
224 includes.extend(self._Setting( | 242 includes.extend(self._Setting( |
225 ('VCCLCompilerTool', 'AdditionalIncludeDirectories'), config, default=[])) | 243 ('VCCLCompilerTool', 'AdditionalIncludeDirectories'), config, default=[])) |
226 return [self.ConvertVSMacros(p) for p in includes] | 244 return [self.ConvertVSMacros(p, config=config) for p in includes] |
227 | 245 |
228 def GetComputedDefines(self, config): | 246 def GetComputedDefines(self, config): |
229 """Returns the set of defines that are injected to the defines list based | 247 """Returns the set of defines that are injected to the defines list based |
230 on other VS settings.""" | 248 on other VS settings.""" |
| 249 config = self._RealConfig(config) |
231 defines = [] | 250 defines = [] |
232 if self._ConfigAttrib(['CharacterSet'], config) == '1': | 251 if self._ConfigAttrib(['CharacterSet'], config) == '1': |
233 defines.extend(('_UNICODE', 'UNICODE')) | 252 defines.extend(('_UNICODE', 'UNICODE')) |
234 if self._ConfigAttrib(['CharacterSet'], config) == '2': | 253 if self._ConfigAttrib(['CharacterSet'], config) == '2': |
235 defines.append('_MBCS') | 254 defines.append('_MBCS') |
236 defines.extend(self._Setting( | 255 defines.extend(self._Setting( |
237 ('VCCLCompilerTool', 'PreprocessorDefinitions'), config, default=[])) | 256 ('VCCLCompilerTool', 'PreprocessorDefinitions'), config, default=[])) |
238 return defines | 257 return defines |
239 | 258 |
240 def GetOutputName(self, config, expand_special): | 259 def GetOutputName(self, config, expand_special): |
241 """Gets the explicitly overridden output name for a target or returns None | 260 """Gets the explicitly overridden output name for a target or returns None |
242 if it's not overridden.""" | 261 if it's not overridden.""" |
| 262 config = self._RealConfig(config) |
243 type = self.spec['type'] | 263 type = self.spec['type'] |
244 root = 'VCLibrarianTool' if type == 'static_library' else 'VCLinkerTool' | 264 root = 'VCLibrarianTool' if type == 'static_library' else 'VCLinkerTool' |
245 # TODO(scottmg): Handle OutputDirectory without OutputFile. | 265 # TODO(scottmg): Handle OutputDirectory without OutputFile. |
246 output_file = self._Setting((root, 'OutputFile'), config) | 266 output_file = self._Setting((root, 'OutputFile'), config) |
247 if output_file: | 267 if output_file: |
248 output_file = expand_special(self.ConvertVSMacros(output_file)) | 268 output_file = expand_special(self.ConvertVSMacros( |
| 269 output_file, config=config)) |
249 return output_file | 270 return output_file |
250 | 271 |
251 def GetCflags(self, config): | 272 def GetCflags(self, config): |
252 """Returns the flags that need to be added to .c and .cc compilations.""" | 273 """Returns the flags that need to be added to .c and .cc compilations.""" |
| 274 config = self._RealConfig(config) |
253 cflags = [] | 275 cflags = [] |
254 cflags.extend(['/wd' + w for w in self.msvs_disabled_warnings[config]]) | 276 cflags.extend(['/wd' + w for w in self.msvs_disabled_warnings[config]]) |
255 cl = self._GetWrapper(self, self.msvs_settings[config], | 277 cl = self._GetWrapper(self, self.msvs_settings[config], |
256 'VCCLCompilerTool', append=cflags) | 278 'VCCLCompilerTool', append=cflags) |
257 cl('Optimization', | 279 cl('Optimization', |
258 map={'0': 'd', '1': '1', '2': '2', '3': 'x'}, prefix='/O') | 280 map={'0': 'd', '1': '1', '2': '2', '3': 'x'}, prefix='/O') |
259 cl('InlineFunctionExpansion', prefix='/Ob') | 281 cl('InlineFunctionExpansion', prefix='/Ob') |
260 cl('OmitFramePointers', map={'false': '-', 'true': ''}, prefix='/Oy') | 282 cl('OmitFramePointers', map={'false': '-', 'true': ''}, prefix='/Oy') |
261 cl('FavorSizeOrSpeed', map={'1': 't', '2': 's'}, prefix='/O') | 283 cl('FavorSizeOrSpeed', map={'1': 't', '2': 's'}, prefix='/O') |
262 cl('WholeProgramOptimization', map={'true': '/GL'}) | 284 cl('WholeProgramOptimization', map={'true': '/GL'}) |
(...skipping 10 matching lines...) Expand all Loading... |
273 map={'0': 'T', '1': 'Td', '2': 'D', '3': 'Dd'}, prefix='/M') | 295 map={'0': 'T', '1': 'Td', '2': 'D', '3': 'Dd'}, prefix='/M') |
274 cl('ExceptionHandling', map={'1': 'sc','2': 'a'}, prefix='/EH') | 296 cl('ExceptionHandling', map={'1': 'sc','2': 'a'}, prefix='/EH') |
275 cl('AdditionalOptions', prefix='') | 297 cl('AdditionalOptions', prefix='') |
276 # ninja handles parallelism by itself, don't have the compiler do it too. | 298 # ninja handles parallelism by itself, don't have the compiler do it too. |
277 cflags = filter(lambda x: not x.startswith('/MP'), cflags) | 299 cflags = filter(lambda x: not x.startswith('/MP'), cflags) |
278 return cflags | 300 return cflags |
279 | 301 |
280 def GetPrecompiledHeader(self, config, gyp_to_build_path): | 302 def GetPrecompiledHeader(self, config, gyp_to_build_path): |
281 """Returns an object that handles the generation of precompiled header | 303 """Returns an object that handles the generation of precompiled header |
282 build steps.""" | 304 build steps.""" |
| 305 config = self._RealConfig(config) |
283 return _PchHelper(self, config, gyp_to_build_path) | 306 return _PchHelper(self, config, gyp_to_build_path) |
284 | 307 |
285 def _GetPchFlags(self, config, extension): | 308 def _GetPchFlags(self, config, extension): |
286 """Get the flags to be added to the cflags for precompiled header support. | 309 """Get the flags to be added to the cflags for precompiled header support. |
287 """ | 310 """ |
| 311 config = self._RealConfig(config) |
288 # The PCH is only built once by a particular source file. Usage of PCH must | 312 # The PCH is only built once by a particular source file. Usage of PCH must |
289 # only be for the same language (i.e. C vs. C++), so only include the pch | 313 # only be for the same language (i.e. C vs. C++), so only include the pch |
290 # flags when the language matches. | 314 # flags when the language matches. |
291 if self.msvs_precompiled_header[config]: | 315 if self.msvs_precompiled_header[config]: |
292 source_ext = os.path.splitext(self.msvs_precompiled_source[config])[1] | 316 source_ext = os.path.splitext(self.msvs_precompiled_source[config])[1] |
293 if _LanguageMatchesForPch(source_ext, extension): | 317 if _LanguageMatchesForPch(source_ext, extension): |
294 pch = os.path.split(self.msvs_precompiled_header[config])[1] | 318 pch = os.path.split(self.msvs_precompiled_header[config])[1] |
295 return ['/Yu' + pch, '/FI' + pch, '/Fp${pchprefix}.' + pch + '.pch'] | 319 return ['/Yu' + pch, '/FI' + pch, '/Fp${pchprefix}.' + pch + '.pch'] |
296 return [] | 320 return [] |
297 | 321 |
298 def GetCflagsC(self, config): | 322 def GetCflagsC(self, config): |
299 """Returns the flags that need to be added to .c compilations.""" | 323 """Returns the flags that need to be added to .c compilations.""" |
| 324 config = self._RealConfig(config) |
300 return self._GetPchFlags(config, '.c') | 325 return self._GetPchFlags(config, '.c') |
301 | 326 |
302 def GetCflagsCC(self, config): | 327 def GetCflagsCC(self, config): |
303 """Returns the flags that need to be added to .cc compilations.""" | 328 """Returns the flags that need to be added to .cc compilations.""" |
| 329 config = self._RealConfig(config) |
304 return ['/TP'] + self._GetPchFlags(config, '.cc') | 330 return ['/TP'] + self._GetPchFlags(config, '.cc') |
305 | 331 |
306 def _GetAdditionalLibraryDirectories(self, root, config, gyp_to_build_path): | 332 def _GetAdditionalLibraryDirectories(self, root, config, gyp_to_build_path): |
307 """Get and normalize the list of paths in AdditionalLibraryDirectories | 333 """Get and normalize the list of paths in AdditionalLibraryDirectories |
308 setting.""" | 334 setting.""" |
| 335 config = self._RealConfig(config) |
309 libpaths = self._Setting((root, 'AdditionalLibraryDirectories'), | 336 libpaths = self._Setting((root, 'AdditionalLibraryDirectories'), |
310 config, default=[]) | 337 config, default=[]) |
311 libpaths = [os.path.normpath(gyp_to_build_path(self.ConvertVSMacros(p))) | 338 libpaths = [os.path.normpath( |
| 339 gyp_to_build_path(self.ConvertVSMacros(p, config=config))) |
312 for p in libpaths] | 340 for p in libpaths] |
313 return ['/LIBPATH:"' + p + '"' for p in libpaths] | 341 return ['/LIBPATH:"' + p + '"' for p in libpaths] |
314 | 342 |
315 def GetLibFlags(self, config, gyp_to_build_path): | 343 def GetLibFlags(self, config, gyp_to_build_path): |
316 """Returns the flags that need to be added to lib commands.""" | 344 """Returns the flags that need to be added to lib commands.""" |
| 345 config = self._RealConfig(config) |
317 libflags = [] | 346 libflags = [] |
318 lib = self._GetWrapper(self, self.msvs_settings[config], | 347 lib = self._GetWrapper(self, self.msvs_settings[config], |
319 'VCLibrarianTool', append=libflags) | 348 'VCLibrarianTool', append=libflags) |
320 libflags.extend(self._GetAdditionalLibraryDirectories( | 349 libflags.extend(self._GetAdditionalLibraryDirectories( |
321 'VCLibrarianTool', config, gyp_to_build_path)) | 350 'VCLibrarianTool', config, gyp_to_build_path)) |
322 lib('AdditionalOptions') | 351 lib('AdditionalOptions') |
323 return libflags | 352 return libflags |
324 | 353 |
325 def _GetDefFileAsLdflags(self, spec, ldflags, gyp_to_build_path): | 354 def _GetDefFileAsLdflags(self, spec, ldflags, gyp_to_build_path): |
326 """.def files get implicitly converted to a ModuleDefinitionFile for the | 355 """.def files get implicitly converted to a ModuleDefinitionFile for the |
327 linker in the VS generator. Emulate that behaviour here.""" | 356 linker in the VS generator. Emulate that behaviour here.""" |
328 def_file = '' | 357 def_file = '' |
329 if spec['type'] in ('shared_library', 'loadable_module', 'executable'): | 358 if spec['type'] in ('shared_library', 'loadable_module', 'executable'): |
330 def_files = [s for s in spec.get('sources', []) if s.endswith('.def')] | 359 def_files = [s for s in spec.get('sources', []) if s.endswith('.def')] |
331 if len(def_files) == 1: | 360 if len(def_files) == 1: |
332 ldflags.append('/DEF:"%s"' % gyp_to_build_path(def_files[0])) | 361 ldflags.append('/DEF:"%s"' % gyp_to_build_path(def_files[0])) |
333 elif len(def_files) > 1: | 362 elif len(def_files) > 1: |
334 raise Exception("Multiple .def files") | 363 raise Exception("Multiple .def files") |
335 | 364 |
336 def GetLdflags(self, config, gyp_to_build_path, expand_special): | 365 def GetLdflags(self, config, gyp_to_build_path, expand_special): |
337 """Returns the flags that need to be added to link commands.""" | 366 """Returns the flags that need to be added to link commands.""" |
| 367 config = self._RealConfig(config) |
338 ldflags = [] | 368 ldflags = [] |
339 ld = self._GetWrapper(self, self.msvs_settings[config], | 369 ld = self._GetWrapper(self, self.msvs_settings[config], |
340 'VCLinkerTool', append=ldflags) | 370 'VCLinkerTool', append=ldflags) |
341 self._GetDefFileAsLdflags(self.spec, ldflags, gyp_to_build_path) | 371 self._GetDefFileAsLdflags(self.spec, ldflags, gyp_to_build_path) |
342 ld('GenerateDebugInformation', map={'true': '/DEBUG'}) | 372 ld('GenerateDebugInformation', map={'true': '/DEBUG'}) |
343 ld('TargetMachine', map={'1': 'X86', '17': 'X64'}, prefix='/MACHINE:') | 373 ld('TargetMachine', map={'1': 'X86', '17': 'X64'}, prefix='/MACHINE:') |
344 ldflags.extend(self._GetAdditionalLibraryDirectories( | 374 ldflags.extend(self._GetAdditionalLibraryDirectories( |
345 'VCLinkerTool', config, gyp_to_build_path)) | 375 'VCLinkerTool', config, gyp_to_build_path)) |
346 ld('DelayLoadDLLs', prefix='/DELAYLOAD:') | 376 ld('DelayLoadDLLs', prefix='/DELAYLOAD:') |
347 out = self.GetOutputName(config, expand_special) | 377 out = self.GetOutputName(config, expand_special) |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 # Vista or greater (which applies to the linker), the IDE defaults it on | 410 # Vista or greater (which applies to the linker), the IDE defaults it on |
381 # unless it's explicitly off. | 411 # unless it's explicitly off. |
382 if not filter(lambda x: 'NXCOMPAT' in x, ldflags): | 412 if not filter(lambda x: 'NXCOMPAT' in x, ldflags): |
383 ldflags.append('/NXCOMPAT') | 413 ldflags.append('/NXCOMPAT') |
384 | 414 |
385 return ldflags | 415 return ldflags |
386 | 416 |
387 def IsUseLibraryDependencyInputs(self, config): | 417 def IsUseLibraryDependencyInputs(self, config): |
388 """Returns whether the target should be linked via Use Library Dependency | 418 """Returns whether the target should be linked via Use Library Dependency |
389 Inputs (using component .objs of a given .lib).""" | 419 Inputs (using component .objs of a given .lib).""" |
| 420 config = self._RealConfig(config) |
390 uldi = self._Setting(('VCLinkerTool', 'UseLibraryDependencyInputs'), config) | 421 uldi = self._Setting(('VCLinkerTool', 'UseLibraryDependencyInputs'), config) |
391 return uldi == 'true' | 422 return uldi == 'true' |
392 | 423 |
393 def GetRcflags(self, config, gyp_to_ninja_path): | 424 def GetRcflags(self, config, gyp_to_ninja_path): |
394 """Returns the flags that need to be added to invocations of the resource | 425 """Returns the flags that need to be added to invocations of the resource |
395 compiler.""" | 426 compiler.""" |
| 427 config = self._RealConfig(config) |
396 rcflags = [] | 428 rcflags = [] |
397 rc = self._GetWrapper(self, self.msvs_settings[config], | 429 rc = self._GetWrapper(self, self.msvs_settings[config], |
398 'VCResourceCompilerTool', append=rcflags) | 430 'VCResourceCompilerTool', append=rcflags) |
399 rc('AdditionalIncludeDirectories', map=gyp_to_ninja_path, prefix='/I') | 431 rc('AdditionalIncludeDirectories', map=gyp_to_ninja_path, prefix='/I') |
400 rcflags.append('/I' + gyp_to_ninja_path('.')) | 432 rcflags.append('/I' + gyp_to_ninja_path('.')) |
401 rc('PreprocessorDefinitions', prefix='/d') | 433 rc('PreprocessorDefinitions', prefix='/d') |
402 # /l arg must be in hex without leading '0x' | 434 # /l arg must be in hex without leading '0x' |
403 rc('Culture', prefix='/l', map=lambda x: hex(int(x))[2:]) | 435 rc('Culture', prefix='/l', map=lambda x: hex(int(x))[2:]) |
404 return rcflags | 436 return rcflags |
405 | 437 |
(...skipping 27 matching lines...) Expand all Loading... |
433 """Determine if there's an explicit rule for idl files. When there isn't we | 465 """Determine if there's an explicit rule for idl files. When there isn't we |
434 need to generate implicit rules to build MIDL .idl files.""" | 466 need to generate implicit rules to build MIDL .idl files.""" |
435 for rule in spec.get('rules', []): | 467 for rule in spec.get('rules', []): |
436 if rule['extension'] == 'idl' and int(rule.get('msvs_external_rule', 0)): | 468 if rule['extension'] == 'idl' and int(rule.get('msvs_external_rule', 0)): |
437 return True | 469 return True |
438 return False | 470 return False |
439 | 471 |
440 def GetIdlBuildData(self, source, config): | 472 def GetIdlBuildData(self, source, config): |
441 """Determine the implicit outputs for an idl file. Returns output | 473 """Determine the implicit outputs for an idl file. Returns output |
442 directory, outputs, and variables and flags that are required.""" | 474 directory, outputs, and variables and flags that are required.""" |
| 475 config = self._RealConfig(config) |
443 midl_get = self._GetWrapper(self, self.msvs_settings[config], 'VCMIDLTool') | 476 midl_get = self._GetWrapper(self, self.msvs_settings[config], 'VCMIDLTool') |
444 def midl(name, default=None): | 477 def midl(name, default=None): |
445 return self.ConvertVSMacros(midl_get(name, default=default)) | 478 return self.ConvertVSMacros(midl_get(name, default=default), |
| 479 config=config) |
446 tlb = midl('TypeLibraryName', default='${root}.tlb') | 480 tlb = midl('TypeLibraryName', default='${root}.tlb') |
447 header = midl('HeaderFileName', default='${root}.h') | 481 header = midl('HeaderFileName', default='${root}.h') |
448 dlldata = midl('DLLDataFileName', default='dlldata.c') | 482 dlldata = midl('DLLDataFileName', default='dlldata.c') |
449 iid = midl('InterfaceIdentifierFileName', default='${root}_i.c') | 483 iid = midl('InterfaceIdentifierFileName', default='${root}_i.c') |
450 proxy = midl('ProxyFileName', default='${root}_p.c') | 484 proxy = midl('ProxyFileName', default='${root}_p.c') |
451 # Note that .tlb is not included in the outputs as it is not always | 485 # Note that .tlb is not included in the outputs as it is not always |
452 # generated depending on the content of the input idl file. | 486 # generated depending on the content of the input idl file. |
453 outdir = midl('OutputDirectory', default='') | 487 outdir = midl('OutputDirectory', default='') |
454 output = [header, dlldata, iid, proxy] | 488 output = [header, dlldata, iid, proxy] |
455 variables = [('tlb', tlb), | 489 variables = [('tlb', tlb), |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 args = vs.SetupScript(arch) | 629 args = vs.SetupScript(arch) |
596 args.extend(('&&', 'set')) | 630 args.extend(('&&', 'set')) |
597 popen = subprocess.Popen( | 631 popen = subprocess.Popen( |
598 args, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) | 632 args, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) |
599 variables, _ = popen.communicate() | 633 variables, _ = popen.communicate() |
600 env = _ExtractImportantEnvironment(variables) | 634 env = _ExtractImportantEnvironment(variables) |
601 env_block = _FormatAsEnvironmentBlock(env) | 635 env_block = _FormatAsEnvironmentBlock(env) |
602 f = open_out(os.path.join(toplevel_build_dir, 'environment.' + arch), 'wb') | 636 f = open_out(os.path.join(toplevel_build_dir, 'environment.' + arch), 'wb') |
603 f.write(env_block) | 637 f.write(env_block) |
604 f.close() | 638 f.close() |
OLD | NEW |