User | Revision | Line number | New contents of line |
nexpaq |
0:6c56fb4bc5f0
|
1
|
"""
|
nexpaq |
0:6c56fb4bc5f0
|
2
|
mbed SDK
|
nexpaq |
0:6c56fb4bc5f0
|
3
|
Copyright (c) 2011-2016 ARM Limited
|
nexpaq |
0:6c56fb4bc5f0
|
4
|
|
nexpaq |
0:6c56fb4bc5f0
|
5
|
Licensed under the Apache License, Version 2.0 (the "License");
|
nexpaq |
0:6c56fb4bc5f0
|
6
|
you may not use this file except in compliance with the License.
|
nexpaq |
0:6c56fb4bc5f0
|
7
|
You may obtain a copy of the License at
|
nexpaq |
0:6c56fb4bc5f0
|
8
|
|
nexpaq |
0:6c56fb4bc5f0
|
9
|
http://www.apache.org/licenses/LICENSE-2.0
|
nexpaq |
0:6c56fb4bc5f0
|
10
|
|
nexpaq |
0:6c56fb4bc5f0
|
11
|
Unless required by applicable law or agreed to in writing, software
|
nexpaq |
0:6c56fb4bc5f0
|
12
|
distributed under the License is distributed on an "AS IS" BASIS,
|
nexpaq |
0:6c56fb4bc5f0
|
13
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
nexpaq |
0:6c56fb4bc5f0
|
14
|
See the License for the specific language governing permissions and
|
nexpaq |
0:6c56fb4bc5f0
|
15
|
limitations under the License.
|
nexpaq |
0:6c56fb4bc5f0
|
16
|
"""
|
nexpaq |
0:6c56fb4bc5f0
|
17
|
import uuid
|
nexpaq |
0:6c56fb4bc5f0
|
18
|
from exporters import Exporter
|
nexpaq |
0:6c56fb4bc5f0
|
19
|
from os.path import splitext, basename, dirname
|
nexpaq |
0:6c56fb4bc5f0
|
20
|
|
nexpaq |
0:6c56fb4bc5f0
|
21
|
|
nexpaq |
0:6c56fb4bc5f0
|
22
|
class AtmelStudio(Exporter):
|
nexpaq |
0:6c56fb4bc5f0
|
23
|
NAME = 'AtmelStudio'
|
nexpaq |
0:6c56fb4bc5f0
|
24
|
TOOLCHAIN = 'GCC_ARM'
|
nexpaq |
0:6c56fb4bc5f0
|
25
|
|
nexpaq |
0:6c56fb4bc5f0
|
26
|
TARGETS = [
|
nexpaq |
0:6c56fb4bc5f0
|
27
|
'SAMD21J18A',
|
nexpaq |
0:6c56fb4bc5f0
|
28
|
'SAMR21G18A',
|
nexpaq |
0:6c56fb4bc5f0
|
29
|
'SAMD21G18A',
|
nexpaq |
0:6c56fb4bc5f0
|
30
|
'SAML21J18A',
|
nexpaq |
0:6c56fb4bc5f0
|
31
|
'SAMG55J19',
|
nexpaq |
0:6c56fb4bc5f0
|
32
|
]
|
nexpaq |
0:6c56fb4bc5f0
|
33
|
|
nexpaq |
0:6c56fb4bc5f0
|
34
|
DOT_IN_RELATIVE_PATH = True
|
nexpaq |
0:6c56fb4bc5f0
|
35
|
|
nexpaq |
0:6c56fb4bc5f0
|
36
|
MBED_CONFIG_HEADER_SUPPORTED = True
|
nexpaq |
0:6c56fb4bc5f0
|
37
|
|
nexpaq |
0:6c56fb4bc5f0
|
38
|
def generate(self):
|
nexpaq |
0:6c56fb4bc5f0
|
39
|
|
nexpaq |
0:6c56fb4bc5f0
|
40
|
source_files = []
|
nexpaq |
0:6c56fb4bc5f0
|
41
|
dirs = []
|
nexpaq |
0:6c56fb4bc5f0
|
42
|
for r_type in ['s_sources', 'c_sources', 'cpp_sources']:
|
nexpaq |
0:6c56fb4bc5f0
|
43
|
r = getattr(self.resources, r_type)
|
nexpaq |
0:6c56fb4bc5f0
|
44
|
if r:
|
nexpaq |
0:6c56fb4bc5f0
|
45
|
for source in r:
|
nexpaq |
0:6c56fb4bc5f0
|
46
|
source_files.append(source[2:])
|
nexpaq |
0:6c56fb4bc5f0
|
47
|
dirs.append(dirname(source[2:]))
|
nexpaq |
0:6c56fb4bc5f0
|
48
|
|
nexpaq |
0:6c56fb4bc5f0
|
49
|
source_folders = []
|
nexpaq |
0:6c56fb4bc5f0
|
50
|
for e in dirs:
|
nexpaq |
0:6c56fb4bc5f0
|
51
|
if e and e not in source_folders:
|
nexpaq |
0:6c56fb4bc5f0
|
52
|
source_folders.append(e)
|
nexpaq |
0:6c56fb4bc5f0
|
53
|
|
nexpaq |
0:6c56fb4bc5f0
|
54
|
libraries = []
|
nexpaq |
0:6c56fb4bc5f0
|
55
|
for lib in self.resources.libraries:
|
nexpaq |
0:6c56fb4bc5f0
|
56
|
l, _ = splitext(basename(lib))
|
nexpaq |
0:6c56fb4bc5f0
|
57
|
libraries.append(l[3:])
|
nexpaq |
0:6c56fb4bc5f0
|
58
|
|
nexpaq |
0:6c56fb4bc5f0
|
59
|
solution_uuid = '{' + str(uuid.uuid4()) + '}'
|
nexpaq |
0:6c56fb4bc5f0
|
60
|
project_uuid = '{' + str(uuid.uuid4()) + '}'
|
nexpaq |
0:6c56fb4bc5f0
|
61
|
|
nexpaq |
0:6c56fb4bc5f0
|
62
|
ctx = {
|
nexpaq |
0:6c56fb4bc5f0
|
63
|
'target': self.target,
|
nexpaq |
0:6c56fb4bc5f0
|
64
|
'name': self.project_name,
|
nexpaq |
0:6c56fb4bc5f0
|
65
|
'source_files': source_files,
|
nexpaq |
0:6c56fb4bc5f0
|
66
|
'source_folders': source_folders,
|
nexpaq |
0:6c56fb4bc5f0
|
67
|
'object_files': self.resources.objects,
|
nexpaq |
0:6c56fb4bc5f0
|
68
|
'include_paths': self.resources.inc_dirs,
|
nexpaq |
0:6c56fb4bc5f0
|
69
|
'library_paths': self.resources.lib_dirs,
|
nexpaq |
0:6c56fb4bc5f0
|
70
|
'linker_script': self.resources.linker_script,
|
nexpaq |
0:6c56fb4bc5f0
|
71
|
'libraries': libraries,
|
nexpaq |
0:6c56fb4bc5f0
|
72
|
'symbols': self.toolchain.get_symbols(),
|
nexpaq |
0:6c56fb4bc5f0
|
73
|
'solution_uuid': solution_uuid.upper(),
|
nexpaq |
0:6c56fb4bc5f0
|
74
|
'project_uuid': project_uuid.upper()
|
nexpaq |
0:6c56fb4bc5f0
|
75
|
}
|
nexpaq |
0:6c56fb4bc5f0
|
76
|
ctx.update(self.flags)
|
nexpaq |
0:6c56fb4bc5f0
|
77
|
target = self.target.lower()
|
nexpaq |
0:6c56fb4bc5f0
|
78
|
self.gen_file('atmelstudio6_2.atsln.tmpl', ctx, '%s.atsln' % self.project_name)
|
nexpaq |
0:6c56fb4bc5f0
|
79
|
self.gen_file('atmelstudio6_2.cppproj.tmpl', ctx, '%s.cppproj' % self.project_name)
|