@@ -242,7 +242,7 @@ def extract_from_thin_archive(inputFile):
242
242
"""
243
243
retval = None
244
244
245
- arCmd = ['ar' , '-t' , inputFile ] #might be os dependent
245
+ arCmd = ['ar' , '-t' , inputFile ] #iam: check if this might be os dependent
246
246
arProc = Popen (arCmd , stdout = sp .PIPE )
247
247
248
248
arOutput = arProc .communicate ()[0 ]
@@ -263,7 +263,7 @@ def handleExecutable(pArgs):
263
263
return 1
264
264
265
265
if pArgs .manifestFlag :
266
- writeManifest ('{0}.llvm.manifest' .format (pArgs .inputFile ), fileNames )
266
+ writeManifest (pArgs , '{0}.llvm.manifest' .format (pArgs .inputFile ), fileNames )
267
267
268
268
if pArgs .outputFile is None :
269
269
pArgs .outputFile = pArgs .inputFile + '.' + moduleExtension
@@ -273,11 +273,6 @@ def handleExecutable(pArgs):
273
273
274
274
def handleThinArchive (pArgs ):
275
275
276
- if pArgs .bitcodeModuleFlag :
277
- _logger .info ('Generating LLVM Bitcode module from an archive' )
278
- else :
279
- _logger .info ('Generating LLVM Bitcode archive from an archive' )
280
-
281
276
objectPaths = extract_from_thin_archive (pArgs .inputFile )
282
277
283
278
if not objectPaths :
@@ -297,11 +292,6 @@ def handleThinArchive(pArgs):
297
292
298
293
def handleArchive (pArgs ):
299
294
300
- if pArgs .bitcodeModuleFlag :
301
- _logger .info ('Generating LLVM Bitcode module from an archive' )
302
- else :
303
- _logger .info ('Generating LLVM Bitcode archive from an archive' )
304
-
305
295
originalDir = os .getcwd () # This will be the destination
306
296
307
297
pArgs .arCmd .append (pArgs .inputFile )
@@ -366,9 +356,14 @@ def handleArchive(pArgs):
366
356
367
357
def buildArchive (pArgs , bitCodeFiles ):
368
358
359
+ if pArgs .bitcodeModuleFlag :
360
+ _logger .info ('Generating LLVM Bitcode module from an archive' )
361
+ else :
362
+ _logger .info ('Generating LLVM Bitcode archive from an archive' )
363
+
369
364
#write the manifest file if asked for
370
365
if pArgs .manifestFlag :
371
- writeManifest ('{0}.llvm.manifest' .format (pArgs .inputFile ), bitCodeFiles )
366
+ writeManifest (pArgs , '{0}.llvm.manifest' .format (pArgs .inputFile ), bitCodeFiles )
372
367
373
368
if pArgs .bitcodeModuleFlag :
374
369
@@ -398,13 +393,16 @@ def buildArchive(pArgs, bitCodeFiles):
398
393
return archiveFiles (pArgs , bitCodeFiles )
399
394
400
395
401
- def writeManifest (manifestFile , bitCodeFiles ):
396
+ def writeManifest (pArgs , manifestFile , bitCodeFiles ):
397
+ if pArgs .sortManifestFlag :
398
+ bitCodeFiles = sorted (bitCodeFiles )
402
399
with open (manifestFile , 'w' ) as output :
403
- for f in sorted ( bitCodeFiles ) :
400
+ for f in bitCodeFiles :
404
401
output .write ('{0}\n ' .format (f ))
405
402
sf = getStorePath (f )
406
403
if sf :
407
404
output .write ('{0}\n ' .format (sf ))
405
+ _logger .warning ('Manifest written to %s' , manifestFile )
408
406
409
407
410
408
@@ -457,6 +455,10 @@ def extract_bc_args():
457
455
dest = 'manifestFlag' ,
458
456
help = 'Write a manifest file listing all the .bc files used.' ,
459
457
action = 'store_true' )
458
+ parser .add_argument ('--sortmanifest' , '-s' ,
459
+ dest = 'sortManifestFlag' ,
460
+ help = 'Sort the manifest file (if written).' ,
461
+ action = 'store_true' )
460
462
parser .add_argument ('--bitcode' , '-b' ,
461
463
dest = 'bitcodeModuleFlag' ,
462
464
help = 'Extract a bitcode module rather than an archive. ' +
0 commit comments