@@ -317,6 +317,26 @@ def fetchTOC(inputFile):
317
317
return toc
318
318
319
319
320
+ def extractFile (archive , filename , instance ):
321
+ arCmd = ['ar' , 'xN' , str (instance ), archive , filename ] #iam: check if this might be os dependent
322
+ try :
323
+ arP = Popen (arCmd )
324
+ except Exception as e :
325
+ _logger .error (e )
326
+ return False
327
+
328
+ arPE = arP .wait ()
329
+
330
+ if arPE != 0 :
331
+ errorMsg = 'Failed to execute archiver with command {0}' .format (arCmd )
332
+ _logger .error (errorMsg )
333
+ return False
334
+
335
+ return True
336
+
337
+
338
+
339
+
320
340
#iam: 5/1/2018
321
341
def handleArchive (pArgs ):
322
342
""" handleArchive processes a archive, and creates either a bitcode archive, or a module, depending on the flags used.
@@ -353,29 +373,18 @@ def handleArchive(pArgs):
353
373
for filename in toc :
354
374
count = toc [filename ]
355
375
for i in range (1 , count + 1 ):
356
- arCmd = ['ar' , 'xN' , str (i ), inputFile , filename ] #iam: check if this might be os dependent
357
- try :
358
- arP = Popen (arCmd )
359
- except Exception as e :
360
- _logger .error (e )
361
- return 1
362
-
363
- arPE = arP .wait ()
364
-
365
- if arPE != 0 :
366
- errorMsg = 'Failed to execute archiver with command {0}' .format (arCmd )
367
- _logger .error (errorMsg )
368
- return 1
369
-
370
- # Extract bitcode locations from object
371
- contents = pArgs .extractor (filename )
372
- _logger .debug ('From instance %s of %s in %s we extracted\n \t %s\n ' , i , filename , inputFile , contents )
373
- if contents :
374
- for path in contents :
375
- if path :
376
- bitCodeFiles .append (path )
377
- else :
378
- _logger .debug ('From instance %s of %s in %s we extracted NOTHING\n ' , i , filename , inputFile )
376
+
377
+ # extact out the ith instance of filename
378
+ if extractFile (inputFile , filename , i ):
379
+ # Extract bitcode locations from object
380
+ contents = pArgs .extractor (filename )
381
+ _logger .debug ('From instance %s of %s in %s we extracted\n \t %s\n ' , i , filename , inputFile , contents )
382
+ if contents :
383
+ for path in contents :
384
+ if path :
385
+ bitCodeFiles .append (path )
386
+ else :
387
+ _logger .debug ('From instance %s of %s in %s we extracted NOTHING\n ' , i , filename , inputFile )
379
388
380
389
finally :
381
390
# Delete the temporary folder
0 commit comments