Rtos API example

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers __init__.py Source File

__init__.py

00001 """
00002 mbed SDK
00003 Copyright (c) 2011-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 import uuid
00018 from os.path import splitext, basename, dirname
00019 
00020 from tools.export.exporters import Exporter, deprecated_exporter
00021 
00022 
00023 @deprecated_exporter
00024 class AtmelStudio(Exporter ):
00025     NAME = 'AtmelStudio'
00026     TOOLCHAIN = 'GCC_ARM'
00027 
00028     TARGETS = [
00029         'SAMD21J18A',
00030         'SAMR21G18A',
00031         'SAMD21G18A',
00032         'SAML21J18A',
00033         'SAMG55J19',
00034     ]
00035 
00036     DOT_IN_RELATIVE_PATH = True
00037 
00038     MBED_CONFIG_HEADER_SUPPORTED = True
00039 
00040     @classmethod
00041     def is_target_supported(cls, maybe_supported):
00042         return maybe_supported in cls.TARGETS
00043 
00044     def generate(self):
00045 
00046         source_files = []
00047         dirs = []
00048         for r_type in ['s_sources', 'c_sources', 'cpp_sources']:
00049             r = getattr(self.resources, r_type)
00050             if r:
00051                 for source in r:
00052                     source_files.append(source[2:])
00053                     dirs.append(dirname(source[2:]))
00054 
00055         source_folders = []
00056         for e in dirs:
00057             if e and e not in source_folders:
00058                 source_folders.append(e)
00059 
00060         libraries = []
00061         for lib in self.resources.libraries:
00062             l, _ = splitext(basename(lib))
00063             libraries.append(l[3:])
00064         
00065         solution_uuid = '{' + str(uuid.uuid4()) + '}'
00066         project_uuid = '{' + str(uuid.uuid4()) + '}'
00067 
00068         ctx = {
00069             'target': self.target,
00070             'name': self.project_name,
00071             'source_files': source_files,
00072             'source_folders': source_folders,
00073             'object_files': self.resources.objects,
00074             'include_paths': self.resources.inc_dirs,
00075             'library_paths': self.resources.lib_dirs,
00076             'linker_script': self.resources.linker_script,
00077             'libraries': libraries,
00078             'symbols': self.toolchain.get_symbols(),
00079             'solution_uuid': solution_uuid.upper(),
00080             'project_uuid': project_uuid.upper()
00081         }
00082         ctx.update(self.flags)
00083         target = self.target.lower()
00084         self.gen_file('atmelstudio/atsln.tmpl', ctx, '%s.atsln' % self.project_name)
00085         self.gen_file('atmelstudio/cppproj.tmpl', ctx, '%s.cppproj' % self.project_name)