Preliminary main mbed library for nexpaq development
tools/export/coide.py@1:d96dbedaebdb, 2016-11-04 (annotated)
- Committer:
- nexpaq
- Date:
- Fri Nov 04 20:54:50 2016 +0000
- Revision:
- 1:d96dbedaebdb
- Parent:
- 0:6c56fb4bc5f0
Removed extra directories for other platforms
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nexpaq | 0:6c56fb4bc5f0 | 1 | """ |
nexpaq | 0:6c56fb4bc5f0 | 2 | mbed SDK |
nexpaq | 0:6c56fb4bc5f0 | 3 | Copyright (c) 2014-2016 ARM Limited |
nexpaq | 0:6c56fb4bc5f0 | 4 | |
nexpaq | 0:6c56fb4bc5f0 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); |
nexpaq | 0:6c56fb4bc5f0 | 6 | you may not use this file except in compliance with the License. |
nexpaq | 0:6c56fb4bc5f0 | 7 | You may obtain a copy of the License at |
nexpaq | 0:6c56fb4bc5f0 | 8 | |
nexpaq | 0:6c56fb4bc5f0 | 9 | http://www.apache.org/licenses/LICENSE-2.0 |
nexpaq | 0:6c56fb4bc5f0 | 10 | |
nexpaq | 0:6c56fb4bc5f0 | 11 | Unless required by applicable law or agreed to in writing, software |
nexpaq | 0:6c56fb4bc5f0 | 12 | distributed under the License is distributed on an "AS IS" BASIS, |
nexpaq | 0:6c56fb4bc5f0 | 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
nexpaq | 0:6c56fb4bc5f0 | 14 | See the License for the specific language governing permissions and |
nexpaq | 0:6c56fb4bc5f0 | 15 | limitations under the License. |
nexpaq | 0:6c56fb4bc5f0 | 16 | """ |
nexpaq | 0:6c56fb4bc5f0 | 17 | from exporters import Exporter |
nexpaq | 0:6c56fb4bc5f0 | 18 | from os.path import splitext, basename |
nexpaq | 0:6c56fb4bc5f0 | 19 | |
nexpaq | 0:6c56fb4bc5f0 | 20 | |
nexpaq | 0:6c56fb4bc5f0 | 21 | class CoIDE(Exporter): |
nexpaq | 0:6c56fb4bc5f0 | 22 | NAME = 'CoIDE' |
nexpaq | 0:6c56fb4bc5f0 | 23 | TOOLCHAIN = 'GCC_ARM' |
nexpaq | 0:6c56fb4bc5f0 | 24 | |
nexpaq | 0:6c56fb4bc5f0 | 25 | TARGETS = [ |
nexpaq | 0:6c56fb4bc5f0 | 26 | 'KL25Z', |
nexpaq | 0:6c56fb4bc5f0 | 27 | 'KL05Z', |
nexpaq | 0:6c56fb4bc5f0 | 28 | 'LPC1768', |
nexpaq | 0:6c56fb4bc5f0 | 29 | 'ARCH_PRO', |
nexpaq | 0:6c56fb4bc5f0 | 30 | 'ARCH_MAX', |
nexpaq | 0:6c56fb4bc5f0 | 31 | 'UBLOX_C027', |
nexpaq | 0:6c56fb4bc5f0 | 32 | 'NUCLEO_L011K4', |
nexpaq | 0:6c56fb4bc5f0 | 33 | 'NUCLEO_L053R8', |
nexpaq | 0:6c56fb4bc5f0 | 34 | 'NUCLEO_L152RE', |
nexpaq | 0:6c56fb4bc5f0 | 35 | 'NUCLEO_F030R8', |
nexpaq | 0:6c56fb4bc5f0 | 36 | 'NUCLEO_F042K6', |
nexpaq | 0:6c56fb4bc5f0 | 37 | 'NUCLEO_F070RB', |
nexpaq | 0:6c56fb4bc5f0 | 38 | 'NUCLEO_F072RB', |
nexpaq | 0:6c56fb4bc5f0 | 39 | 'NUCLEO_F091RC', |
nexpaq | 0:6c56fb4bc5f0 | 40 | 'NUCLEO_F103RB', |
nexpaq | 0:6c56fb4bc5f0 | 41 | 'NUCLEO_F207ZG', |
nexpaq | 0:6c56fb4bc5f0 | 42 | 'NUCLEO_F302R8', |
nexpaq | 0:6c56fb4bc5f0 | 43 | 'NUCLEO_F303K8', |
nexpaq | 0:6c56fb4bc5f0 | 44 | 'NUCLEO_F303RE', |
nexpaq | 0:6c56fb4bc5f0 | 45 | 'NUCLEO_F334R8', |
nexpaq | 0:6c56fb4bc5f0 | 46 | 'NUCLEO_F303ZE', |
nexpaq | 0:6c56fb4bc5f0 | 47 | 'NUCLEO_F401RE', |
nexpaq | 0:6c56fb4bc5f0 | 48 | 'NUCLEO_F410RB', |
nexpaq | 0:6c56fb4bc5f0 | 49 | 'NUCLEO_F411RE', |
nexpaq | 0:6c56fb4bc5f0 | 50 | 'NUCLEO_F429ZI', |
nexpaq | 0:6c56fb4bc5f0 | 51 | 'NUCLEO_F446RE', |
nexpaq | 0:6c56fb4bc5f0 | 52 | 'NUCLEO_F446ZE', |
nexpaq | 0:6c56fb4bc5f0 | 53 | 'DISCO_L053C8', |
nexpaq | 0:6c56fb4bc5f0 | 54 | 'DISCO_F051R8', |
nexpaq | 0:6c56fb4bc5f0 | 55 | 'DISCO_F100RB', |
nexpaq | 0:6c56fb4bc5f0 | 56 | 'DISCO_F303VC', |
nexpaq | 0:6c56fb4bc5f0 | 57 | 'DISCO_F334C8', |
nexpaq | 0:6c56fb4bc5f0 | 58 | 'DISCO_F401VC', |
nexpaq | 0:6c56fb4bc5f0 | 59 | 'DISCO_F407VG', |
nexpaq | 0:6c56fb4bc5f0 | 60 | 'DISCO_F429ZI', |
nexpaq | 0:6c56fb4bc5f0 | 61 | 'DISCO_F469NI', |
nexpaq | 0:6c56fb4bc5f0 | 62 | 'MTS_MDOT_F405RG', |
nexpaq | 0:6c56fb4bc5f0 | 63 | 'MTS_MDOT_F411RE', |
nexpaq | 0:6c56fb4bc5f0 | 64 | 'MOTE_L152RC', |
nexpaq | 0:6c56fb4bc5f0 | 65 | 'NZ32_SC151', |
nexpaq | 0:6c56fb4bc5f0 | 66 | ] |
nexpaq | 0:6c56fb4bc5f0 | 67 | |
nexpaq | 0:6c56fb4bc5f0 | 68 | # seems like CoIDE currently supports only one type |
nexpaq | 0:6c56fb4bc5f0 | 69 | FILE_TYPES = { |
nexpaq | 0:6c56fb4bc5f0 | 70 | 'c_sources':'1', |
nexpaq | 0:6c56fb4bc5f0 | 71 | 'cpp_sources':'1', |
nexpaq | 0:6c56fb4bc5f0 | 72 | 's_sources':'1' |
nexpaq | 0:6c56fb4bc5f0 | 73 | } |
nexpaq | 0:6c56fb4bc5f0 | 74 | FILE_TYPES2 = { |
nexpaq | 0:6c56fb4bc5f0 | 75 | 'headers':'1' |
nexpaq | 0:6c56fb4bc5f0 | 76 | } |
nexpaq | 0:6c56fb4bc5f0 | 77 | |
nexpaq | 0:6c56fb4bc5f0 | 78 | def generate(self): |
nexpaq | 0:6c56fb4bc5f0 | 79 | self.resources.win_to_unix() |
nexpaq | 0:6c56fb4bc5f0 | 80 | source_files = [] |
nexpaq | 0:6c56fb4bc5f0 | 81 | for r_type, n in CoIDE.FILE_TYPES.iteritems(): |
nexpaq | 0:6c56fb4bc5f0 | 82 | for file in getattr(self.resources, r_type): |
nexpaq | 0:6c56fb4bc5f0 | 83 | source_files.append({ |
nexpaq | 0:6c56fb4bc5f0 | 84 | 'name': basename(file), 'type': n, 'path': file |
nexpaq | 0:6c56fb4bc5f0 | 85 | }) |
nexpaq | 0:6c56fb4bc5f0 | 86 | header_files = [] |
nexpaq | 0:6c56fb4bc5f0 | 87 | for r_type, n in CoIDE.FILE_TYPES2.iteritems(): |
nexpaq | 0:6c56fb4bc5f0 | 88 | for file in getattr(self.resources, r_type): |
nexpaq | 0:6c56fb4bc5f0 | 89 | header_files.append({ |
nexpaq | 0:6c56fb4bc5f0 | 90 | 'name': basename(file), 'type': n, 'path': file |
nexpaq | 0:6c56fb4bc5f0 | 91 | }) |
nexpaq | 0:6c56fb4bc5f0 | 92 | |
nexpaq | 0:6c56fb4bc5f0 | 93 | libraries = [] |
nexpaq | 0:6c56fb4bc5f0 | 94 | for lib in self.resources.libraries: |
nexpaq | 0:6c56fb4bc5f0 | 95 | l, _ = splitext(basename(lib)) |
nexpaq | 0:6c56fb4bc5f0 | 96 | libraries.append(l[3:]) |
nexpaq | 0:6c56fb4bc5f0 | 97 | |
nexpaq | 0:6c56fb4bc5f0 | 98 | if self.resources.linker_script is None: |
nexpaq | 0:6c56fb4bc5f0 | 99 | self.resources.linker_script = '' |
nexpaq | 0:6c56fb4bc5f0 | 100 | |
nexpaq | 0:6c56fb4bc5f0 | 101 | ctx = { |
nexpaq | 0:6c56fb4bc5f0 | 102 | 'name': self.project_name, |
nexpaq | 0:6c56fb4bc5f0 | 103 | 'source_files': source_files, |
nexpaq | 0:6c56fb4bc5f0 | 104 | 'header_files': header_files, |
nexpaq | 0:6c56fb4bc5f0 | 105 | 'include_paths': self.resources.inc_dirs, |
nexpaq | 0:6c56fb4bc5f0 | 106 | 'scatter_file': self.resources.linker_script, |
nexpaq | 0:6c56fb4bc5f0 | 107 | 'library_paths': self.resources.lib_dirs, |
nexpaq | 0:6c56fb4bc5f0 | 108 | 'object_files': self.resources.objects, |
nexpaq | 0:6c56fb4bc5f0 | 109 | 'libraries': libraries, |
nexpaq | 0:6c56fb4bc5f0 | 110 | 'symbols': self.toolchain.get_symbols() |
nexpaq | 0:6c56fb4bc5f0 | 111 | } |
nexpaq | 0:6c56fb4bc5f0 | 112 | target = self.target.lower() |
nexpaq | 0:6c56fb4bc5f0 | 113 | |
nexpaq | 0:6c56fb4bc5f0 | 114 | # Project file |
nexpaq | 0:6c56fb4bc5f0 | 115 | self.gen_file('coide_%s.coproj.tmpl' % target, ctx, '%s.coproj' % self.project_name) |