您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
此仓库已存档。您可以查看文件和克隆,但不能推送或创建工单/合并请求。

emblocks.py 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. """
  2. mbed SDK
  3. Copyright (c) 2014 ARM Limited
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. http://www.apache.org/licenses/LICENSE-2.0
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. """
  14. from exporters import Exporter
  15. from os.path import splitext, basename
  16. from workspace_tools.targets import TARGETS
  17. # filter all the GCC_ARM targets out of the target list
  18. gccTargets = []
  19. for t in TARGETS:
  20. if 'GCC_ARM' in t.supported_toolchains:
  21. gccTargets.append(t.name)
  22. class IntermediateFile(Exporter):
  23. NAME = 'EmBlocks'
  24. TOOLCHAIN = 'GCC_ARM'
  25. # we support all GCC targets (is handled on IDE side)
  26. TARGETS = gccTargets
  27. FILE_TYPES = {
  28. 'headers': 'h',
  29. 'c_sources': 'c',
  30. 's_sources': 'a',
  31. 'cpp_sources': 'cpp'
  32. }
  33. def generate(self):
  34. self.resources.win_to_unix()
  35. source_files = []
  36. for r_type, n in IntermediateFile.FILE_TYPES.iteritems():
  37. for file in getattr(self.resources, r_type):
  38. source_files.append({
  39. 'name': file, 'type': n
  40. })
  41. libraries = []
  42. for lib in self.resources.libraries:
  43. l, _ = splitext(basename(lib))
  44. libraries.append(l[3:])
  45. if self.resources.linker_script is None:
  46. self.resources.linker_script = ''
  47. ctx = {
  48. 'name': self.program_name,
  49. 'target': self.target,
  50. 'toolchain': self.toolchain.name,
  51. 'source_files': source_files,
  52. 'include_paths': self.resources.inc_dirs,
  53. 'script_file': self.resources.linker_script,
  54. 'library_paths': self.resources.lib_dirs,
  55. 'libraries': libraries,
  56. 'symbols': self.get_symbols(),
  57. 'object_files': self.resources.objects,
  58. 'sys_libs': self.toolchain.sys_libs,
  59. 'cc_org': self.toolchain.cc[1:],
  60. 'ld_org': self.toolchain.ld[1:],
  61. 'cppc_org': self.toolchain.cppc[1:]
  62. }
  63. # EmBlocks intermediate file template
  64. self.gen_file('emblocks.eix.tmpl', ctx, '%s.eix' % self.program_name)