Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: blinky_max32630fthr
simplicityv3.py
00001 """ 00002 mbed SDK 00003 Copyright (c) 2014-2016 ARM Limited 00004 00005 Licensed under the Apache License, Version 2.0 (the "License"); 00006 you may not use this file except in compliance with the License. 00007 You may obtain a copy of the License at 00008 00009 http://www.apache.org/licenses/LICENSE-2.0 00010 00011 Unless required by applicable law or agreed to in writing, software 00012 distributed under the License is distributed on an "AS IS" BASIS, 00013 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 See the License for the specific language governing permissions and 00015 limitations under the License. 00016 """ 00017 from exporters import Exporter 00018 from os.path import split,splitext, basename 00019 00020 class Folder: 00021 def __init__(self, name): 00022 self.name = name 00023 self.children = [] 00024 00025 def contains(self, folderName): 00026 for child in self.children: 00027 if child.name == folderName: 00028 return True 00029 return False 00030 00031 def __str__(self): 00032 retval = self.name + " " 00033 if len(self.children) > 0: 00034 retval += "[ " 00035 for child in self.children: 00036 retval += child.__str__() 00037 retval += " ]" 00038 00039 return retval 00040 00041 def findChild(self, folderName): 00042 for child in self.children: 00043 if child.name == folderName: 00044 return child 00045 return None 00046 00047 def addChild(self, folderName): 00048 if folderName == '': 00049 return None 00050 00051 if not self.contains(folderName): 00052 self.children.append(Folder(folderName)) 00053 00054 return self.findChild(folderName) 00055 00056 class SimplicityV3(Exporter): 00057 NAME = 'SimplicityV3' 00058 TOOLCHAIN = 'GCC_ARM' 00059 00060 TARGETS = [ 00061 'EFM32GG_STK3700', 00062 'EFM32ZG_STK3200', 00063 'EFM32LG_STK3600', 00064 'EFM32WG_STK3800', 00065 'EFM32HG_STK3400', 00066 'EFM32PG_STK3401' 00067 ] 00068 00069 PARTS = { 00070 'EFM32GG_STK3700': 'com.silabs.mcu.si32.efm32.efm32gg.efm32gg990f1024', 00071 'EFM32ZG_STK3200': 'com.silabs.mcu.si32.efm32.efm32zg.efm32zg222f32', 00072 'EFM32LG_STK3600': 'com.silabs.mcu.si32.efm32.efm32lg.efm32lg990f256', 00073 'EFM32WG_STK3800': 'com.silabs.mcu.si32.efm32.efm32wg.efm32wg990f256', 00074 'EFM32HG_STK3400': 'com.silabs.mcu.si32.efm32.efm32hg.efm32hg322f64', 00075 'EFM32PG_STK3401': 'com.silabs.mcu.si32.efm32.efm32pg1b.efm32pg1b200f256gm48' 00076 } 00077 00078 KITS = { 00079 'EFM32GG_STK3700': 'com.silabs.kit.si32.efm32.efm32gg.stk3700', 00080 'EFM32ZG_STK3200': 'com.silabs.kit.si32.efm32.efm32zg.stk3200', 00081 'EFM32LG_STK3600': 'com.silabs.kit.si32.efm32.efm32lg.stk3600', 00082 'EFM32WG_STK3800': 'com.silabs.kit.si32.efm32.efm32wg.stk3800', 00083 'EFM32HG_STK3400': 'com.silabs.kit.si32.efm32.efm32hg.slstk3400a', 00084 'EFM32PG_STK3401': 'com.silabs.kit.si32.efm32.efm32pg.slstk3401a' 00085 } 00086 00087 FILE_TYPES = { 00088 'c_sources':'1', 00089 'cpp_sources':'1', 00090 's_sources':'1' 00091 } 00092 00093 EXCLUDED_LIBS = [ 00094 'm', 00095 'c', 00096 'gcc', 00097 'nosys', 00098 'supc++', 00099 'stdc++' 00100 ] 00101 00102 DOT_IN_RELATIVE_PATH = False 00103 00104 MBED_CONFIG_HEADER_SUPPORTED = True 00105 00106 orderedPaths = Folder("Root") 00107 00108 def check_and_add_path(self, path): 00109 levels = path.split('/') 00110 base = self.orderedPaths 00111 for level in levels: 00112 if base.contains(level): 00113 base = base.findChild(level) 00114 else: 00115 base.addChild(level) 00116 base = base.findChild(level) 00117 00118 00119 def generate(self): 00120 # "make" wants Unix paths 00121 self.resources.win_to_unix() 00122 00123 main_files = [] 00124 00125 EXCLUDED_LIBS = [ 00126 'm', 00127 'c', 00128 'gcc', 00129 'nosys', 00130 'supc++', 00131 'stdc++' 00132 ] 00133 00134 for r_type in ['s_sources', 'c_sources', 'cpp_sources']: 00135 r = getattr(self.resources, r_type) 00136 if r: 00137 for source in r: 00138 self.check_and_add_path(split(source)[0]) 00139 00140 if not ('/' in source): 00141 main_files.append(source) 00142 00143 libraries = [] 00144 for lib in self.resources.libraries: 00145 l, _ = splitext(basename(lib)) 00146 if l[3:] not in EXCLUDED_LIBS: 00147 libraries.append(l[3:]) 00148 00149 defines = [] 00150 for define in self.toolchain.get_symbols(): 00151 if '=' in define: 00152 keyval = define.split('=') 00153 defines.append( (keyval[0], keyval[1]) ) 00154 else: 00155 defines.append( (define, '') ) 00156 00157 self.check_and_add_path(split(self.resources.linker_script)[0]) 00158 00159 ctx = { 00160 'name': self.project_name, 00161 'main_files': main_files, 00162 'recursiveFolders': self.orderedPaths, 00163 'object_files': self.resources.objects, 00164 'include_paths': self.resources.inc_dirs, 00165 'library_paths': self.resources.lib_dirs, 00166 'linker_script': self.resources.linker_script, 00167 'libraries': libraries, 00168 'defines': defines, 00169 'part': self.PARTS[self.target], 00170 'kit': self.KITS[self.target], 00171 'loopcount': 0 00172 } 00173 ctx.update(self.flags) 00174 00175 ## Strip main folder from include paths because ssproj is not capable of handling it 00176 if '.' in ctx['include_paths']: 00177 ctx['include_paths'].remove('.') 00178 ctx['include_root'] = True 00179 00180 ''' 00181 Suppress print statements 00182 print('\n') 00183 print(self.target) 00184 print('\n') 00185 print(ctx) 00186 print('\n') 00187 print(self.orderedPaths) 00188 for path in self.orderedPaths.children: 00189 print(path.name + "\n") 00190 for bpath in path.children: 00191 print("\t" + bpath.name + "\n") 00192 ''' 00193 00194 self.gen_file('simplicityv3_slsproj.tmpl', ctx, '%s.slsproj' % self.project_name)
Generated on Tue Jul 12 2022 14:21:19 by
1.7.2