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