Clone of official tools

Committer:
theotherjimmy
Date:
Tue Oct 10 16:56:30 2017 -0500
Revision:
40:7d3fa6b99b2b
Parent:
35:da9c89f8be7d
Child:
43:2a7da56ebd24
Update to tools release 5.6.1

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