Clone of official tools

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?

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