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.
__init__.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 os.path import split,splitext, basename 00018 00019 from tools.export.exporters import Exporter, deprecated_exporter 00020 00021 class Folder: 00022 def __init__(self, name): 00023 self.name = name 00024 self.children = [] 00025 00026 def contains(self, folderName): 00027 for child in self.children: 00028 if child.name == folderName: 00029 return True 00030 return False 00031 00032 def __str__(self): 00033 retval = self.name + " " 00034 if len(self.children) > 0: 00035 retval += "[ " 00036 for child in self.children: 00037 retval += child.__str__() 00038 retval += " ]" 00039 00040 return retval 00041 00042 def findChild(self, folderName): 00043 for child in self.children: 00044 if child.name == folderName: 00045 return child 00046 return None 00047 00048 def addChild(self, folderName): 00049 if folderName == '': 00050 return None 00051 00052 if not self.contains(folderName): 00053 self.children.append(Folder(folderName)) 00054 00055 return self.findChild(folderName) 00056 00057 @deprecated_exporter 00058 class SimplicityV3(Exporter ): 00059 NAME = 'SimplicityV3' 00060 TOOLCHAIN = 'GCC_ARM' 00061 00062 TARGETS = [ 00063 'EFM32GG_STK3700', 00064 'EFM32ZG_STK3200', 00065 'EFM32LG_STK3600', 00066 'EFM32WG_STK3800', 00067 'EFM32HG_STK3400', 00068 'EFM32PG_STK3401' 00069 ] 00070 00071 PARTS = { 00072 'EFM32GG_STK3700': 'com.silabs.mcu.si32.efm32.efm32gg.efm32gg990f1024', 00073 'EFM32ZG_STK3200': 'com.silabs.mcu.si32.efm32.efm32zg.efm32zg222f32', 00074 'EFM32LG_STK3600': 'com.silabs.mcu.si32.efm32.efm32lg.efm32lg990f256', 00075 'EFM32WG_STK3800': 'com.silabs.mcu.si32.efm32.efm32wg.efm32wg990f256', 00076 'EFM32HG_STK3400': 'com.silabs.mcu.si32.efm32.efm32hg.efm32hg322f64', 00077 'EFM32PG_STK3401': 'com.silabs.mcu.si32.efm32.efm32pg1b.efm32pg1b200f256gm48' 00078 } 00079 00080 KITS = { 00081 'EFM32GG_STK3700': 'com.silabs.kit.si32.efm32.efm32gg.stk3700', 00082 'EFM32ZG_STK3200': 'com.silabs.kit.si32.efm32.efm32zg.stk3200', 00083 'EFM32LG_STK3600': 'com.silabs.kit.si32.efm32.efm32lg.stk3600', 00084 'EFM32WG_STK3800': 'com.silabs.kit.si32.efm32.efm32wg.stk3800', 00085 'EFM32HG_STK3400': 'com.silabs.kit.si32.efm32.efm32hg.slstk3400a', 00086 'EFM32PG_STK3401': 'com.silabs.kit.si32.efm32.efm32pg.slstk3401a' 00087 } 00088 00089 FILE_TYPES = { 00090 'c_sources':'1', 00091 'cpp_sources':'1', 00092 's_sources':'1' 00093 } 00094 00095 EXCLUDED_LIBS = [ 00096 'm', 00097 'c', 00098 'gcc', 00099 'nosys', 00100 'supc++', 00101 'stdc++' 00102 ] 00103 00104 DOT_IN_RELATIVE_PATH = False 00105 00106 MBED_CONFIG_HEADER_SUPPORTED = True 00107 00108 orderedPaths = Folder("Root") 00109 00110 def check_and_add_path(self, path): 00111 levels = path.split('/') 00112 base = self.orderedPaths 00113 for level in levels: 00114 if base.contains(level): 00115 base = base.findChild(level) 00116 else: 00117 base.addChild(level) 00118 base = base.findChild(level) 00119 00120 00121 def generate(self): 00122 # "make" wants Unix paths 00123 self.resources.win_to_unix() 00124 00125 main_files = [] 00126 00127 EXCLUDED_LIBS = [ 00128 'm', 00129 'c', 00130 'gcc', 00131 'nosys', 00132 'supc++', 00133 'stdc++' 00134 ] 00135 00136 for r_type in ['s_sources', 'c_sources', 'cpp_sources']: 00137 r = getattr(self.resources, r_type) 00138 if r: 00139 for source in r: 00140 self.check_and_add_path(split(source)[0]) 00141 00142 if not ('/' in source): 00143 main_files.append(source) 00144 00145 libraries = [] 00146 for lib in self.resources.libraries: 00147 l, _ = splitext(basename(lib)) 00148 if l[3:] not in EXCLUDED_LIBS: 00149 libraries.append(l[3:]) 00150 00151 defines = [] 00152 for define in self.toolchain.get_symbols(): 00153 if '=' in define: 00154 keyval = define.split('=') 00155 defines.append( (keyval[0], keyval[1]) ) 00156 else: 00157 defines.append( (define, '') ) 00158 00159 self.check_and_add_path(split(self.resources.linker_script)[0]) 00160 00161 ctx = { 00162 'name': self.project_name, 00163 'main_files': main_files, 00164 'recursiveFolders': self.orderedPaths, 00165 'object_files': self.resources.objects, 00166 'include_paths': self.resources.inc_dirs, 00167 'library_paths': self.resources.lib_dirs, 00168 'linker_script': self.resources.linker_script, 00169 'libraries': libraries, 00170 'defines': defines, 00171 'part': self.PARTS[self.target], 00172 'kit': self.KITS[self.target], 00173 'loopcount': 0 00174 } 00175 ctx.update(self.flags) 00176 00177 ## Strip main folder from include paths because ssproj is not capable of handling it 00178 if '.' in ctx['include_paths']: 00179 ctx['include_paths'].remove('.') 00180 ctx['include_root'] = True 00181 00182 ''' 00183 Suppress print statements 00184 print('\n') 00185 print(self.target) 00186 print('\n') 00187 print(ctx) 00188 print('\n') 00189 print(self.orderedPaths) 00190 for path in self.orderedPaths.children: 00191 print(path.name + "\n") 00192 for bpath in path.children: 00193 print("\t" + bpath.name + "\n") 00194 ''' 00195 00196 self.gen_file('simplicity/slsproj.tmpl', ctx, '%s.slsproj' % self.project_name)
Generated on Thu Jul 14 2022 14:36:11 by
