@@ -49,31 +49,31 @@ def IARAddGroup(parent, name, files, project_path):
4949 group = SubElement (parent , 'group' )
5050 group_name = SubElement (group , 'name' )
5151 group_name .text = name
52-
52+
5353 for f in files :
5454 fn = f .rfile ()
5555 name = fn .name
5656 path = os .path .dirname (fn .abspath )
57-
5857 basename = os .path .basename (path )
5958 path = _make_path_relative (project_path , path )
6059 path = os .path .join (path , name )
61-
60+
6261 file = SubElement (group , 'file' )
6362 file_name = SubElement (file , 'name' )
63+
6464 if os .path .isabs (path ):
6565 file_name .text = path .decode (fs_encoding )
6666 else :
6767 file_name .text = ('$PROJ_DIR$\\ ' + path ).decode (fs_encoding )
6868
6969def IARWorkspace (target ):
70- # make an workspace
70+ # make an workspace
7171 workspace = target .replace ('.ewp' , '.eww' )
7272 out = file (workspace , 'wb' )
7373 xml = iar_workspace % target
7474 out .write (xml )
7575 out .close ()
76-
76+
7777def IARProject (target , script ):
7878 project_path = os .path .dirname (os .path .abspath (target ))
7979
@@ -87,37 +87,46 @@ def IARProject(target, script):
8787 LINKFLAGS = ''
8888 CCFLAGS = ''
8989 Libs = []
90-
90+ lib_prefix = ['lib' , '' ]
91+ lib_suffix = ['.a' , '.o' , '' ]
92+
93+ def searchLib (group ):
94+ for path_item in group ['LIBPATH' ]:
95+ for prefix_item in lib_prefix :
96+ for suffix_item in lib_suffix :
97+ lib_full_path = os .path .join (path_item , prefix_item + item + suffix_item )
98+ if os .path .isfile (lib_full_path ):
99+ return lib_full_path
100+ else :
101+ return ''
102+
91103 # add group
92104 for group in script :
93105 IARAddGroup (root , group ['name' ], group ['src' ], project_path )
94106
95107 # get each include path
96108 if group .has_key ('CPPPATH' ) and group ['CPPPATH' ]:
97109 CPPPATH += group ['CPPPATH' ]
98-
110+
99111 # get each group's definitions
100112 if group .has_key ('CPPDEFINES' ) and group ['CPPDEFINES' ]:
101113 CPPDEFINES += group ['CPPDEFINES' ]
102-
114+
103115 # get each group's link flags
104116 if group .has_key ('LINKFLAGS' ) and group ['LINKFLAGS' ]:
105117 LINKFLAGS += group ['LINKFLAGS' ]
106-
118+
107119 if group .has_key ('LIBS' ) and group ['LIBS' ]:
108120 for item in group ['LIBS' ]:
109- lib_path = ''
110-
111- for path_item in group ['LIBPATH' ]:
112- full_path = os .path .join (path_item , item + '.a' )
113- if os .path .isfile (full_path ): # has this library
114- lib_path = full_path
115-
121+ lib_path = searchLib (group )
116122 if lib_path != '' :
117123 lib_path = _make_path_relative (project_path , lib_path )
118124 Libs += [lib_path ]
125+ # print('found lib isfile: ' + lib_path)
126+ else :
127+ print ('not found LIB: ' + item )
119128
120- # make relative path
129+ # make relative path
121130 paths = set ()
122131 for path in CPPPATH :
123132 inc = _make_path_relative (project_path , os .path .normpath (path ))
@@ -156,7 +165,7 @@ def IARProject(target, script):
156165 out .close ()
157166
158167 IARWorkspace (target )
159-
168+
160169def IARVersion ():
161170 import subprocess
162171 import re
0 commit comments