18
18
import os
19
19
import json
20
20
from collections import namedtuple
21
- from tools .targets import TARGET_MAP
22
21
from os .path import join , exists
23
22
from os import makedirs , remove
24
23
import shutil
25
24
from copy import deepcopy
25
+ from tools .targets import TARGET_MAP
26
26
27
27
from tools .export .makefile import Makefile , GccArm , Armc5 , IAR
28
28
@@ -38,19 +38,22 @@ class Eclipse(Makefile):
38
38
"""Generic Eclipse project. Intended to be subclassed by classes that
39
39
specify a type of Makefile.
40
40
"""
41
- def get_target_config (self , ctx , configuration ):
41
+ def get_target_config (self , configuration ):
42
42
"""Retrieve info from cdt_definitions.json"""
43
- tgt = deepcopy (TARGET_MAP [self .target ])
44
- defaults = deepcopy (_CONFIGS_OPTIONS ['default' ])
43
+ defaults = _CONFIGS_OPTIONS ['default' ]
45
44
eclipse_config = deepcopy (defaults ['generic' ])
46
45
if configuration in defaults :
47
46
eclipse_config .update (defaults [configuration ])
48
47
48
+ # Get target-specific options. Use labels to find alias
49
+ # for target. This allows to define options within inheritance path
49
50
target_specific = _CONFIGS_OPTIONS ['targets' ]
50
- if tgt .name in target_specific :
51
- eclipse_config .update (target_specific [tgt .name ]['generic' ])
52
- if configuration in target_specific [tgt .name ]:
53
- eclipse_config .update (target_specific [tgt .name ][configuration ])
51
+ for target_alias in self .toolchain .target .labels :
52
+ if target_alias in target_specific :
53
+ eclipse_config .update (target_specific [target_alias ]['generic' ])
54
+ if configuration in target_specific [target_alias ]:
55
+ eclipse_config .update (target_specific [target_alias ][configuration ])
56
+ break
54
57
55
58
return eclipse_config
56
59
@@ -63,7 +66,7 @@ def generate(self):
63
66
starting_dot = re .compile (r'(^[.]/|^[.]$)' )
64
67
ctx = {
65
68
'name' : self .project_name ,
66
- 'elf_location' : join ('BUILD' ,self .project_name )+ '.elf' ,
69
+ 'elf_location' : join ('BUILD' , self .project_name )+ '.elf' ,
67
70
'c_symbols' : self .toolchain .get_symbols (),
68
71
'asm_symbols' : self .toolchain .get_symbols (True ),
69
72
'target' : self .target ,
@@ -74,11 +77,11 @@ def generate(self):
74
77
launch_cfgs = {}
75
78
for launch_name in supported_launches :
76
79
launch = deepcopy (ctx )
77
- launch .update ({'device' : self .get_target_config (ctx , launch_name )})
80
+ launch .update ({'device' : self .get_target_config (launch_name )})
78
81
launch_cfgs [launch_name ] = launch
79
82
80
- if not exists (join (self .export_dir ,'eclipse-extras' )):
81
- makedirs (join (self .export_dir ,'eclipse-extras' ))
83
+ if not exists (join (self .export_dir , 'eclipse-extras' )):
84
+ makedirs (join (self .export_dir , 'eclipse-extras' ))
82
85
83
86
for launch_name , ctx in launch_cfgs .items ():
84
87
# Generate launch configurations for former GNU ARM Eclipse plug-in
@@ -95,7 +98,7 @@ def generate(self):
95
98
conf = launch_name )))
96
99
97
100
self .gen_file ('cdt/necessary_software.tmpl' , ctx ,
98
- join ('eclipse-extras' ,'necessary_software.p2f' ))
101
+ join ('eclipse-extras' , 'necessary_software.p2f' ))
99
102
100
103
self .gen_file ('cdt/.cproject.tmpl' , ctx , '.cproject' )
101
104
self .gen_file ('cdt/.project.tmpl' , ctx , '.project' )
@@ -119,7 +122,7 @@ class EclipseArmc5(Eclipse, Armc5):
119
122
def is_target_supported (cls , target_name ):
120
123
target = TARGET_MAP [target_name ]
121
124
if int (target .build_tools_metadata ["version" ]) > 0 :
122
- return "ARMC5" in target .supported_toolchains ;
125
+ return "ARMC5" in target .supported_toolchains
123
126
else :
124
127
return True
125
128
0 commit comments