@@ -26,7 +26,53 @@ Export('RTT_ROOT')
2626Export ('rtconfig' )
2727
2828# prepare building environment
29- objs = PrepareBuilding (env , RTT_ROOT , has_libcpu = True )
29+ objs = PrepareBuilding (env , RTT_ROOT )
30+
31+ def _replace_cortex_r52_with_startup (objects ):
32+ startup_dir = os .path .join (Dir ('#' ).abspath , 'startup' )
33+ startup_names = set (
34+ name for name in os .listdir (startup_dir )
35+ if os .path .isfile (os .path .join (startup_dir , name ))
36+ )
37+ cpu_dir = os .path .abspath (os .path .join (RTT_ROOT , 'libcpu' , 'arm' , 'cortex-r52' ))
38+
39+ def _source_path (node ):
40+ for attr in ('srcnode' , 'rfile' ):
41+ if hasattr (node , attr ):
42+ source = getattr (node , attr )()
43+ if hasattr (source , 'abspath' ):
44+ return os .path .abspath (source .abspath )
45+ if hasattr (node , 'abspath' ):
46+ return os .path .abspath (node .abspath )
47+ return None
48+
49+ def _filter (items ):
50+ filtered = []
51+ for item in items :
52+ if isinstance (item , list ):
53+ filtered .append (_filter (item ))
54+ continue
55+
56+ if not hasattr (item , 'abspath' ):
57+ filtered .append (item )
58+ continue
59+
60+ item_path = _source_path (item )
61+ if item_path is None :
62+ filtered .append (item )
63+ continue
64+
65+ item_name = os .path .basename (item_path )
66+ if item_name in startup_names and item_path .startswith (cpu_dir + os .sep ):
67+ continue
68+
69+ filtered .append (item )
70+
71+ return filtered
72+
73+ return _filter (objects )
74+
75+ objs = _replace_cortex_r52_with_startup (objs )
3076
3177# make a building
3278DoBuilding (TARGET , objs )
0 commit comments