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,23 @@ 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 resolution order and extra labels
49
+ # to find alias 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
+ aliases = self .toolchain .target .resolution_order_names \
52
+ + self .toolchain .target .extra_labels
53
+ target_alias = next ((t for t in aliases if t in target_specific ), None )
54
+ if target_alias :
55
+ eclipse_config .update (target_specific [target_alias ]['generic' ])
56
+ if configuration in target_specific [target_alias ]:
57
+ eclipse_config .update (target_specific [target_alias ][configuration ])
54
58
55
59
return eclipse_config
56
60
@@ -63,7 +67,7 @@ def generate(self):
63
67
starting_dot = re .compile (r'(^[.]/|^[.]$)' )
64
68
ctx = {
65
69
'name' : self .project_name ,
66
- 'elf_location' : join ('BUILD' ,self .project_name )+ '.elf' ,
70
+ 'elf_location' : join ('BUILD' , self .project_name )+ '.elf' ,
67
71
'c_symbols' : self .toolchain .get_symbols (),
68
72
'asm_symbols' : self .toolchain .get_symbols (True ),
69
73
'target' : self .target ,
@@ -74,11 +78,11 @@ def generate(self):
74
78
launch_cfgs = {}
75
79
for launch_name in supported_launches :
76
80
launch = deepcopy (ctx )
77
- launch .update ({'device' : self .get_target_config (ctx , launch_name )})
81
+ launch .update ({'device' : self .get_target_config (launch_name )})
78
82
launch_cfgs [launch_name ] = launch
79
83
80
- if not exists (join (self .export_dir ,'eclipse-extras' )):
81
- makedirs (join (self .export_dir ,'eclipse-extras' ))
84
+ if not exists (join (self .export_dir , 'eclipse-extras' )):
85
+ makedirs (join (self .export_dir , 'eclipse-extras' ))
82
86
83
87
for launch_name , ctx in launch_cfgs .items ():
84
88
# Generate launch configurations for former GNU ARM Eclipse plug-in
@@ -95,7 +99,7 @@ def generate(self):
95
99
conf = launch_name )))
96
100
97
101
self .gen_file ('cdt/necessary_software.tmpl' , ctx ,
98
- join ('eclipse-extras' ,'necessary_software.p2f' ))
102
+ join ('eclipse-extras' , 'necessary_software.p2f' ))
99
103
100
104
self .gen_file ('cdt/.cproject.tmpl' , ctx , '.cproject' )
101
105
self .gen_file ('cdt/.project.tmpl' , ctx , '.project' )
@@ -119,7 +123,7 @@ class EclipseArmc5(Eclipse, Armc5):
119
123
def is_target_supported (cls , target_name ):
120
124
target = TARGET_MAP [target_name ]
121
125
if int (target .build_tools_metadata ["version" ]) > 0 :
122
- return "ARMC5" in target .supported_toolchains ;
126
+ return "ARMC5" in target .supported_toolchains
123
127
else :
124
128
return True
125
129
0 commit comments