Clone of official tools
export/atmelstudio/__init__.py@47:21ae3e5a7128, 2021-02-04 (annotated)
- Committer:
- Anders Blomdell
- Date:
- Thu Feb 04 17:17:13 2021 +0100
- Revision:
- 47:21ae3e5a7128
- Parent:
- 43:2a7da56ebd24
Add a few normpath calls
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
The Other Jimmy |
35:da9c89f8be7d | 1 | """ |
The Other Jimmy |
35:da9c89f8be7d | 2 | mbed SDK |
The Other Jimmy |
35:da9c89f8be7d | 3 | Copyright (c) 2011-2016 ARM Limited |
The Other Jimmy |
35:da9c89f8be7d | 4 | |
The Other Jimmy |
35:da9c89f8be7d | 5 | Licensed under the Apache License, Version 2.0 (the "License"); |
The Other Jimmy |
35:da9c89f8be7d | 6 | you may not use this file except in compliance with the License. |
The Other Jimmy |
35:da9c89f8be7d | 7 | You may obtain a copy of the License at |
The Other Jimmy |
35:da9c89f8be7d | 8 | |
The Other Jimmy |
35:da9c89f8be7d | 9 | http://www.apache.org/licenses/LICENSE-2.0 |
The Other Jimmy |
35:da9c89f8be7d | 10 | |
The Other Jimmy |
35:da9c89f8be7d | 11 | Unless required by applicable law or agreed to in writing, software |
The Other Jimmy |
35:da9c89f8be7d | 12 | distributed under the License is distributed on an "AS IS" BASIS, |
The Other Jimmy |
35:da9c89f8be7d | 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
The Other Jimmy |
35:da9c89f8be7d | 14 | See the License for the specific language governing permissions and |
The Other Jimmy |
35:da9c89f8be7d | 15 | limitations under the License. |
The Other Jimmy |
35:da9c89f8be7d | 16 | """ |
The Other Jimmy |
35:da9c89f8be7d | 17 | import uuid |
The Other Jimmy |
35:da9c89f8be7d | 18 | from os.path import splitext, basename, dirname |
theotherjimmy |
43:2a7da56ebd24 | 19 | from os import remove |
The Other Jimmy |
35:da9c89f8be7d | 20 | |
theotherjimmy |
40:7d3fa6b99b2b | 21 | from tools.export.exporters import Exporter, deprecated_exporter |
The Other Jimmy |
35:da9c89f8be7d | 22 | |
The Other Jimmy |
35:da9c89f8be7d | 23 | |
theotherjimmy |
40:7d3fa6b99b2b | 24 | @deprecated_exporter |
The Other Jimmy |
35:da9c89f8be7d | 25 | class AtmelStudio(Exporter): |
The Other Jimmy |
35:da9c89f8be7d | 26 | NAME = 'AtmelStudio' |
The Other Jimmy |
35:da9c89f8be7d | 27 | TOOLCHAIN = 'GCC_ARM' |
The Other Jimmy |
35:da9c89f8be7d | 28 | |
The Other Jimmy |
35:da9c89f8be7d | 29 | TARGETS = [ |
The Other Jimmy |
35:da9c89f8be7d | 30 | 'SAMD21J18A', |
The Other Jimmy |
35:da9c89f8be7d | 31 | 'SAMR21G18A', |
The Other Jimmy |
35:da9c89f8be7d | 32 | 'SAMD21G18A', |
The Other Jimmy |
35:da9c89f8be7d | 33 | 'SAML21J18A', |
The Other Jimmy |
35:da9c89f8be7d | 34 | 'SAMG55J19', |
The Other Jimmy |
35:da9c89f8be7d | 35 | ] |
The Other Jimmy |
35:da9c89f8be7d | 36 | |
The Other Jimmy |
35:da9c89f8be7d | 37 | DOT_IN_RELATIVE_PATH = True |
The Other Jimmy |
35:da9c89f8be7d | 38 | |
The Other Jimmy |
35:da9c89f8be7d | 39 | MBED_CONFIG_HEADER_SUPPORTED = True |
The Other Jimmy |
35:da9c89f8be7d | 40 | |
theotherjimmy |
40:7d3fa6b99b2b | 41 | @classmethod |
theotherjimmy |
40:7d3fa6b99b2b | 42 | def is_target_supported(cls, maybe_supported): |
theotherjimmy |
40:7d3fa6b99b2b | 43 | return maybe_supported in cls.TARGETS |
theotherjimmy |
40:7d3fa6b99b2b | 44 | |
The Other Jimmy |
35:da9c89f8be7d | 45 | def generate(self): |
The Other Jimmy |
35:da9c89f8be7d | 46 | |
The Other Jimmy |
35:da9c89f8be7d | 47 | source_files = [] |
The Other Jimmy |
35:da9c89f8be7d | 48 | dirs = [] |
The Other Jimmy |
35:da9c89f8be7d | 49 | for r_type in ['s_sources', 'c_sources', 'cpp_sources']: |
The Other Jimmy |
35:da9c89f8be7d | 50 | r = getattr(self.resources, r_type) |
The Other Jimmy |
35:da9c89f8be7d | 51 | if r: |
The Other Jimmy |
35:da9c89f8be7d | 52 | for source in r: |
The Other Jimmy |
35:da9c89f8be7d | 53 | source_files.append(source[2:]) |
The Other Jimmy |
35:da9c89f8be7d | 54 | dirs.append(dirname(source[2:])) |
The Other Jimmy |
35:da9c89f8be7d | 55 | |
The Other Jimmy |
35:da9c89f8be7d | 56 | source_folders = [] |
The Other Jimmy |
35:da9c89f8be7d | 57 | for e in dirs: |
The Other Jimmy |
35:da9c89f8be7d | 58 | if e and e not in source_folders: |
The Other Jimmy |
35:da9c89f8be7d | 59 | source_folders.append(e) |
The Other Jimmy |
35:da9c89f8be7d | 60 | |
The Other Jimmy |
35:da9c89f8be7d | 61 | libraries = [] |
theotherjimmy |
43:2a7da56ebd24 | 62 | for lib in self.libraries: |
The Other Jimmy |
35:da9c89f8be7d | 63 | l, _ = splitext(basename(lib)) |
The Other Jimmy |
35:da9c89f8be7d | 64 | libraries.append(l[3:]) |
The Other Jimmy |
35:da9c89f8be7d | 65 | |
The Other Jimmy |
35:da9c89f8be7d | 66 | solution_uuid = '{' + str(uuid.uuid4()) + '}' |
The Other Jimmy |
35:da9c89f8be7d | 67 | project_uuid = '{' + str(uuid.uuid4()) + '}' |
The Other Jimmy |
35:da9c89f8be7d | 68 | |
The Other Jimmy |
35:da9c89f8be7d | 69 | ctx = { |
The Other Jimmy |
35:da9c89f8be7d | 70 | 'target': self.target, |
The Other Jimmy |
35:da9c89f8be7d | 71 | 'name': self.project_name, |
The Other Jimmy |
35:da9c89f8be7d | 72 | 'source_files': source_files, |
The Other Jimmy |
35:da9c89f8be7d | 73 | 'source_folders': source_folders, |
The Other Jimmy |
35:da9c89f8be7d | 74 | 'object_files': self.resources.objects, |
The Other Jimmy |
35:da9c89f8be7d | 75 | 'include_paths': self.resources.inc_dirs, |
The Other Jimmy |
35:da9c89f8be7d | 76 | 'library_paths': self.resources.lib_dirs, |
The Other Jimmy |
35:da9c89f8be7d | 77 | 'linker_script': self.resources.linker_script, |
The Other Jimmy |
35:da9c89f8be7d | 78 | 'libraries': libraries, |
The Other Jimmy |
35:da9c89f8be7d | 79 | 'symbols': self.toolchain.get_symbols(), |
The Other Jimmy |
35:da9c89f8be7d | 80 | 'solution_uuid': solution_uuid.upper(), |
The Other Jimmy |
35:da9c89f8be7d | 81 | 'project_uuid': project_uuid.upper() |
The Other Jimmy |
35:da9c89f8be7d | 82 | } |
The Other Jimmy |
35:da9c89f8be7d | 83 | ctx.update(self.flags) |
The Other Jimmy |
35:da9c89f8be7d | 84 | target = self.target.lower() |
The Other Jimmy |
35:da9c89f8be7d | 85 | self.gen_file('atmelstudio/atsln.tmpl', ctx, '%s.atsln' % self.project_name) |
The Other Jimmy |
35:da9c89f8be7d | 86 | self.gen_file('atmelstudio/cppproj.tmpl', ctx, '%s.cppproj' % self.project_name) |
theotherjimmy |
43:2a7da56ebd24 | 87 | |
theotherjimmy |
43:2a7da56ebd24 | 88 | @staticmethod |
theotherjimmy |
43:2a7da56ebd24 | 89 | def clean(project_name): |
theotherjimmy |
43:2a7da56ebd24 | 90 | remove('%s.atsln' % project_name) |
theotherjimmy |
43:2a7da56ebd24 | 91 | remove('%s.cppproj' % project_name) |