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 """GYP backend that generates Eclipse CDT settings files. | 5 """GYP backend that generates Eclipse CDT settings files. |
6 | 6 |
7 This backend DOES NOT generate Eclipse CDT projects. Instead, it generates XML | 7 This backend DOES NOT generate Eclipse CDT projects. Instead, it generates XML |
8 files that can be imported into an Eclipse CDT project. The XML file contains a | 8 files that can be imported into an Eclipse CDT project. The XML file contains a |
9 list of include paths and symbols (i.e. defines). | 9 list of include paths and symbols (i.e. defines). |
10 | 10 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 cflags = msvs_settings.GetCflags(config_name) | 134 cflags = msvs_settings.GetCflags(config_name) |
135 else: | 135 else: |
136 cflags = config['cflags'] | 136 cflags = config['cflags'] |
137 for cflag in cflags: | 137 for cflag in cflags: |
138 if cflag.startswith('-I'): | 138 if cflag.startswith('-I'): |
139 include_dir = cflag[2:] | 139 include_dir = cflag[2:] |
140 if include_dir not in compiler_includes_list: | 140 if include_dir not in compiler_includes_list: |
141 compiler_includes_list.append(include_dir) | 141 compiler_includes_list.append(include_dir) |
142 | 142 |
143 # Find standard gyp include dirs. | 143 # Find standard gyp include dirs. |
144 if config.has_key('include_dirs'): | 144 if 'include_dirs' in config: |
145 include_dirs = config['include_dirs'] | 145 include_dirs = config['include_dirs'] |
146 for shared_intermediate_dir in shared_intermediate_dirs: | 146 for shared_intermediate_dir in shared_intermediate_dirs: |
147 for include_dir in include_dirs: | 147 for include_dir in include_dirs: |
148 include_dir = include_dir.replace('$SHARED_INTERMEDIATE_DIR', | 148 include_dir = include_dir.replace('$SHARED_INTERMEDIATE_DIR', |
149 shared_intermediate_dir) | 149 shared_intermediate_dir) |
150 if not os.path.isabs(include_dir): | 150 if not os.path.isabs(include_dir): |
151 base_dir = os.path.dirname(target_name) | 151 base_dir = os.path.dirname(target_name) |
152 | 152 |
153 include_dir = base_dir + '/' + include_dir | 153 include_dir = base_dir + '/' + include_dir |
154 include_dir = os.path.abspath(include_dir) | 154 include_dir = os.path.abspath(include_dir) |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 | 265 |
266 | 266 |
267 def WriteMacros(out, eclipse_langs, defines): | 267 def WriteMacros(out, eclipse_langs, defines): |
268 """Write the macros section of a CDT settings export file.""" | 268 """Write the macros section of a CDT settings export file.""" |
269 | 269 |
270 out.write(' <section name="org.eclipse.cdt.internal.ui.wizards.' \ | 270 out.write(' <section name="org.eclipse.cdt.internal.ui.wizards.' \ |
271 'settingswizards.Macros">\n') | 271 'settingswizards.Macros">\n') |
272 out.write(' <language name="holder for library settings"></language>\n') | 272 out.write(' <language name="holder for library settings"></language>\n') |
273 for lang in eclipse_langs: | 273 for lang in eclipse_langs: |
274 out.write(' <language name="%s">\n' % lang) | 274 out.write(' <language name="%s">\n' % lang) |
275 for key in sorted(defines.iterkeys()): | 275 for key in sorted(defines.keys()): |
276 out.write(' <macro><name>%s</name><value>%s</value></macro>\n' % | 276 out.write(' <macro><name>%s</name><value>%s</value></macro>\n' % |
277 (escape(key), escape(defines[key]))) | 277 (escape(key), escape(defines[key]))) |
278 out.write(' </language>\n') | 278 out.write(' </language>\n') |
279 out.write(' </section>\n') | 279 out.write(' </section>\n') |
280 | 280 |
281 | 281 |
282 def GenerateOutputForConfig(target_list, target_dicts, data, params, | 282 def GenerateOutputForConfig(target_list, target_dicts, data, params, |
283 config_name): | 283 config_name): |
284 options = params['options'] | 284 options = params['options'] |
285 generator_flags = params.get('generator_flags', {}) | 285 generator_flags = params.get('generator_flags', {}) |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 """Generate an XML settings file that can be imported into a CDT project.""" | 411 """Generate an XML settings file that can be imported into a CDT project.""" |
412 | 412 |
413 if params['options'].generator_output: | 413 if params['options'].generator_output: |
414 raise NotImplementedError("--generator_output not implemented for eclipse") | 414 raise NotImplementedError("--generator_output not implemented for eclipse") |
415 | 415 |
416 user_config = params.get('generator_flags', {}).get('config', None) | 416 user_config = params.get('generator_flags', {}).get('config', None) |
417 if user_config: | 417 if user_config: |
418 GenerateOutputForConfig(target_list, target_dicts, data, params, | 418 GenerateOutputForConfig(target_list, target_dicts, data, params, |
419 user_config) | 419 user_config) |
420 else: | 420 else: |
421 config_names = target_dicts[target_list[0]]['configurations'].keys() | 421 config_names = target_dicts[target_list[0]]['configurations'] |
422 for config_name in config_names: | 422 for config_name in config_names: |
423 GenerateOutputForConfig(target_list, target_dicts, data, params, | 423 GenerateOutputForConfig(target_list, target_dicts, data, params, |
424 config_name) | 424 config_name) |
425 | 425 |
OLD | NEW |