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 21 matching lines...) Expand all Loading... | |
32 | 32 |
33 | 33 |
34 generator_default_variables = { | 34 generator_default_variables = { |
35 'EXECUTABLE_PREFIX': '', | 35 'EXECUTABLE_PREFIX': '', |
36 'EXECUTABLE_SUFFIX': '.exe', | 36 'EXECUTABLE_SUFFIX': '.exe', |
37 'STATIC_LIB_PREFIX': '', | 37 'STATIC_LIB_PREFIX': '', |
38 'SHARED_LIB_PREFIX': '', | 38 'SHARED_LIB_PREFIX': '', |
39 'STATIC_LIB_SUFFIX': '.lib', | 39 'STATIC_LIB_SUFFIX': '.lib', |
40 'SHARED_LIB_SUFFIX': '.dll', | 40 'SHARED_LIB_SUFFIX': '.dll', |
41 'INTERMEDIATE_DIR': '$(IntDir)', | 41 'INTERMEDIATE_DIR': '$(IntDir)', |
42 'SHARED_INTERMEDIATE_DIR': '$(OutDir)/obj/global_intermediate', | 42 'SHARED_INTERMEDIATE_DIR': '$(OutDir)obj/global_intermediate', |
43 'OS': 'win', | 43 'OS': 'win', |
44 'PRODUCT_DIR': '$(OutDir)', | 44 'PRODUCT_DIR': '$(OutDir)', |
45 'LIB_DIR': '$(OutDir)\\lib', | 45 'LIB_DIR': '$(OutDir)lib', |
46 'RULE_INPUT_ROOT': '$(InputName)', | 46 'RULE_INPUT_ROOT': '$(InputName)', |
47 'RULE_INPUT_DIRNAME': '$(InputDir)', | 47 'RULE_INPUT_DIRNAME': '$(InputDir)', |
48 'RULE_INPUT_EXT': '$(InputExt)', | 48 'RULE_INPUT_EXT': '$(InputExt)', |
49 'RULE_INPUT_NAME': '$(InputFileName)', | 49 'RULE_INPUT_NAME': '$(InputFileName)', |
50 'RULE_INPUT_PATH': '$(InputPath)', | 50 'RULE_INPUT_PATH': '$(InputPath)', |
51 'CONFIGURATION_NAME': '$(ConfigurationName)', | 51 'CONFIGURATION_NAME': '$(ConfigurationName)', |
52 } | 52 } |
53 | 53 |
54 | 54 |
55 # The msvs specific sections that hold paths | 55 # The msvs specific sections that hold paths |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
294 command = ['type'] | 294 command = ['type'] |
295 else: | 295 else: |
296 command = [cmd[0].replace('/', '\\')] | 296 command = [cmd[0].replace('/', '\\')] |
297 # Fix the paths | 297 # Fix the paths |
298 # TODO(quote): This is a really ugly heuristic, and will miss path fixing | 298 # TODO(quote): This is a really ugly heuristic, and will miss path fixing |
299 # for arguments like "--arg=path" or "/opt:path". | 299 # for arguments like "--arg=path" or "/opt:path". |
300 # If the argument starts with a slash or dash, it's probably a command line | 300 # If the argument starts with a slash or dash, it's probably a command line |
301 # switch | 301 # switch |
302 arguments = [i if (i[:1] in "/-") else _FixPath(i) for i in cmd[1:]] | 302 arguments = [i if (i[:1] in "/-") else _FixPath(i) for i in cmd[1:]] |
303 arguments = [i.replace('$(InputDir)','%INPUTDIR%') for i in arguments] | 303 arguments = [i.replace('$(InputDir)','%INPUTDIR%') for i in arguments] |
304 arguments = [MSVSSettings.FixVCMacroSlashes(i) for i in arguments] | |
304 if quote_cmd: | 305 if quote_cmd: |
305 # Support a mode for using cmd directly. | 306 # Support a mode for using cmd directly. |
306 # Convert any paths to native form (first element is used directly). | 307 # Convert any paths to native form (first element is used directly). |
307 # TODO(quote): regularize quoting path names throughout the module | 308 # TODO(quote): regularize quoting path names throughout the module |
308 arguments = ['"%s"' % i for i in arguments] | 309 arguments = ['"%s"' % i for i in arguments] |
309 # Collapse into a single command. | 310 # Collapse into a single command. |
310 return input_dir_preamble + ' '.join(command + arguments) | 311 return input_dir_preamble + ' '.join(command + arguments) |
311 | 312 |
312 | 313 |
313 def _BuildCommandLineForRule(spec, rule, has_input_path, do_setup_env): | 314 def _BuildCommandLineForRule(spec, rule, has_input_path, do_setup_env): |
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1044 _ToolAppend(tools, 'VCLinkerTool', 'AdditionalDependencies', libraries) | 1045 _ToolAppend(tools, 'VCLinkerTool', 'AdditionalDependencies', libraries) |
1045 if out_file: | 1046 if out_file: |
1046 _ToolAppend(tools, vc_tool, 'OutputFile', out_file, only_if_unset=True) | 1047 _ToolAppend(tools, vc_tool, 'OutputFile', out_file, only_if_unset=True) |
1047 # Add defines. | 1048 # Add defines. |
1048 _ToolAppend(tools, 'VCCLCompilerTool', 'PreprocessorDefinitions', defines) | 1049 _ToolAppend(tools, 'VCCLCompilerTool', 'PreprocessorDefinitions', defines) |
1049 _ToolAppend(tools, 'VCResourceCompilerTool', 'PreprocessorDefinitions', | 1050 _ToolAppend(tools, 'VCResourceCompilerTool', 'PreprocessorDefinitions', |
1050 defines) | 1051 defines) |
1051 _ToolAppend(tools, 'VCMIDLTool', 'PreprocessorDefinitions', defines) | 1052 _ToolAppend(tools, 'VCMIDLTool', 'PreprocessorDefinitions', defines) |
1052 # Change program database directory to prevent collisions. | 1053 # Change program database directory to prevent collisions. |
1053 _ToolAppend(tools, 'VCCLCompilerTool', 'ProgramDataBaseFileName', | 1054 _ToolAppend(tools, 'VCCLCompilerTool', 'ProgramDataBaseFileName', |
1054 '$(IntDir)\\$(ProjectName)\\vc80.pdb', only_if_unset=True) | 1055 '$(IntDir)$(ProjectName)\\vc80.pdb', only_if_unset=True) |
1055 # Add disabled warnings. | 1056 # Add disabled warnings. |
1056 _ToolAppend(tools, 'VCCLCompilerTool', | 1057 _ToolAppend(tools, 'VCCLCompilerTool', |
1057 'DisableSpecificWarnings', disabled_warnings) | 1058 'DisableSpecificWarnings', disabled_warnings) |
1058 # Add Pre-build. | 1059 # Add Pre-build. |
1059 _ToolAppend(tools, 'VCPreBuildEventTool', 'CommandLine', prebuild) | 1060 _ToolAppend(tools, 'VCPreBuildEventTool', 'CommandLine', prebuild) |
1060 # Add Post-build. | 1061 # Add Post-build. |
1061 _ToolAppend(tools, 'VCPostBuildEventTool', 'CommandLine', postbuild) | 1062 _ToolAppend(tools, 'VCPostBuildEventTool', 'CommandLine', postbuild) |
1062 # Turn on precompiled headers if appropriate. | 1063 # Turn on precompiled headers if appropriate. |
1063 if precompiled_header: | 1064 if precompiled_header: |
1064 precompiled_header = os.path.split(precompiled_header)[1] | 1065 precompiled_header = os.path.split(precompiled_header)[1] |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1131 Arguments: | 1132 Arguments: |
1132 spec: The target dictionary containing the properties of the target. | 1133 spec: The target dictionary containing the properties of the target. |
1133 Returns: | 1134 Returns: |
1134 A triple of (file path, name of the vc tool, name of the msbuild tool) | 1135 A triple of (file path, name of the vc tool, name of the msbuild tool) |
1135 """ | 1136 """ |
1136 # Select a name for the output file. | 1137 # Select a name for the output file. |
1137 out_file = '' | 1138 out_file = '' |
1138 vc_tool = '' | 1139 vc_tool = '' |
1139 msbuild_tool = '' | 1140 msbuild_tool = '' |
1140 output_file_map = { | 1141 output_file_map = { |
1141 'executable': ('VCLinkerTool', 'Link', '$(OutDir)\\', '.exe'), | 1142 'executable': ('VCLinkerTool', 'Link', '$(OutDir)', '.exe'), |
1142 'shared_library': ('VCLinkerTool', 'Link', '$(OutDir)\\', '.dll'), | 1143 'shared_library': ('VCLinkerTool', 'Link', '$(OutDir)', '.dll'), |
1143 'loadable_module': ('VCLinkerTool', 'Link', '$(OutDir)\\', '.dll'), | 1144 'loadable_module': ('VCLinkerTool', 'Link', '$(OutDir)', '.dll'), |
1144 'static_library': ('VCLibrarianTool', 'Lib', '$(OutDir)\\lib\\', '.lib'), | 1145 'static_library': ('VCLibrarianTool', 'Lib', '$(OutDir)lib\\', '.lib'), |
1145 } | 1146 } |
1146 output_file_props = output_file_map.get(spec['type']) | 1147 output_file_props = output_file_map.get(spec['type']) |
1147 if output_file_props and int(spec.get('msvs_auto_output_file', 1)): | 1148 if output_file_props and int(spec.get('msvs_auto_output_file', 1)): |
1148 vc_tool, msbuild_tool, out_dir, suffix = output_file_props | 1149 vc_tool, msbuild_tool, out_dir, suffix = output_file_props |
1149 out_dir = spec.get('product_dir', out_dir) | 1150 out_dir = spec.get('product_dir', out_dir) |
1150 product_extension = spec.get('product_extension') | 1151 product_extension = spec.get('product_extension') |
1151 if product_extension: | 1152 if product_extension: |
1152 suffix = '.' + product_extension | 1153 suffix = '.' + product_extension |
1153 prefix = spec.get('product_prefix', '') | 1154 prefix = spec.get('product_prefix', '') |
1154 product_name = spec.get('product_name', '$(ProjectName)') | 1155 product_name = spec.get('product_name', '$(ProjectName)') |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1247 prepared_attrs[a] = source_attrs[a] | 1248 prepared_attrs[a] = source_attrs[a] |
1248 # Add props files. | 1249 # Add props files. |
1249 vsprops_dirs = config.get('msvs_props', []) | 1250 vsprops_dirs = config.get('msvs_props', []) |
1250 vsprops_dirs = _FixPaths(vsprops_dirs) | 1251 vsprops_dirs = _FixPaths(vsprops_dirs) |
1251 if vsprops_dirs: | 1252 if vsprops_dirs: |
1252 prepared_attrs['InheritedPropertySheets'] = ';'.join(vsprops_dirs) | 1253 prepared_attrs['InheritedPropertySheets'] = ';'.join(vsprops_dirs) |
1253 # Set configuration type. | 1254 # Set configuration type. |
1254 prepared_attrs['ConfigurationType'] = config_type | 1255 prepared_attrs['ConfigurationType'] = config_type |
1255 output_dir = prepared_attrs.get('OutputDirectory', | 1256 output_dir = prepared_attrs.get('OutputDirectory', |
1256 '$(SolutionDir)$(ConfigurationName)') | 1257 '$(SolutionDir)$(ConfigurationName)') |
1257 prepared_attrs['OutputDirectory'] = _FixPath(output_dir) | 1258 prepared_attrs['OutputDirectory'] = _FixPath(output_dir)+"\\" |
scottmg
2012/08/08 22:02:56
spaces and ' not "
iannucci
2012/08/08 22:09:44
Done
| |
1258 if 'IntermediateDirectory' not in prepared_attrs: | 1259 if 'IntermediateDirectory' not in prepared_attrs: |
1259 intermediate = '$(ConfigurationName)\\obj\\$(ProjectName)' | 1260 intermediate = '$(ConfigurationName)\\obj\\$(ProjectName)' |
1260 prepared_attrs['IntermediateDirectory'] = _FixPath(intermediate) | 1261 prepared_attrs['IntermediateDirectory'] = _FixPath(intermediate)+"\\" |
scottmg
2012/08/08 22:02:56
same
iannucci
2012/08/08 22:09:44
and done
| |
1261 return prepared_attrs | 1262 return prepared_attrs |
1262 | 1263 |
1263 | 1264 |
1264 def _AddNormalizedSources(sources_set, sources_array): | 1265 def _AddNormalizedSources(sources_set, sources_array): |
1265 sources = [_NormalizedSource(s) for s in sources_array] | 1266 sources = [_NormalizedSource(s) for s in sources_array] |
1266 sources_set.update(set(sources)) | 1267 sources_set.update(set(sources)) |
1267 | 1268 |
1268 | 1269 |
1269 def _PrepareListOfSources(spec, gyp_file): | 1270 def _PrepareListOfSources(spec, gyp_file): |
1270 """Prepare list of sources and excluded sources. | 1271 """Prepare list of sources and excluded sources. |
(...skipping 1851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3122 action_spec.extend( | 3123 action_spec.extend( |
3123 # TODO(jeanluc) 'Document' for all or just if as_sources? | 3124 # TODO(jeanluc) 'Document' for all or just if as_sources? |
3124 [['FileType', 'Document'], | 3125 [['FileType', 'Document'], |
3125 ['Command', command], | 3126 ['Command', command], |
3126 ['Message', description], | 3127 ['Message', description], |
3127 ['Outputs', outputs] | 3128 ['Outputs', outputs] |
3128 ]) | 3129 ]) |
3129 if additional_inputs: | 3130 if additional_inputs: |
3130 action_spec.append(['AdditionalInputs', additional_inputs]) | 3131 action_spec.append(['AdditionalInputs', additional_inputs]) |
3131 actions_spec.append(action_spec) | 3132 actions_spec.append(action_spec) |
OLD | NEW |