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