Skip to content

Commit 5c2094c

Browse files
committed
Added a -s switch to sort the manifest. Default is unsorted.
1 parent c7b16b9 commit 5c2094c

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

wllvm/extraction.py

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ def extract_from_thin_archive(inputFile):
242242
"""
243243
retval = None
244244

245-
arCmd = ['ar', '-t', inputFile] #might be os dependent
245+
arCmd = ['ar', '-t', inputFile] #iam: check if this might be os dependent
246246
arProc = Popen(arCmd, stdout=sp.PIPE)
247247

248248
arOutput = arProc.communicate()[0]
@@ -263,7 +263,7 @@ def handleExecutable(pArgs):
263263
return 1
264264

265265
if pArgs.manifestFlag:
266-
writeManifest('{0}.llvm.manifest'.format(pArgs.inputFile), fileNames)
266+
writeManifest(pArgs, '{0}.llvm.manifest'.format(pArgs.inputFile), fileNames)
267267

268268
if pArgs.outputFile is None:
269269
pArgs.outputFile = pArgs.inputFile + '.' + moduleExtension
@@ -273,11 +273,6 @@ def handleExecutable(pArgs):
273273

274274
def handleThinArchive(pArgs):
275275

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-
281276
objectPaths = extract_from_thin_archive(pArgs.inputFile)
282277

283278
if not objectPaths:
@@ -297,11 +292,6 @@ def handleThinArchive(pArgs):
297292

298293
def handleArchive(pArgs):
299294

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-
305295
originalDir = os.getcwd() # This will be the destination
306296

307297
pArgs.arCmd.append(pArgs.inputFile)
@@ -366,9 +356,14 @@ def handleArchive(pArgs):
366356

367357
def buildArchive(pArgs, bitCodeFiles):
368358

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+
369364
#write the manifest file if asked for
370365
if pArgs.manifestFlag:
371-
writeManifest('{0}.llvm.manifest'.format(pArgs.inputFile), bitCodeFiles)
366+
writeManifest(pArgs, '{0}.llvm.manifest'.format(pArgs.inputFile), bitCodeFiles)
372367

373368
if pArgs.bitcodeModuleFlag:
374369

@@ -398,13 +393,16 @@ def buildArchive(pArgs, bitCodeFiles):
398393
return archiveFiles(pArgs, bitCodeFiles)
399394

400395

401-
def writeManifest(manifestFile, bitCodeFiles):
396+
def writeManifest(pArgs, manifestFile, bitCodeFiles):
397+
if pArgs.sortManifestFlag:
398+
bitCodeFiles = sorted(bitCodeFiles)
402399
with open(manifestFile, 'w') as output:
403-
for f in sorted(bitCodeFiles):
400+
for f in bitCodeFiles:
404401
output.write('{0}\n'.format(f))
405402
sf = getStorePath(f)
406403
if sf:
407404
output.write('{0}\n'.format(sf))
405+
_logger.warning('Manifest written to %s', manifestFile)
408406

409407

410408

@@ -457,6 +455,10 @@ def extract_bc_args():
457455
dest='manifestFlag',
458456
help='Write a manifest file listing all the .bc files used.',
459457
action='store_true')
458+
parser.add_argument('--sortmanifest', '-s',
459+
dest='sortManifestFlag',
460+
help='Sort the manifest file (if written).',
461+
action='store_true')
460462
parser.add_argument('--bitcode', '-b',
461463
dest='bitcodeModuleFlag',
462464
help='Extract a bitcode module rather than an archive. ' +

0 commit comments

Comments
 (0)