@@ -248,10 +248,9 @@ def extract_from_thin_archive(inputFile):
248248 arOutput = arProc .communicate ()[0 ]
249249 if arProc .returncode != 0 :
250250 _logger .error ('ar failed on %s' , inputFile )
251- sys .exit (- 1 )
252-
253- lines = arOutput .splitlines ()
254- return lines
251+ else :
252+ retval = arOutput .splitlines ()
253+ return retval
255254
256255
257256
@@ -280,17 +279,17 @@ def handleThinArchive(pArgs):
280279
281280 bcFiles = []
282281 for p in objectPaths :
283- _logger .info ('handleThinArchive: processing {0}' . format ( p ) )
282+ _logger .info ('handleThinArchive: processing %s' , p )
284283 contents = pArgs .extractor (p )
285284 for c in contents :
286- if len ( c ) > 0 :
287- _logger .info ('\t including {0}' . format ( c ) )
285+ if c :
286+ _logger .info ('\t including %s' , c )
288287 bcFiles .append (str (c ))
289288
290289 return buildArchive (pArgs , bcFiles )
291290
292291#iam: do we want to preserve the order in the archive? if so we need to return both the list and the dict.
293- def fetchTOC (pArgs , inputFile ):
292+ def fetchTOC (inputFile ):
294293 toc = {}
295294
296295 arCmd = ['ar' , '-t' , inputFile ] #iam: check if this might be os dependent
@@ -333,11 +332,11 @@ def handleArchive(pArgs):
333332
334333 originalDir = os .getcwd () # We want to end up back where we started.
335334
336- toc = fetchTOC (pArgs , inputFile )
335+ toc = fetchTOC (inputFile )
337336
338337 if not toc :
339338 _logger .warning ('No files found, so nothing to be done.' )
340- return
339+ return 0
341340
342341 bitCodeFiles = []
343342
@@ -353,31 +352,31 @@ def handleArchive(pArgs):
353352 arP = Popen (arCmd )
354353 except Exception as e :
355354 _logger .error (e )
356- return
355+ return 1
357356
358357 arPE = arP .wait ()
359358
360359 if arPE != 0 :
361360 errorMsg = 'Failed to execute archiver with command {0}' .format (arCmd )
362361 _logger .error (errorMsg )
363- return
362+ return 1
364363
365364 # Extract bitcode locations from object
366365 contents = pArgs .extractor (filename )
367- _logger .debug ('From instance {0} of {1} in {2} we extracted\n \t {3} \n ' . format ( i , filename , inputFile , contents ) )
366+ _logger .debug ('From instance %s of %s in %s we extracted\n \t %s \n ' , i , filename , inputFile , contents )
368367 if contents :
369368 for path in contents :
370369 if path :
371370 bitCodeFiles .append (path )
372371 else :
373- _logger .debug ('From instance {0} of {1} in {2} we extracted NOTHING\n ' . format ( i , filename , inputFile ) )
372+ _logger .debug ('From instance %s of %s in %s we extracted NOTHING\n ' , i , filename , inputFile )
374373
375374 finally :
376375 # Delete the temporary folder
377376 _logger .debug ('Deleting temporary folder "%s"' , tempDir )
378377 shutil .rmtree (tempDir )
379378
380- _logger .debug ('From instance {0} we extracted\n \t {1} \n ' . format ( inputFile , bitCodeFiles ) )
379+ _logger .debug ('From instance %s we extracted\n \t %s \n ' , inputFile , bitCodeFiles )
381380
382381 # Build bitcode archive
383382 os .chdir (originalDir )
@@ -599,7 +598,7 @@ def extract_bc_args():
599598
600599
601600def process_file_unix (pArgs ):
602-
601+ retval = 1
603602 ft = FileType .getFileType (pArgs .inputFile )
604603 _logger .debug ('Detected file type is %s' , FileType .revMap [ft ])
605604
@@ -609,19 +608,19 @@ def process_file_unix(pArgs):
609608
610609 if ft == FileType .ELF_EXECUTABLE or ft == FileType .ELF_SHARED or ft == FileType .ELF_OBJECT :
611610 _logger .info ('Generating LLVM Bitcode module' )
612- return handleExecutable (pArgs )
611+ retval = handleExecutable (pArgs )
613612 elif ft == FileType .ARCHIVE :
614- return handleArchive (pArgs )
613+ retval = handleArchive (pArgs )
615614 elif ft == FileType .THIN_ARCHIVE :
616- return handleThinArchive (pArgs )
615+ retval = handleThinArchive (pArgs )
617616 else :
618617 _logger .error ('File "%s" of type %s cannot be used' , pArgs .inputFile , FileType .revMap [ft ])
619- return 1
618+ return retval
620619
621620
622621
623622def process_file_darwin (pArgs ):
624-
623+ retval = 1
625624 ft = FileType .getFileType (pArgs .inputFile )
626625 _logger .debug ('Detected file type is %s' , FileType .revMap [ft ])
627626
@@ -631,9 +630,9 @@ def process_file_darwin(pArgs):
631630
632631 if ft == FileType .MACH_EXECUTABLE or ft == FileType .MACH_SHARED or ft == FileType .MACH_OBJECT :
633632 _logger .info ('Generating LLVM Bitcode module' )
634- return handleExecutable (pArgs )
633+ retval = handleExecutable (pArgs )
635634 elif ft == FileType .ARCHIVE :
636- return handleArchive (pArgs )
635+ retval = handleArchive (pArgs )
637636 else :
638637 _logger .error ('File "%s" of type %s cannot be used' , pArgs .inputFile , FileType .revMap [ft ])
639- return 1
638+ return retval
0 commit comments