@@ -240,13 +240,9 @@ def parse_object_name_armcc(self, line):
240
240
return line
241
241
242
242
else :
243
-
244
- test_re_obj_name = re .match (RE_OBJECT_ARMCC , line )
245
-
246
- if test_re_obj_name :
247
- object_name = test_re_obj_name .group (1 ) + '/' + \
248
- test_re_obj_name .group (2 )
249
-
243
+ is_obj = re .match (RE_OBJECT_ARMCC , line )
244
+ if is_obj :
245
+ object_name = os .path .basename (is_obj .group (1 )) + '/' + is_obj .group (3 )
250
246
return '[lib]/' + object_name
251
247
else :
252
248
print "Malformed input found when parsing ARMCC map: %s" % line
@@ -374,11 +370,20 @@ def parse_map_file_armcc(self, file_desc):
374
370
375
371
# Start decoding the map file
376
372
for line in infile :
377
- object_name , object_size , section = self .parse_section_armcc (line )
378
- if object_name is not "" and section is not "" :
379
- self .module_add (object_name , object_size , section )
373
+ self .module_add (* self .parse_section_armcc (line ))
374
+
375
+ common_prefix = os .path .dirname (os .path .commonprefix ([
376
+ o for o in self .modules .keys () if (o .endswith (".o" ) and o != "anon$$obj.o" and not o .startswith ("[lib]" ))]))
377
+ new_modules = {}
378
+ for name , stats in self .modules .items ():
379
+ if name == "anon$$obj.o" or name .startswith ("[lib]" ):
380
+ new_modules [name ] = stats
381
+ elif name .endswith (".o" ):
382
+ new_modules [os .path .relpath (name , common_prefix )] = stats
383
+ else :
384
+ new_modules [name ] = stats
385
+ self .modules = new_modules
380
386
381
- self .rename_modules_from_fs (infile .name )
382
387
383
388
384
389
def check_new_library_iar (self , line ):
@@ -449,9 +454,7 @@ def parse_map_file_iar(self, file_desc):
449
454
break
450
455
451
456
for line in infile :
452
- name , size , section = self .parse_section_iar (line )
453
- if size and name and section :
454
- self .module_add (name , size , section )
457
+ self .module_add (* self .parse_section_iar (line ))
455
458
456
459
if line .startswith ('*** MODULE SUMMARY' ): # finish section
457
460
break
@@ -467,43 +470,10 @@ def parse_map_file_iar(self, file_desc):
467
470
object_name = self .check_new_object_lib_iar (line )
468
471
469
472
if object_name and current_library :
473
+ print ("Replacing module" , object_name , current_library )
470
474
temp = '[lib]' + '/' + current_library + '/' + object_name
471
475
self .module_replace (object_name , temp )
472
476
473
- def _rename_from_path (self , path , to_find , to_update , skip ):
474
- for root , subdirs , obj_files in os .walk (path ):
475
- if os .path .basename (root ) in skip :
476
- subdirs [:] = []
477
- continue
478
- basename = os .path .relpath (root , path )
479
- for filename in (to_find .intersection (set (obj_files ))):
480
- to_find .remove (filename )
481
- to_update [os .path .join (basename , filename )] = self .modules [filename ]
482
-
483
- def rename_modules_from_fs (self , path ):
484
- """ Converts the current module list to use the path to a module instead
485
- of the name in the map file
486
-
487
- Positional arguments:
488
- path - the path to a map file
489
- """
490
- new_modules = dict ()
491
- to_match = set (k for k in self .modules .keys () if not k .startswith ("[lib]" ))
492
- for module , v in self .modules .items ():
493
- if module .startswith ("[lib]" ):
494
- new_modules [module ] = v
495
- is_test = re .match (RE_IS_TEST , path )
496
- if is_test :
497
- self ._rename_from_path (is_test .group (1 ), to_match , new_modules , set (["TESTS" ]))
498
- self ._rename_from_path (os .path .dirname (path ), to_match , new_modules , set ())
499
- else :
500
- self ._rename_from_path (os .path .dirname (path ), to_match , new_modules , [])
501
-
502
- for module in to_match :
503
- new_modules [module ] = self .modules [module ]
504
-
505
- self .modules = new_modules
506
-
507
477
508
478
def reduce_depth (self , depth ):
509
479
"""
0 commit comments