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 import copy | 5 import copy |
6 import ntpath | 6 import ntpath |
7 import os | 7 import os |
8 import posixpath | 8 import posixpath |
9 import re | 9 import re |
10 import subprocess | 10 import subprocess |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
250 def _ToolSetOrAppend(tools, tool_name, setting, value, only_if_unset=False): | 250 def _ToolSetOrAppend(tools, tool_name, setting, value, only_if_unset=False): |
251 # TODO(bradnelson): ugly hack, fix this more generally!!! | 251 # TODO(bradnelson): ugly hack, fix this more generally!!! |
252 if 'Directories' in setting or 'Dependencies' in setting: | 252 if 'Directories' in setting or 'Dependencies' in setting: |
253 if type(value) == str: | 253 if type(value) == str: |
254 value = value.replace('/', '\\') | 254 value = value.replace('/', '\\') |
255 else: | 255 else: |
256 value = [i.replace('/', '\\') for i in value] | 256 value = [i.replace('/', '\\') for i in value] |
257 if not tools.get(tool_name): | 257 if not tools.get(tool_name): |
258 tools[tool_name] = dict() | 258 tools[tool_name] = dict() |
259 tool = tools[tool_name] | 259 tool = tools[tool_name] |
260 if 'CompileAsWinRT' == setting: return | |
scottmg
2016/04/04 22:05:17
return on separate line
munyirik
2016/04/11 20:07:10
Acknowledged.
| |
260 if tool.get(setting): | 261 if tool.get(setting): |
261 if only_if_unset: return | 262 if only_if_unset: return |
262 if type(tool[setting]) == list and type(value) == list: | 263 if type(tool[setting]) == list and type(value) == list: |
263 tool[setting] += value | 264 tool[setting] += value |
264 else: | 265 else: |
265 raise TypeError( | 266 raise TypeError( |
266 'Appending "%s" to a non-list setting "%s" for tool "%s" is ' | 267 'Appending "%s" to a non-list setting "%s" for tool "%s" is ' |
267 'not allowed, previous value: %s' % ( | 268 'not allowed, previous value: %s' % ( |
268 value, setting, tool_name, str(tool[setting]))) | 269 value, setting, tool_name, str(tool[setting]))) |
269 else: | 270 else: |
270 tool[setting] = value | 271 tool[setting] = value |
271 | 272 |
272 | 273 |
273 def _ConfigPlatform(config_data): | 274 def _ConfigPlatform(config_data): |
274 return config_data.get('msvs_configuration_platform', 'Win32') | 275 return config_data.get('msvs_configuration_platform', 'Win32') |
275 | 276 |
276 | 277 |
277 def _ConfigBaseName(config_name, platform_name): | 278 def _ConfigBaseName(config_name, platform_name): |
278 if config_name.endswith('_' + platform_name): | 279 if config_name.endswith('_' + platform_name): |
279 return config_name[0:-len(platform_name) - 1] | 280 return config_name[0:-len(platform_name) - 1] |
280 else: | 281 else: |
281 return config_name | 282 return config_name |
282 | 283 |
283 | 284 |
284 def _ConfigFullName(config_name, config_data): | 285 def _ConfigFullName(config_name, config_data): |
285 platform_name = _ConfigPlatform(config_data) | 286 platform_name = _ConfigPlatform(config_data) |
286 return '%s|%s' % (_ConfigBaseName(config_name, platform_name), platform_name) | 287 return '%s|%s' % (_ConfigBaseName(config_name, platform_name), platform_name) |
287 | 288 |
288 | 289 |
290 def _ConfigWindowsTargetPlatformVersion(config_data): | |
291 ver = config_data.get('msvs_windows_sdk_version') | |
292 if not ver or re.match(r'^\d+', ver): | |
scottmg
2016/04/04 22:05:17
What's the re for? This will be something like 'v1
munyirik
2016/04/11 20:07:10
That was a typo in the gyp file. The string will b
| |
293 return ver | |
294 for key in [r'HKLM\Software\Microsoft\Microsoft SDKs\Windows\%s', | |
295 r'HKLM\Software\Wow6432Node\Microsoft\Microsoft SDKs\Windows\%s']: | |
296 sdkdir = MSVSVersion._RegistryGetValue(key % ver, 'InstallationFolder') | |
scottmg
2016/04/04 22:05:17
nit; sdk_dir looks nicer.
munyirik
2016/04/11 20:07:10
Acknowledged.
| |
297 if not sdkdir: | |
298 continue | |
299 version = MSVSVersion._RegistryGetValue(key % ver, 'ProductVersion') or '' | |
300 # find a matching entry in sdkdir\include | |
scottmg
2016/04/04 22:05:17
nit; Capital F, end sentence with '.'.
munyirik
2016/04/11 20:07:10
Acknowledged.
| |
301 names = sorted([x for x in os.listdir(r'%s\include' % sdkdir) \ | |
scottmg
2016/04/04 22:05:17
Why do we need to use the prefix and then reverse
munyirik
2016/04/11 20:07:09
The reason is to get the latest SDK version. If so
| |
302 if x.startswith(version)], reverse = True) | |
scottmg
2016/04/04 22:05:17
nit; no spaces in "reverse=True".
munyirik
2016/04/11 20:07:10
Acknowledged.
| |
303 return names[0] | |
304 | |
305 | |
289 def _BuildCommandLineForRuleRaw(spec, cmd, cygwin_shell, has_input_path, | 306 def _BuildCommandLineForRuleRaw(spec, cmd, cygwin_shell, has_input_path, |
290 quote_cmd, do_setup_env): | 307 quote_cmd, do_setup_env): |
291 | 308 |
292 if [x for x in cmd if '$(InputDir)' in x]: | 309 if [x for x in cmd if '$(InputDir)' in x]: |
293 input_dir_preamble = ( | 310 input_dir_preamble = ( |
294 'set INPUTDIR=$(InputDir)\n' | 311 'set INPUTDIR=$(InputDir)\n' |
295 'if NOT DEFINED INPUTDIR set INPUTDIR=.\\\n' | 312 'if NOT DEFINED INPUTDIR set INPUTDIR=.\\\n' |
296 'set INPUTDIR=%INPUTDIR:~0,-1%\n' | 313 'set INPUTDIR=%INPUTDIR:~0,-1%\n' |
297 ) | 314 ) |
298 else: | 315 else: |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
332 cmd += 'bash -c "%(cmd)s"' | 349 cmd += 'bash -c "%(cmd)s"' |
333 cmd = cmd % {'cygwin_dir': cygwin_dir, | 350 cmd = cmd % {'cygwin_dir': cygwin_dir, |
334 'cmd': direct_cmd} | 351 'cmd': direct_cmd} |
335 return input_dir_preamble + cmd | 352 return input_dir_preamble + cmd |
336 else: | 353 else: |
337 # Convert cat --> type to mimic unix. | 354 # Convert cat --> type to mimic unix. |
338 if cmd[0] == 'cat': | 355 if cmd[0] == 'cat': |
339 command = ['type'] | 356 command = ['type'] |
340 else: | 357 else: |
341 command = [cmd[0].replace('/', '\\')] | 358 command = [cmd[0].replace('/', '\\')] |
359 if quote_cmd: | |
360 command = ['"%s"' % i for i in command] | |
342 # Add call before command to ensure that commands can be tied together one | 361 # Add call before command to ensure that commands can be tied together one |
343 # after the other without aborting in Incredibuild, since IB makes a bat | 362 # after the other without aborting in Incredibuild, since IB makes a bat |
344 # file out of the raw command string, and some commands (like python) are | 363 # file out of the raw command string, and some commands (like python) are |
345 # actually batch files themselves. | 364 # actually batch files themselves. |
346 command.insert(0, 'call') | 365 command.insert(0, 'call') |
347 # Fix the paths | 366 # Fix the paths |
348 # TODO(quote): This is a really ugly heuristic, and will miss path fixing | 367 # TODO(quote): This is a really ugly heuristic, and will miss path fixing |
349 # for arguments like "--arg=path" or "/opt:path". | 368 # for arguments like "--arg=path" or "/opt:path". |
350 # If the argument starts with a slash or dash, it's probably a command line | 369 # If the argument starts with a slash or dash, it's probably a command line |
351 # switch | 370 # switch |
(...skipping 2317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2669 properties[0].append(['WindowsTargetPlatformMinVersion', | 2688 properties[0].append(['WindowsTargetPlatformMinVersion', |
2670 target_platform_minversion]) | 2689 target_platform_minversion]) |
2671 else: | 2690 else: |
2672 properties[0].append(['WindowsTargetPlatformMinVersion', | 2691 properties[0].append(['WindowsTargetPlatformMinVersion', |
2673 target_platform_version]) | 2692 target_platform_version]) |
2674 if spec.get('msvs_enable_winphone'): | 2693 if spec.get('msvs_enable_winphone'): |
2675 properties[0].append(['ApplicationType', 'Windows Phone']) | 2694 properties[0].append(['ApplicationType', 'Windows Phone']) |
2676 else: | 2695 else: |
2677 properties[0].append(['ApplicationType', 'Windows Store']) | 2696 properties[0].append(['ApplicationType', 'Windows Store']) |
2678 | 2697 |
2698 platform_name = None | |
2699 msvs_windows_sdk_version = None | |
2700 for configuration in spec['configurations'].itervalues(): | |
2701 platform_name = platform_name or _ConfigPlatform(configuration) | |
2702 msvs_windows_sdk_version = \ | |
scottmg
2016/04/04 22:05:17
Instead of using \, put () around the whole expres
munyirik
2016/04/11 20:07:10
Acknowledged.
| |
2703 msvs_windows_sdk_version or \ | |
2704 _ConfigWindowsTargetPlatformVersion(configuration) | |
2705 if platform_name and msvs_windows_sdk_version: | |
2706 break | |
2707 | |
2708 if platform_name == 'ARM': | |
2709 properties[0].append(['WindowsSDKDesktopARMSupport', 'true']) | |
2710 if msvs_windows_sdk_version: | |
2711 properties[0].append(['WindowsTargetPlatformVersion', \ | |
scottmg
2016/04/04 22:05:17
This \ line continuation is unnecessary.
munyirik
2016/04/11 20:07:10
Acknowledged.
| |
2712 str(msvs_windows_sdk_version)]) | |
2713 | |
2679 return properties | 2714 return properties |
2680 | 2715 |
2681 def _GetMSBuildConfigurationDetails(spec, build_file): | 2716 def _GetMSBuildConfigurationDetails(spec, build_file): |
2682 properties = {} | 2717 properties = {} |
2683 for name, settings in spec['configurations'].iteritems(): | 2718 for name, settings in spec['configurations'].iteritems(): |
2684 msbuild_attributes = _GetMSBuildAttributes(spec, settings, build_file) | 2719 msbuild_attributes = _GetMSBuildAttributes(spec, settings, build_file) |
2685 condition = _GetConfigurationCondition(name, settings) | 2720 condition = _GetConfigurationCondition(name, settings) |
2686 character_set = msbuild_attributes.get('CharacterSet') | 2721 character_set = msbuild_attributes.get('CharacterSet') |
2687 _AddConditionalProperty(properties, condition, 'ConfigurationType', | 2722 _AddConditionalProperty(properties, condition, 'ConfigurationType', |
2688 msbuild_attributes['ConfigurationType']) | 2723 msbuild_attributes['ConfigurationType']) |
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3210 for dependency in project.dependencies: | 3245 for dependency in project.dependencies: |
3211 guid = dependency.guid | 3246 guid = dependency.guid |
3212 project_dir = os.path.split(project.path)[0] | 3247 project_dir = os.path.split(project.path)[0] |
3213 relative_path = gyp.common.RelativePath(dependency.path, project_dir) | 3248 relative_path = gyp.common.RelativePath(dependency.path, project_dir) |
3214 project_ref = ['ProjectReference', | 3249 project_ref = ['ProjectReference', |
3215 {'Include': relative_path}, | 3250 {'Include': relative_path}, |
3216 ['Project', guid], | 3251 ['Project', guid], |
3217 ['ReferenceOutputAssembly', 'false'] | 3252 ['ReferenceOutputAssembly', 'false'] |
3218 ] | 3253 ] |
3219 for config in dependency.spec.get('configurations', {}).itervalues(): | 3254 for config in dependency.spec.get('configurations', {}).itervalues(): |
3255 if config.get('msvs_use_library_dependency_inputs', 0): | |
scottmg
2016/04/04 22:05:17
What's this? We have ULDI settings already in vari
munyirik
2016/04/11 20:07:10
Sorry, I missed putting this in the description. I
| |
3256 project_ref.append(['UseLibraryDependencyInputs', 'true']) | |
3257 break | |
3220 # If it's disabled in any config, turn it off in the reference. | 3258 # If it's disabled in any config, turn it off in the reference. |
3221 if config.get('msvs_2010_disable_uldi_when_referenced', 0): | 3259 if config.get('msvs_2010_disable_uldi_when_referenced', 0): |
3222 project_ref.append(['UseLibraryDependencyInputs', 'false']) | 3260 project_ref.append(['UseLibraryDependencyInputs', 'false']) |
3223 break | 3261 break |
3224 group.append(project_ref) | 3262 group.append(project_ref) |
3225 references.append(group) | 3263 references.append(group) |
3226 return references | 3264 return references |
3227 | 3265 |
3228 | 3266 |
3229 def _GenerateMSBuildProject(project, options, version, generator_flags): | 3267 def _GenerateMSBuildProject(project, options, version, generator_flags): |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3458 action_spec.extend( | 3496 action_spec.extend( |
3459 # TODO(jeanluc) 'Document' for all or just if as_sources? | 3497 # TODO(jeanluc) 'Document' for all or just if as_sources? |
3460 [['FileType', 'Document'], | 3498 [['FileType', 'Document'], |
3461 ['Command', command], | 3499 ['Command', command], |
3462 ['Message', description], | 3500 ['Message', description], |
3463 ['Outputs', outputs] | 3501 ['Outputs', outputs] |
3464 ]) | 3502 ]) |
3465 if additional_inputs: | 3503 if additional_inputs: |
3466 action_spec.append(['AdditionalInputs', additional_inputs]) | 3504 action_spec.append(['AdditionalInputs', additional_inputs]) |
3467 actions_spec.append(action_spec) | 3505 actions_spec.append(action_spec) |
OLD | NEW |