Clone of official tools
Diff: export/sw4stm32/__init__.py
- Revision:
- 43:2a7da56ebd24
- Parent:
- 42:2cf3f29fece1
diff -r 2cf3f29fece1 -r 2a7da56ebd24 export/sw4stm32/__init__.py --- a/export/sw4stm32/__init__.py Mon Nov 06 13:17:14 2017 -0600 +++ b/export/sw4stm32/__init__.py Tue Sep 25 13:43:09 2018 -0500 @@ -14,12 +14,16 @@ See the License for the specific language governing permissions and limitations under the License. """ +from __future__ import print_function, absolute_import +from builtins import str -from os.path import splitext, basename, join +from os.path import splitext, basename, relpath, join +import shutil from tools.utils import mkdir from tools.export.gnuarmeclipse import GNUARMEclipse from tools.export.gnuarmeclipse import UID from tools.build_api import prepare_toolchain +from tools.targets import TARGET_MAP from sys import flags, platform # Global random number generator instance. @@ -99,6 +103,11 @@ 'name': 'DISCO-L072CZ-LRWAN1', 'mcuId': 'STM32L072CZTx' }, + 'MTB_MURATA_ABZ': + { + 'name': 'MTB-MURATA-ABZ', + 'mcuId': 'STM32L0x2xZ' + }, 'DISCO_L475VG_IOT01A': { 'name': 'STM32L475G-DISCO', @@ -189,6 +198,11 @@ 'name': 'NUCLEO-F411RE', 'mcuId': 'STM32F411RETx' }, + 'NUCLEO_F413ZH': + { + 'name': 'NUCLEO-F413ZH', + 'mcuId': 'STM32F413ZHTx' + }, 'NUCLEO_F429ZI': { 'name': 'NUCLEO-F429ZI', @@ -234,6 +248,11 @@ 'name': 'NUCLEO-L073RZ', 'mcuId': 'STM32L073RZTx' }, + 'MTB_RAK811': + { + 'name': 'MTB-RAK-811', + 'mcuId': 'STM32L151CBUxA' + }, 'NUCLEO_L152RE': { 'name': 'NUCLEO-L152RE', @@ -244,6 +263,11 @@ 'name': 'NUCLEO-L432KC', 'mcuId': 'STM32L432KCUx' }, + 'MTB_ADV_WISE_1510': + { + 'name': 'MTB-ADV-WISE-1510', + 'mcuId': 'STM32L443xC' + }, 'NUCLEO_L476RG': { 'name': 'NUCLEO-L476RG', @@ -258,10 +282,21 @@ { 'name': 'NUCLEO-L496ZG', 'mcuId': 'STM32L496ZGTx' - }, + }, + 'NUCLEO_L496ZG_P': + { + 'name': 'NUCLEO-L496ZG', + 'mcuId': 'STM32L496ZGTx' + }, } - TARGETS = BOARDS.keys() + @classmethod + def is_target_supported(cls, target_name): + target = TARGET_MAP[target_name] + target_supported = bool(set(target.resolution_order_names) + .intersection(set(cls.BOARDS.keys()))) + toolchain_supported = cls.TOOLCHAIN in target.supported_toolchains + return target_supported and toolchain_supported def __gen_dir(self, dir_name): """ @@ -391,17 +426,15 @@ if not self.resources.linker_script: raise NotSupportedException("No linker script found.") - print ('\nCreate a System Workbench for STM32 managed project') - print ('Project name: {0}'.format(self.project_name)) - print ('Target: {0}'.format(self.toolchain.target.name)) - print ('Toolchain: {0}'.format(self.TOOLCHAIN) + '\n') + print('\nCreate a System Workbench for STM32 managed project') + print('Project name: {0}'.format(self.project_name)) + print('Target: {0}'.format(self.toolchain.target.name)) + print('Toolchain: {0}'.format(self.TOOLCHAIN) + '\n') self.resources.win_to_unix() - config_header = self.filter_dot(self.toolchain.get_config_header()) - libraries = [] - for lib in self.resources.libraries: + for lib in self.libraries: library, _ = splitext(basename(lib)) libraries.append(library[3:]) @@ -415,19 +448,18 @@ self.c_defines = [s.replace('"', '"') for s in self.toolchain.get_symbols()] self.cpp_defines = self.c_defines - print 'Symbols: {0}'.format(len(self.c_defines)) self.include_path = [] for s in self.resources.inc_dirs: self.include_path.append("../" + self.filter_dot(s)) - print ('Include folders: {0}'.format(len(self.include_path))) + print('Include folders: {0}'.format(len(self.include_path))) self.compute_exclusions() - print ('Exclude folders: {0}'.format(len(self.excluded_folders))) + print('Exclude folders: {0}'.format(len(self.excluded_folders))) ld_script = self.filter_dot(self.resources.linker_script) - print ('Linker script: {0}'.format(ld_script)) + print('Linker script: {0}'.format(ld_script)) lib_dirs = [self.filter_dot(s) for s in self.resources.lib_dirs] @@ -444,9 +476,6 @@ opts['id'] = id opts['name'] = opts['id'].capitalize() - # TODO: Add prints to log or console in verbose mode. - #print ('\nBuild configuration: {0}'.format(opts['name'])) - profile = profiles[id] # A small hack, do not bother with src_path again, @@ -460,13 +489,6 @@ flags = self.toolchain_flags(toolchain) - # TODO: Add prints to log or console in verbose mode. - # print 'Common flags:', ' '.join(flags['common_flags']) - # print 'C++ flags:', ' '.join(flags['cxx_flags']) - # print 'C flags:', ' '.join(flags['c_flags']) - # print 'ASM flags:', ' '.join(flags['asm_flags']) - # print 'Linker flags:', ' '.join(flags['ld_flags']) - # Most GNU ARM Eclipse options have a parent, # either debug or release. if '-O0' in flags['common_flags'] or '-Og' in flags['common_flags']: @@ -505,7 +527,7 @@ 'name': self.project_name, 'platform': platform, 'include_paths': self.include_path, - 'config_header': config_header, + 'config_header': self.config_header_ref.name, 'exclude_paths': '|'.join(self.excluded_folders), 'ld_script': ld_script, 'library_paths': lib_dirs, @@ -529,3 +551,7 @@ 'makefile.targets', trim_blocks=True, lstrip_blocks=True) self.gen_file('sw4stm32/launch.tmpl', ctx, self.project_name + ' ' + options['debug']['name'] + '.launch') + + @staticmethod + def clean(_): + shutil.rmtree(".settings")