Clone of official tools
export/embitz/__init__.py@47:21ae3e5a7128, 2021-02-04 (annotated)
- Committer:
- Anders Blomdell
- Date:
- Thu Feb 04 17:17:13 2021 +0100
- Revision:
- 47:21ae3e5a7128
- Parent:
- 43:2a7da56ebd24
Add a few normpath calls
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
The Other Jimmy |
35:da9c89f8be7d | 1 | """ |
The Other Jimmy |
35:da9c89f8be7d | 2 | mbed SDK |
The Other Jimmy |
35:da9c89f8be7d | 3 | Copyright (c) 2014-2016 ARM Limited |
The Other Jimmy |
35:da9c89f8be7d | 4 | |
The Other Jimmy |
35:da9c89f8be7d | 5 | Licensed under the Apache License, Version 2.0 (the "License"); |
The Other Jimmy |
35:da9c89f8be7d | 6 | you may not use this file except in compliance with the License. |
The Other Jimmy |
35:da9c89f8be7d | 7 | You may obtain a copy of the License at |
The Other Jimmy |
35:da9c89f8be7d | 8 | |
The Other Jimmy |
35:da9c89f8be7d | 9 | http://www.apache.org/licenses/LICENSE-2.0 |
The Other Jimmy |
35:da9c89f8be7d | 10 | |
The Other Jimmy |
35:da9c89f8be7d | 11 | Unless required by applicable law or agreed to in writing, software |
The Other Jimmy |
35:da9c89f8be7d | 12 | distributed under the License is distributed on an "AS IS" BASIS, |
The Other Jimmy |
35:da9c89f8be7d | 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
The Other Jimmy |
35:da9c89f8be7d | 14 | See the License for the specific language governing permissions and |
The Other Jimmy |
35:da9c89f8be7d | 15 | limitations under the License. |
The Other Jimmy |
35:da9c89f8be7d | 16 | """ |
The Other Jimmy |
35:da9c89f8be7d | 17 | from os.path import splitext, basename |
theotherjimmy |
43:2a7da56ebd24 | 18 | from os import remove |
The Other Jimmy |
35:da9c89f8be7d | 19 | from tools.targets import TARGET_MAP |
theotherjimmy |
40:7d3fa6b99b2b | 20 | from tools.export.exporters import Exporter, apply_supported_whitelist |
The Other Jimmy |
36:96847d42f010 | 21 | |
The Other Jimmy |
36:96847d42f010 | 22 | |
The Other Jimmy |
36:96847d42f010 | 23 | POST_BINARY_WHITELIST = set([ |
The Other Jimmy |
36:96847d42f010 | 24 | "TEENSY3_1Code.binary_hook", |
The Other Jimmy |
36:96847d42f010 | 25 | "LPCTargetCode.lpc_patch", |
The Other Jimmy |
36:96847d42f010 | 26 | "LPC4088Code.binary_hook" |
The Other Jimmy |
36:96847d42f010 | 27 | ]) |
The Other Jimmy |
36:96847d42f010 | 28 | |
The Other Jimmy |
35:da9c89f8be7d | 29 | |
The Other Jimmy |
35:da9c89f8be7d | 30 | class EmBitz(Exporter): |
The Other Jimmy |
35:da9c89f8be7d | 31 | NAME = 'EmBitz' |
The Other Jimmy |
35:da9c89f8be7d | 32 | TOOLCHAIN = 'GCC_ARM' |
The Other Jimmy |
35:da9c89f8be7d | 33 | |
The Other Jimmy |
35:da9c89f8be7d | 34 | MBED_CONFIG_HEADER_SUPPORTED = True |
The Other Jimmy |
35:da9c89f8be7d | 35 | |
The Other Jimmy |
35:da9c89f8be7d | 36 | FILE_TYPES = { |
The Other Jimmy |
35:da9c89f8be7d | 37 | 'headers': 'h', |
The Other Jimmy |
35:da9c89f8be7d | 38 | 'c_sources': 'c', |
The Other Jimmy |
35:da9c89f8be7d | 39 | 's_sources': 'a', |
The Other Jimmy |
35:da9c89f8be7d | 40 | 'cpp_sources': 'cpp' |
The Other Jimmy |
35:da9c89f8be7d | 41 | } |
The Other Jimmy |
35:da9c89f8be7d | 42 | |
theotherjimmy |
40:7d3fa6b99b2b | 43 | @classmethod |
theotherjimmy |
40:7d3fa6b99b2b | 44 | def is_target_supported(cls, target_name): |
theotherjimmy |
40:7d3fa6b99b2b | 45 | target = TARGET_MAP[target_name] |
theotherjimmy |
40:7d3fa6b99b2b | 46 | return apply_supported_whitelist( |
theotherjimmy |
40:7d3fa6b99b2b | 47 | cls.TOOLCHAIN, POST_BINARY_WHITELIST, target) |
The Other Jimmy |
35:da9c89f8be7d | 48 | |
The Other Jimmy |
35:da9c89f8be7d | 49 | @staticmethod |
The Other Jimmy |
35:da9c89f8be7d | 50 | def _remove_symbols(sym_list): |
The Other Jimmy |
35:da9c89f8be7d | 51 | return [s for s in sym_list if not s.startswith("-D")] |
The Other Jimmy |
35:da9c89f8be7d | 52 | |
The Other Jimmy |
35:da9c89f8be7d | 53 | def generate(self): |
The Other Jimmy |
35:da9c89f8be7d | 54 | self.resources.win_to_unix() |
The Other Jimmy |
35:da9c89f8be7d | 55 | source_files = [] |
theotherjimmy |
43:2a7da56ebd24 | 56 | for r_type, n in self.FILE_TYPES.items(): |
The Other Jimmy |
35:da9c89f8be7d | 57 | for file in getattr(self.resources, r_type): |
The Other Jimmy |
35:da9c89f8be7d | 58 | source_files.append({ |
The Other Jimmy |
35:da9c89f8be7d | 59 | 'name': file, 'type': n |
The Other Jimmy |
35:da9c89f8be7d | 60 | }) |
The Other Jimmy |
35:da9c89f8be7d | 61 | |
The Other Jimmy |
35:da9c89f8be7d | 62 | libraries = [] |
theotherjimmy |
43:2a7da56ebd24 | 63 | for lib in self.libraries: |
The Other Jimmy |
35:da9c89f8be7d | 64 | l, _ = splitext(basename(lib)) |
The Other Jimmy |
35:da9c89f8be7d | 65 | libraries.append(l[3:]) |
The Other Jimmy |
35:da9c89f8be7d | 66 | |
The Other Jimmy |
35:da9c89f8be7d | 67 | |
The Other Jimmy |
35:da9c89f8be7d | 68 | if self.resources.linker_script is None: |
The Other Jimmy |
35:da9c89f8be7d | 69 | self.resources.linker_script = '' |
The Other Jimmy |
35:da9c89f8be7d | 70 | |
The Other Jimmy |
35:da9c89f8be7d | 71 | ctx = { |
The Other Jimmy |
35:da9c89f8be7d | 72 | 'name': self.project_name, |
The Other Jimmy |
35:da9c89f8be7d | 73 | 'target': self.target, |
The Other Jimmy |
35:da9c89f8be7d | 74 | 'toolchain': self.toolchain.name, |
The Other Jimmy |
35:da9c89f8be7d | 75 | 'source_files': source_files, |
The Other Jimmy |
35:da9c89f8be7d | 76 | 'include_paths': self.resources.inc_dirs, |
The Other Jimmy |
35:da9c89f8be7d | 77 | 'script_file': self.resources.linker_script, |
The Other Jimmy |
35:da9c89f8be7d | 78 | 'library_paths': self.resources.lib_dirs, |
The Other Jimmy |
35:da9c89f8be7d | 79 | 'libraries': libraries, |
The Other Jimmy |
35:da9c89f8be7d | 80 | 'symbols': self.toolchain.get_symbols(), |
The Other Jimmy |
35:da9c89f8be7d | 81 | 'object_files': self.resources.objects, |
The Other Jimmy |
35:da9c89f8be7d | 82 | 'sys_libs': self.toolchain.sys_libs, |
The Other Jimmy |
35:da9c89f8be7d | 83 | 'cc_org': (self.flags['common_flags'] + |
The Other Jimmy |
35:da9c89f8be7d | 84 | self._remove_symbols(self.flags['c_flags'])), |
The Other Jimmy |
35:da9c89f8be7d | 85 | 'ld_org': self.flags['ld_flags'], |
The Other Jimmy |
35:da9c89f8be7d | 86 | 'cppc_org': (self.flags['common_flags'] + |
The Other Jimmy |
35:da9c89f8be7d | 87 | self._remove_symbols(self.flags['cxx_flags'])) |
The Other Jimmy |
35:da9c89f8be7d | 88 | } |
The Other Jimmy |
35:da9c89f8be7d | 89 | |
The Other Jimmy |
35:da9c89f8be7d | 90 | self.gen_file('embitz/eix.tmpl', ctx, '%s.eix' % self.project_name) |
theotherjimmy |
43:2a7da56ebd24 | 91 | |
theotherjimmy |
43:2a7da56ebd24 | 92 | @staticmethod |
theotherjimmy |
43:2a7da56ebd24 | 93 | def clean(project_name): |
theotherjimmy |
43:2a7da56ebd24 | 94 | remove("%s.eix" % project_name) |