MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / IARProject

Function IARProject

tools/targets/iar.py:80–175  ·  view source on GitHub ↗
(env, target, script)

Source from the content-addressed store, hash-verified

78 out.close()
79
80def IARProject(env, target, script):
81 project_path = os.path.dirname(os.path.abspath(target))
82
83 tree = etree.parse('template.ewp')
84 root = tree.getroot()
85
86 out = open(target, 'w')
87
88 CPPPATH = []
89 CPPDEFINES = env.get('CPPDEFINES', [])
90 LOCAL_CPPDEFINES = []
91 LINKFLAGS = ''
92 CFLAGS = ''
93 Libs = []
94 lib_prefix = ['lib', '']
95 lib_suffix = ['.a', '.o', '']
96
97 def searchLib(group):
98 for path_item in group['LIBPATH']:
99 for prefix_item in lib_prefix:
100 for suffix_item in lib_suffix:
101 lib_full_path = os.path.join(path_item, prefix_item + item + suffix_item)
102 if os.path.isfile(lib_full_path):
103 return lib_full_path
104 else:
105 return ''
106
107 # add group
108 for group in script:
109 IARAddGroup(root, group['name'], group['src'], project_path)
110
111 # get each include path
112 if 'CPPPATH' in group and group['CPPPATH']:
113 CPPPATH += group['CPPPATH']
114
115
116 if 'LOCAL_CPPDEFINES' in group and group['LOCAL_CPPDEFINES']:
117 LOCAL_CPPDEFINES += group['LOCAL_CPPDEFINES']
118
119 # get each group's link flags
120 if 'LINKFLAGS' in group and group['LINKFLAGS']:
121 LINKFLAGS += group['LINKFLAGS']
122
123 if 'LIBS' in group and group['LIBS']:
124 for item in group['LIBS']:
125 lib_path = searchLib(group)
126 if lib_path != '':
127 lib_path = _make_path_relative(project_path, lib_path)
128 Libs += [lib_path]
129 # print('found lib isfile: ' + lib_path)
130 else:
131 print('not found LIB: ' + item)
132
133 # make relative path
134 paths = set()
135 for path in CPPPATH:
136 inc = _make_path_relative(project_path, os.path.normpath(path))
137 paths.add(inc) #.replace('\\', '/')

Callers 1

GenTargetProjectFunction · 0.90

Calls 9

_make_path_relativeFunction · 0.90
xml_indentFunction · 0.90
IARAddGroupFunction · 0.85
searchLibFunction · 0.85
IARWorkspaceFunction · 0.85
openFunction · 0.50
setFunction · 0.50
getMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected