| 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 1091 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1102 | 1102 |
| 1103 Arguments: | 1103 Arguments: |
| 1104 p: The target project being generated. | 1104 p: The target project being generated. |
| 1105 spec: The target dictionary containing the properties of the target. | 1105 spec: The target dictionary containing the properties of the target. |
| 1106 config_type: The configuration type, a number as defined by Microsoft. | 1106 config_type: The configuration type, a number as defined by Microsoft. |
| 1107 config_name: The name of the configuration. | 1107 config_name: The name of the configuration. |
| 1108 config: The dictionary that defines the special processing to be done | 1108 config: The dictionary that defines the special processing to be done |
| 1109 for this configuration. | 1109 for this configuration. |
| 1110 """ | 1110 """ |
| 1111 # Get the information for this configuration | 1111 # Get the information for this configuration |
| 1112 include_dirs, resource_include_dirs = _GetIncludeDirs(config) | 1112 include_dirs, midl_include_dirs, resource_include_dirs = \ |
| 1113 _GetIncludeDirs(config) |
| 1113 libraries = _GetLibraries(spec) | 1114 libraries = _GetLibraries(spec) |
| 1114 library_dirs = _GetLibraryDirs(config) | 1115 library_dirs = _GetLibraryDirs(config) |
| 1115 out_file, vc_tool, _ = _GetOutputFilePathAndTool(spec, msbuild=False) | 1116 out_file, vc_tool, _ = _GetOutputFilePathAndTool(spec, msbuild=False) |
| 1116 defines = _GetDefines(config) | 1117 defines = _GetDefines(config) |
| 1117 defines = [_EscapeCppDefineForMSVS(d) for d in defines] | 1118 defines = [_EscapeCppDefineForMSVS(d) for d in defines] |
| 1118 disabled_warnings = _GetDisabledWarnings(config) | 1119 disabled_warnings = _GetDisabledWarnings(config) |
| 1119 prebuild = config.get('msvs_prebuild') | 1120 prebuild = config.get('msvs_prebuild') |
| 1120 postbuild = config.get('msvs_postbuild') | 1121 postbuild = config.get('msvs_postbuild') |
| 1121 def_file = _GetModuleDefinition(spec) | 1122 def_file = _GetModuleDefinition(spec) |
| 1122 precompiled_header = config.get('msvs_precompiled_header') | 1123 precompiled_header = config.get('msvs_precompiled_header') |
| 1123 | 1124 |
| 1124 # Prepare the list of tools as a dictionary. | 1125 # Prepare the list of tools as a dictionary. |
| 1125 tools = dict() | 1126 tools = dict() |
| 1126 # Add in user specified msvs_settings. | 1127 # Add in user specified msvs_settings. |
| 1127 msvs_settings = config.get('msvs_settings', {}) | 1128 msvs_settings = config.get('msvs_settings', {}) |
| 1128 MSVSSettings.ValidateMSVSSettings(msvs_settings) | 1129 MSVSSettings.ValidateMSVSSettings(msvs_settings) |
| 1129 | 1130 |
| 1130 # Prevent default library inheritance from the environment. | 1131 # Prevent default library inheritance from the environment. |
| 1131 _ToolAppend(tools, 'VCLinkerTool', 'AdditionalDependencies', ['$(NOINHERIT)']) | 1132 _ToolAppend(tools, 'VCLinkerTool', 'AdditionalDependencies', ['$(NOINHERIT)']) |
| 1132 | 1133 |
| 1133 for tool in msvs_settings: | 1134 for tool in msvs_settings: |
| 1134 settings = config['msvs_settings'][tool] | 1135 settings = config['msvs_settings'][tool] |
| 1135 for setting in settings: | 1136 for setting in settings: |
| 1136 _ToolAppend(tools, tool, setting, settings[setting]) | 1137 _ToolAppend(tools, tool, setting, settings[setting]) |
| 1137 # Add the information to the appropriate tool | 1138 # Add the information to the appropriate tool |
| 1138 _ToolAppend(tools, 'VCCLCompilerTool', | 1139 _ToolAppend(tools, 'VCCLCompilerTool', |
| 1139 'AdditionalIncludeDirectories', include_dirs) | 1140 'AdditionalIncludeDirectories', include_dirs) |
| 1141 _ToolAppend(tools, 'VCMIDLTool', |
| 1142 'AdditionalIncludeDirectories', midl_include_dirs) |
| 1140 _ToolAppend(tools, 'VCResourceCompilerTool', | 1143 _ToolAppend(tools, 'VCResourceCompilerTool', |
| 1141 'AdditionalIncludeDirectories', resource_include_dirs) | 1144 'AdditionalIncludeDirectories', resource_include_dirs) |
| 1142 # Add in libraries. | 1145 # Add in libraries. |
| 1143 _ToolAppend(tools, 'VCLinkerTool', 'AdditionalDependencies', libraries) | 1146 _ToolAppend(tools, 'VCLinkerTool', 'AdditionalDependencies', libraries) |
| 1144 _ToolAppend(tools, 'VCLinkerTool', 'AdditionalLibraryDirectories', | 1147 _ToolAppend(tools, 'VCLinkerTool', 'AdditionalLibraryDirectories', |
| 1145 library_dirs) | 1148 library_dirs) |
| 1146 if out_file: | 1149 if out_file: |
| 1147 _ToolAppend(tools, vc_tool, 'OutputFile', out_file, only_if_unset=True) | 1150 _ToolAppend(tools, vc_tool, 'OutputFile', out_file, only_if_unset=True) |
| 1148 # Add defines. | 1151 # Add defines. |
| 1149 _ToolAppend(tools, 'VCCLCompilerTool', 'PreprocessorDefinitions', defines) | 1152 _ToolAppend(tools, 'VCCLCompilerTool', 'PreprocessorDefinitions', defines) |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1185 config: The dictionary that defines the special processing to be done | 1188 config: The dictionary that defines the special processing to be done |
| 1186 for this configuration. | 1189 for this configuration. |
| 1187 Returns: | 1190 Returns: |
| 1188 The list of directory paths. | 1191 The list of directory paths. |
| 1189 """ | 1192 """ |
| 1190 # TODO(bradnelson): include_dirs should really be flexible enough not to | 1193 # TODO(bradnelson): include_dirs should really be flexible enough not to |
| 1191 # require this sort of thing. | 1194 # require this sort of thing. |
| 1192 include_dirs = ( | 1195 include_dirs = ( |
| 1193 config.get('include_dirs', []) + | 1196 config.get('include_dirs', []) + |
| 1194 config.get('msvs_system_include_dirs', [])) | 1197 config.get('msvs_system_include_dirs', [])) |
| 1198 midl_include_dirs = ( |
| 1199 config.get('midl_include_dirs', []) + |
| 1200 config.get('msvs_system_include_dirs', [])) |
| 1195 resource_include_dirs = config.get('resource_include_dirs', include_dirs) | 1201 resource_include_dirs = config.get('resource_include_dirs', include_dirs) |
| 1196 include_dirs = _FixPaths(include_dirs) | 1202 include_dirs = _FixPaths(include_dirs) |
| 1203 midl_include_dirs = _FixPaths(midl_include_dirs) |
| 1197 resource_include_dirs = _FixPaths(resource_include_dirs) | 1204 resource_include_dirs = _FixPaths(resource_include_dirs) |
| 1198 return include_dirs, resource_include_dirs | 1205 return include_dirs, midl_include_dirs, resource_include_dirs |
| 1199 | 1206 |
| 1200 | 1207 |
| 1201 def _GetLibraryDirs(config): | 1208 def _GetLibraryDirs(config): |
| 1202 """Returns the list of directories to be used for library search paths. | 1209 """Returns the list of directories to be used for library search paths. |
| 1203 | 1210 |
| 1204 Arguments: | 1211 Arguments: |
| 1205 config: The dictionary that defines the special processing to be done | 1212 config: The dictionary that defines the special processing to be done |
| 1206 for this configuration. | 1213 for this configuration. |
| 1207 Returns: | 1214 Returns: |
| 1208 The list of directory paths. | 1215 The list of directory paths. |
| (...skipping 1713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2922 | 2929 |
| 2923 def _FinalizeMSBuildSettings(spec, configuration): | 2930 def _FinalizeMSBuildSettings(spec, configuration): |
| 2924 if 'msbuild_settings' in configuration: | 2931 if 'msbuild_settings' in configuration: |
| 2925 converted = False | 2932 converted = False |
| 2926 msbuild_settings = configuration['msbuild_settings'] | 2933 msbuild_settings = configuration['msbuild_settings'] |
| 2927 MSVSSettings.ValidateMSBuildSettings(msbuild_settings) | 2934 MSVSSettings.ValidateMSBuildSettings(msbuild_settings) |
| 2928 else: | 2935 else: |
| 2929 converted = True | 2936 converted = True |
| 2930 msvs_settings = configuration.get('msvs_settings', {}) | 2937 msvs_settings = configuration.get('msvs_settings', {}) |
| 2931 msbuild_settings = MSVSSettings.ConvertToMSBuildSettings(msvs_settings) | 2938 msbuild_settings = MSVSSettings.ConvertToMSBuildSettings(msvs_settings) |
| 2932 include_dirs, resource_include_dirs = _GetIncludeDirs(configuration) | 2939 include_dirs, midl_include_dirs, resource_include_dirs = \ |
| 2940 _GetIncludeDirs(configuration) |
| 2933 libraries = _GetLibraries(spec) | 2941 libraries = _GetLibraries(spec) |
| 2934 library_dirs = _GetLibraryDirs(configuration) | 2942 library_dirs = _GetLibraryDirs(configuration) |
| 2935 out_file, _, msbuild_tool = _GetOutputFilePathAndTool(spec, msbuild=True) | 2943 out_file, _, msbuild_tool = _GetOutputFilePathAndTool(spec, msbuild=True) |
| 2936 target_ext = _GetOutputTargetExt(spec) | 2944 target_ext = _GetOutputTargetExt(spec) |
| 2937 defines = _GetDefines(configuration) | 2945 defines = _GetDefines(configuration) |
| 2938 if converted: | 2946 if converted: |
| 2939 # Visual Studio 2010 has TR1 | 2947 # Visual Studio 2010 has TR1 |
| 2940 defines = [d for d in defines if d != '_HAS_TR1=0'] | 2948 defines = [d for d in defines if d != '_HAS_TR1=0'] |
| 2941 # Warn of ignored settings | 2949 # Warn of ignored settings |
| 2942 ignored_settings = ['msvs_tool_files'] | 2950 ignored_settings = ['msvs_tool_files'] |
| 2943 for ignored_setting in ignored_settings: | 2951 for ignored_setting in ignored_settings: |
| 2944 value = configuration.get(ignored_setting) | 2952 value = configuration.get(ignored_setting) |
| 2945 if value: | 2953 if value: |
| 2946 print ('Warning: The automatic conversion to MSBuild does not handle ' | 2954 print ('Warning: The automatic conversion to MSBuild does not handle ' |
| 2947 '%s. Ignoring setting of %s' % (ignored_setting, str(value))) | 2955 '%s. Ignoring setting of %s' % (ignored_setting, str(value))) |
| 2948 | 2956 |
| 2949 defines = [_EscapeCppDefineForMSBuild(d) for d in defines] | 2957 defines = [_EscapeCppDefineForMSBuild(d) for d in defines] |
| 2950 disabled_warnings = _GetDisabledWarnings(configuration) | 2958 disabled_warnings = _GetDisabledWarnings(configuration) |
| 2951 prebuild = configuration.get('msvs_prebuild') | 2959 prebuild = configuration.get('msvs_prebuild') |
| 2952 postbuild = configuration.get('msvs_postbuild') | 2960 postbuild = configuration.get('msvs_postbuild') |
| 2953 def_file = _GetModuleDefinition(spec) | 2961 def_file = _GetModuleDefinition(spec) |
| 2954 precompiled_header = configuration.get('msvs_precompiled_header') | 2962 precompiled_header = configuration.get('msvs_precompiled_header') |
| 2955 | 2963 |
| 2956 # Add the information to the appropriate tool | 2964 # Add the information to the appropriate tool |
| 2957 # TODO(jeanluc) We could optimize and generate these settings only if | 2965 # TODO(jeanluc) We could optimize and generate these settings only if |
| 2958 # the corresponding files are found, e.g. don't generate ResourceCompile | 2966 # the corresponding files are found, e.g. don't generate ResourceCompile |
| 2959 # if you don't have any resources. | 2967 # if you don't have any resources. |
| 2960 _ToolAppend(msbuild_settings, 'ClCompile', | 2968 _ToolAppend(msbuild_settings, 'ClCompile', |
| 2961 'AdditionalIncludeDirectories', include_dirs) | 2969 'AdditionalIncludeDirectories', include_dirs) |
| 2970 _ToolAppend(msbuild_settings, 'Midl', |
| 2971 'AdditionalIncludeDirectories', midl_include_dirs) |
| 2962 _ToolAppend(msbuild_settings, 'ResourceCompile', | 2972 _ToolAppend(msbuild_settings, 'ResourceCompile', |
| 2963 'AdditionalIncludeDirectories', resource_include_dirs) | 2973 'AdditionalIncludeDirectories', resource_include_dirs) |
| 2964 # Add in libraries, note that even for empty libraries, we want this | 2974 # Add in libraries, note that even for empty libraries, we want this |
| 2965 # set, to prevent inheriting default libraries from the enviroment. | 2975 # set, to prevent inheriting default libraries from the enviroment. |
| 2966 _ToolSetOrAppend(msbuild_settings, 'Link', 'AdditionalDependencies', | 2976 _ToolSetOrAppend(msbuild_settings, 'Link', 'AdditionalDependencies', |
| 2967 libraries) | 2977 libraries) |
| 2968 _ToolAppend(msbuild_settings, 'Link', 'AdditionalLibraryDirectories', | 2978 _ToolAppend(msbuild_settings, 'Link', 'AdditionalLibraryDirectories', |
| 2969 library_dirs) | 2979 library_dirs) |
| 2970 if out_file: | 2980 if out_file: |
| 2971 _ToolAppend(msbuild_settings, msbuild_tool, 'OutputFile', out_file, | 2981 _ToolAppend(msbuild_settings, msbuild_tool, 'OutputFile', out_file, |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3380 action_spec.extend( | 3390 action_spec.extend( |
| 3381 # TODO(jeanluc) 'Document' for all or just if as_sources? | 3391 # TODO(jeanluc) 'Document' for all or just if as_sources? |
| 3382 [['FileType', 'Document'], | 3392 [['FileType', 'Document'], |
| 3383 ['Command', command], | 3393 ['Command', command], |
| 3384 ['Message', description], | 3394 ['Message', description], |
| 3385 ['Outputs', outputs] | 3395 ['Outputs', outputs] |
| 3386 ]) | 3396 ]) |
| 3387 if additional_inputs: | 3397 if additional_inputs: |
| 3388 action_spec.append(['AdditionalInputs', additional_inputs]) | 3398 action_spec.append(['AdditionalInputs', additional_inputs]) |
| 3389 actions_spec.append(action_spec) | 3399 actions_spec.append(action_spec) |
| OLD | NEW |