Clone of official tools

Committer:
The Other Jimmy
Date:
Wed Feb 15 13:53:18 2017 -0600
Revision:
35:da9c89f8be7d
Child:
40:7d3fa6b99b2b
Update tools to mbed-os 5.3.5

Who changed what in which revision?

UserRevisionLine numberNew 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 split,splitext, basename
The Other Jimmy 35:da9c89f8be7d 18
The Other Jimmy 35:da9c89f8be7d 19 from tools.export.exporters import Exporter
The Other Jimmy 35:da9c89f8be7d 20
The Other Jimmy 35:da9c89f8be7d 21 class Folder:
The Other Jimmy 35:da9c89f8be7d 22 def __init__(self, name):
The Other Jimmy 35:da9c89f8be7d 23 self.name = name
The Other Jimmy 35:da9c89f8be7d 24 self.children = []
The Other Jimmy 35:da9c89f8be7d 25
The Other Jimmy 35:da9c89f8be7d 26 def contains(self, folderName):
The Other Jimmy 35:da9c89f8be7d 27 for child in self.children:
The Other Jimmy 35:da9c89f8be7d 28 if child.name == folderName:
The Other Jimmy 35:da9c89f8be7d 29 return True
The Other Jimmy 35:da9c89f8be7d 30 return False
The Other Jimmy 35:da9c89f8be7d 31
The Other Jimmy 35:da9c89f8be7d 32 def __str__(self):
The Other Jimmy 35:da9c89f8be7d 33 retval = self.name + " "
The Other Jimmy 35:da9c89f8be7d 34 if len(self.children) > 0:
The Other Jimmy 35:da9c89f8be7d 35 retval += "[ "
The Other Jimmy 35:da9c89f8be7d 36 for child in self.children:
The Other Jimmy 35:da9c89f8be7d 37 retval += child.__str__()
The Other Jimmy 35:da9c89f8be7d 38 retval += " ]"
The Other Jimmy 35:da9c89f8be7d 39
The Other Jimmy 35:da9c89f8be7d 40 return retval
The Other Jimmy 35:da9c89f8be7d 41
The Other Jimmy 35:da9c89f8be7d 42 def findChild(self, folderName):
The Other Jimmy 35:da9c89f8be7d 43 for child in self.children:
The Other Jimmy 35:da9c89f8be7d 44 if child.name == folderName:
The Other Jimmy 35:da9c89f8be7d 45 return child
The Other Jimmy 35:da9c89f8be7d 46 return None
The Other Jimmy 35:da9c89f8be7d 47
The Other Jimmy 35:da9c89f8be7d 48 def addChild(self, folderName):
The Other Jimmy 35:da9c89f8be7d 49 if folderName == '':
The Other Jimmy 35:da9c89f8be7d 50 return None
The Other Jimmy 35:da9c89f8be7d 51
The Other Jimmy 35:da9c89f8be7d 52 if not self.contains(folderName):
The Other Jimmy 35:da9c89f8be7d 53 self.children.append(Folder(folderName))
The Other Jimmy 35:da9c89f8be7d 54
The Other Jimmy 35:da9c89f8be7d 55 return self.findChild(folderName)
The Other Jimmy 35:da9c89f8be7d 56
The Other Jimmy 35:da9c89f8be7d 57 class SimplicityV3(Exporter):
The Other Jimmy 35:da9c89f8be7d 58 NAME = 'SimplicityV3'
The Other Jimmy 35:da9c89f8be7d 59 TOOLCHAIN = 'GCC_ARM'
The Other Jimmy 35:da9c89f8be7d 60
The Other Jimmy 35:da9c89f8be7d 61 TARGETS = [
The Other Jimmy 35:da9c89f8be7d 62 'EFM32GG_STK3700',
The Other Jimmy 35:da9c89f8be7d 63 'EFM32ZG_STK3200',
The Other Jimmy 35:da9c89f8be7d 64 'EFM32LG_STK3600',
The Other Jimmy 35:da9c89f8be7d 65 'EFM32WG_STK3800',
The Other Jimmy 35:da9c89f8be7d 66 'EFM32HG_STK3400',
The Other Jimmy 35:da9c89f8be7d 67 'EFM32PG_STK3401'
The Other Jimmy 35:da9c89f8be7d 68 ]
The Other Jimmy 35:da9c89f8be7d 69
The Other Jimmy 35:da9c89f8be7d 70 PARTS = {
The Other Jimmy 35:da9c89f8be7d 71 'EFM32GG_STK3700': 'com.silabs.mcu.si32.efm32.efm32gg.efm32gg990f1024',
The Other Jimmy 35:da9c89f8be7d 72 'EFM32ZG_STK3200': 'com.silabs.mcu.si32.efm32.efm32zg.efm32zg222f32',
The Other Jimmy 35:da9c89f8be7d 73 'EFM32LG_STK3600': 'com.silabs.mcu.si32.efm32.efm32lg.efm32lg990f256',
The Other Jimmy 35:da9c89f8be7d 74 'EFM32WG_STK3800': 'com.silabs.mcu.si32.efm32.efm32wg.efm32wg990f256',
The Other Jimmy 35:da9c89f8be7d 75 'EFM32HG_STK3400': 'com.silabs.mcu.si32.efm32.efm32hg.efm32hg322f64',
The Other Jimmy 35:da9c89f8be7d 76 'EFM32PG_STK3401': 'com.silabs.mcu.si32.efm32.efm32pg1b.efm32pg1b200f256gm48'
The Other Jimmy 35:da9c89f8be7d 77 }
The Other Jimmy 35:da9c89f8be7d 78
The Other Jimmy 35:da9c89f8be7d 79 KITS = {
The Other Jimmy 35:da9c89f8be7d 80 'EFM32GG_STK3700': 'com.silabs.kit.si32.efm32.efm32gg.stk3700',
The Other Jimmy 35:da9c89f8be7d 81 'EFM32ZG_STK3200': 'com.silabs.kit.si32.efm32.efm32zg.stk3200',
The Other Jimmy 35:da9c89f8be7d 82 'EFM32LG_STK3600': 'com.silabs.kit.si32.efm32.efm32lg.stk3600',
The Other Jimmy 35:da9c89f8be7d 83 'EFM32WG_STK3800': 'com.silabs.kit.si32.efm32.efm32wg.stk3800',
The Other Jimmy 35:da9c89f8be7d 84 'EFM32HG_STK3400': 'com.silabs.kit.si32.efm32.efm32hg.slstk3400a',
The Other Jimmy 35:da9c89f8be7d 85 'EFM32PG_STK3401': 'com.silabs.kit.si32.efm32.efm32pg.slstk3401a'
The Other Jimmy 35:da9c89f8be7d 86 }
The Other Jimmy 35:da9c89f8be7d 87
The Other Jimmy 35:da9c89f8be7d 88 FILE_TYPES = {
The Other Jimmy 35:da9c89f8be7d 89 'c_sources':'1',
The Other Jimmy 35:da9c89f8be7d 90 'cpp_sources':'1',
The Other Jimmy 35:da9c89f8be7d 91 's_sources':'1'
The Other Jimmy 35:da9c89f8be7d 92 }
The Other Jimmy 35:da9c89f8be7d 93
The Other Jimmy 35:da9c89f8be7d 94 EXCLUDED_LIBS = [
The Other Jimmy 35:da9c89f8be7d 95 'm',
The Other Jimmy 35:da9c89f8be7d 96 'c',
The Other Jimmy 35:da9c89f8be7d 97 'gcc',
The Other Jimmy 35:da9c89f8be7d 98 'nosys',
The Other Jimmy 35:da9c89f8be7d 99 'supc++',
The Other Jimmy 35:da9c89f8be7d 100 'stdc++'
The Other Jimmy 35:da9c89f8be7d 101 ]
The Other Jimmy 35:da9c89f8be7d 102
The Other Jimmy 35:da9c89f8be7d 103 DOT_IN_RELATIVE_PATH = False
The Other Jimmy 35:da9c89f8be7d 104
The Other Jimmy 35:da9c89f8be7d 105 MBED_CONFIG_HEADER_SUPPORTED = True
The Other Jimmy 35:da9c89f8be7d 106
The Other Jimmy 35:da9c89f8be7d 107 orderedPaths = Folder("Root")
The Other Jimmy 35:da9c89f8be7d 108
The Other Jimmy 35:da9c89f8be7d 109 def check_and_add_path(self, path):
The Other Jimmy 35:da9c89f8be7d 110 levels = path.split('/')
The Other Jimmy 35:da9c89f8be7d 111 base = self.orderedPaths
The Other Jimmy 35:da9c89f8be7d 112 for level in levels:
The Other Jimmy 35:da9c89f8be7d 113 if base.contains(level):
The Other Jimmy 35:da9c89f8be7d 114 base = base.findChild(level)
The Other Jimmy 35:da9c89f8be7d 115 else:
The Other Jimmy 35:da9c89f8be7d 116 base.addChild(level)
The Other Jimmy 35:da9c89f8be7d 117 base = base.findChild(level)
The Other Jimmy 35:da9c89f8be7d 118
The Other Jimmy 35:da9c89f8be7d 119
The Other Jimmy 35:da9c89f8be7d 120 def generate(self):
The Other Jimmy 35:da9c89f8be7d 121 # "make" wants Unix paths
The Other Jimmy 35:da9c89f8be7d 122 self.resources.win_to_unix()
The Other Jimmy 35:da9c89f8be7d 123
The Other Jimmy 35:da9c89f8be7d 124 main_files = []
The Other Jimmy 35:da9c89f8be7d 125
The Other Jimmy 35:da9c89f8be7d 126 EXCLUDED_LIBS = [
The Other Jimmy 35:da9c89f8be7d 127 'm',
The Other Jimmy 35:da9c89f8be7d 128 'c',
The Other Jimmy 35:da9c89f8be7d 129 'gcc',
The Other Jimmy 35:da9c89f8be7d 130 'nosys',
The Other Jimmy 35:da9c89f8be7d 131 'supc++',
The Other Jimmy 35:da9c89f8be7d 132 'stdc++'
The Other Jimmy 35:da9c89f8be7d 133 ]
The Other Jimmy 35:da9c89f8be7d 134
The Other Jimmy 35:da9c89f8be7d 135 for r_type in ['s_sources', 'c_sources', 'cpp_sources']:
The Other Jimmy 35:da9c89f8be7d 136 r = getattr(self.resources, r_type)
The Other Jimmy 35:da9c89f8be7d 137 if r:
The Other Jimmy 35:da9c89f8be7d 138 for source in r:
The Other Jimmy 35:da9c89f8be7d 139 self.check_and_add_path(split(source)[0])
The Other Jimmy 35:da9c89f8be7d 140
The Other Jimmy 35:da9c89f8be7d 141 if not ('/' in source):
The Other Jimmy 35:da9c89f8be7d 142 main_files.append(source)
The Other Jimmy 35:da9c89f8be7d 143
The Other Jimmy 35:da9c89f8be7d 144 libraries = []
The Other Jimmy 35:da9c89f8be7d 145 for lib in self.resources.libraries:
The Other Jimmy 35:da9c89f8be7d 146 l, _ = splitext(basename(lib))
The Other Jimmy 35:da9c89f8be7d 147 if l[3:] not in EXCLUDED_LIBS:
The Other Jimmy 35:da9c89f8be7d 148 libraries.append(l[3:])
The Other Jimmy 35:da9c89f8be7d 149
The Other Jimmy 35:da9c89f8be7d 150 defines = []
The Other Jimmy 35:da9c89f8be7d 151 for define in self.toolchain.get_symbols():
The Other Jimmy 35:da9c89f8be7d 152 if '=' in define:
The Other Jimmy 35:da9c89f8be7d 153 keyval = define.split('=')
The Other Jimmy 35:da9c89f8be7d 154 defines.append( (keyval[0], keyval[1]) )
The Other Jimmy 35:da9c89f8be7d 155 else:
The Other Jimmy 35:da9c89f8be7d 156 defines.append( (define, '') )
The Other Jimmy 35:da9c89f8be7d 157
The Other Jimmy 35:da9c89f8be7d 158 self.check_and_add_path(split(self.resources.linker_script)[0])
The Other Jimmy 35:da9c89f8be7d 159
The Other Jimmy 35:da9c89f8be7d 160 ctx = {
The Other Jimmy 35:da9c89f8be7d 161 'name': self.project_name,
The Other Jimmy 35:da9c89f8be7d 162 'main_files': main_files,
The Other Jimmy 35:da9c89f8be7d 163 'recursiveFolders': self.orderedPaths,
The Other Jimmy 35:da9c89f8be7d 164 'object_files': self.resources.objects,
The Other Jimmy 35:da9c89f8be7d 165 'include_paths': self.resources.inc_dirs,
The Other Jimmy 35:da9c89f8be7d 166 'library_paths': self.resources.lib_dirs,
The Other Jimmy 35:da9c89f8be7d 167 'linker_script': self.resources.linker_script,
The Other Jimmy 35:da9c89f8be7d 168 'libraries': libraries,
The Other Jimmy 35:da9c89f8be7d 169 'defines': defines,
The Other Jimmy 35:da9c89f8be7d 170 'part': self.PARTS[self.target],
The Other Jimmy 35:da9c89f8be7d 171 'kit': self.KITS[self.target],
The Other Jimmy 35:da9c89f8be7d 172 'loopcount': 0
The Other Jimmy 35:da9c89f8be7d 173 }
The Other Jimmy 35:da9c89f8be7d 174 ctx.update(self.flags)
The Other Jimmy 35:da9c89f8be7d 175
The Other Jimmy 35:da9c89f8be7d 176 ## Strip main folder from include paths because ssproj is not capable of handling it
The Other Jimmy 35:da9c89f8be7d 177 if '.' in ctx['include_paths']:
The Other Jimmy 35:da9c89f8be7d 178 ctx['include_paths'].remove('.')
The Other Jimmy 35:da9c89f8be7d 179 ctx['include_root'] = True
The Other Jimmy 35:da9c89f8be7d 180
The Other Jimmy 35:da9c89f8be7d 181 '''
The Other Jimmy 35:da9c89f8be7d 182 Suppress print statements
The Other Jimmy 35:da9c89f8be7d 183 print('\n')
The Other Jimmy 35:da9c89f8be7d 184 print(self.target)
The Other Jimmy 35:da9c89f8be7d 185 print('\n')
The Other Jimmy 35:da9c89f8be7d 186 print(ctx)
The Other Jimmy 35:da9c89f8be7d 187 print('\n')
The Other Jimmy 35:da9c89f8be7d 188 print(self.orderedPaths)
The Other Jimmy 35:da9c89f8be7d 189 for path in self.orderedPaths.children:
The Other Jimmy 35:da9c89f8be7d 190 print(path.name + "\n")
The Other Jimmy 35:da9c89f8be7d 191 for bpath in path.children:
The Other Jimmy 35:da9c89f8be7d 192 print("\t" + bpath.name + "\n")
The Other Jimmy 35:da9c89f8be7d 193 '''
The Other Jimmy 35:da9c89f8be7d 194
The Other Jimmy 35:da9c89f8be7d 195 self.gen_file('simplicity/slsproj.tmpl', ctx, '%s.slsproj' % self.project_name)