1
- import logging , collections , os , re , sys
1
+ import logging
2
+ import collections
3
+ import os
4
+ import re
5
+ import sys
2
6
3
7
# Internal logger
4
8
_logger = logging .getLogger (__name__ )
@@ -123,8 +127,8 @@ def __init__(self, inputList, exactMatches={}, patternMatches={}):
123
127
# Debug
124
128
'-g' : (0 , ArgumentListFilter .compileUnaryCallback ),
125
129
'-g0' : (0 , ArgumentListFilter .compileUnaryCallback ), #iam: clang not gcc
126
- '-ggdb' : (0 , ArgumentListFilter .compileUnaryCallback ),
127
- '-ggdb3' : (0 , ArgumentListFilter .compileUnaryCallback ),
130
+ '-ggdb' : (0 , ArgumentListFilter .compileUnaryCallback ),
131
+ '-ggdb3' : (0 , ArgumentListFilter .compileUnaryCallback ),
128
132
'-gdwarf-2' : (0 , ArgumentListFilter .compileUnaryCallback ),
129
133
'-gdwarf-3' : (0 , ArgumentListFilter .compileUnaryCallback ),
130
134
'-gline-tables-only' : (0 , ArgumentListFilter .compileUnaryCallback ),
@@ -185,7 +189,7 @@ def __init__(self, inputList, exactMatches={}, patternMatches={}):
185
189
# (the Darwin ld is a bit single minded)
186
190
#
187
191
# 1) compilation with -fvisibility=hidden causes trouble when we try to
188
- # attach bitcode filenames to an object file. The global symbols in object
192
+ # attach bitcode filenames to an object file. The global symbols in object
189
193
# files get turned into local symbols when we invoke 'ld -r'
190
194
#
191
195
# 2) all stripping commands (e.g., -dead_strip) remove the __LLVM segment after
@@ -195,8 +199,8 @@ def __init__(self, inputList, exactMatches={}, patternMatches={}):
195
199
# calling ld -r.
196
200
#
197
201
'-Wl,-dead_strip' : (0 , ArgumentListFilter .darwinWarningLinkUnaryCallback ),
198
-
199
- }
202
+
203
+ }
200
204
201
205
#
202
206
# Patterns for other command-line arguments:
@@ -227,15 +231,15 @@ def __init__(self, inputList, exactMatches={}, patternMatches={}):
227
231
r'^--sysroot=.+$' : (0 , ArgumentListFilter .compileUnaryCallback ),
228
232
r'^-print-prog-name=.*$' : (0 , ArgumentListFilter .compileUnaryCallback ),
229
233
r'^-print-file-name=.*$' : (0 , ArgumentListFilter .compileUnaryCallback ),
230
-
234
+
231
235
}
232
236
233
237
#iam: try and keep track of the files, input object, and output
234
238
self .inputList = inputList
235
239
self .inputFiles = []
236
240
self .objectFiles = []
237
241
self .outputFilename = None
238
-
242
+
239
243
#iam: try and split the args into linker and compiler switches
240
244
self .compileArgs = []
241
245
self .linkArgs = []
@@ -256,10 +260,10 @@ def __init__(self, inputList, exactMatches={}, patternMatches={}):
256
260
self ._inputArgs = collections .deque (inputList )
257
261
258
262
#iam: parse the cmd line, bailing if we discover that there will be no second phase.
259
- while ( len (self ._inputArgs ) > 0 and
260
- not (self .isAssembly or
261
- self .isAssembleOnly or
262
- self .isPreprocessOnly ) ):
263
+ while (len (self ._inputArgs ) > 0 and
264
+ not (self .isAssembly or
265
+ self .isAssembleOnly or
266
+ self .isPreprocessOnly ) ):
263
267
# Get the next argument
264
268
currentItem = self ._inputArgs .popleft ()
265
269
_logger .debug ('Trying to match item ' + currentItem )
@@ -281,7 +285,7 @@ def __init__(self, inputList, exactMatches={}, patternMatches={}):
281
285
# If no action has been specified, this is a zero-argument
282
286
# flag that we should just keep.
283
287
if not matched :
284
- _logger .warning ('Did not recognize the compiler flag "{0}"' . format ( currentItem ) )
288
+ _logger .warning ('Did not recognize the compiler flag "%s"' , currentItem )
285
289
self .compileUnaryCallback (currentItem )
286
290
287
291
if DUMPING :
@@ -296,11 +300,11 @@ def _shiftArgs(self, nargs):
296
300
return ret
297
301
298
302
def abortUnaryCallback (self , flag ):
299
- _logger .warning ('Out of context experience: "{0}"' . format ( str (self .inputList ) ))
303
+ _logger .warning ('Out of context experience: "%s"' , str (self .inputList ))
300
304
sys .exit (1 )
301
305
302
306
def inputFileCallback (self , infile ):
303
- _logger .debug ('Input file: ' + infile )
307
+ _logger .debug ('Input file: %s' , infile )
304
308
self .inputFiles .append (infile )
305
309
if re .search ('\\ .(s|S)$' , infile ):
306
310
self .isAssembly = True
@@ -335,13 +339,13 @@ def compileUnaryCallback(self, flag):
335
339
336
340
def darwinWarningLinkUnaryCallback (self , flag ):
337
341
if sys .platform .startswith ('darwin' ):
338
- _logger .warning ('The flag "{0} " cannot be used with this tool' . format ( flag ) )
342
+ _logger .warning ('The flag "%s " cannot be used with this tool' , flag )
339
343
sys .exit (1 )
340
344
else :
341
345
self .linkArgs .append (flag )
342
346
343
347
def defaultBinaryCallback (self , flag , arg ):
344
- _logger .warning ('Ignoring compiler arg pair: "{0} {1}"' . format ( flag , arg ) )
348
+ _logger .warning ('Ignoring compiler arg pair: "%s %s"' , flag , arg )
345
349
346
350
def dependencyBinaryCallback (self , flag , arg ):
347
351
self .isDependencyOnly = True
@@ -392,15 +396,11 @@ def getArtifactNames(self, srcFile, hidden=False):
392
396
393
397
#iam: for printing our partitioning of the args
394
398
def dump (self ):
395
- _logger .debug ('compileArgs: {0}' .format (self .compileArgs ))
396
- _logger .debug ('inputFiles: {0}' .format (self .inputFiles ))
397
- _logger .debug ('linkArgs: {0}' .format (self .linkArgs ))
398
- _logger .debug ('objectFiles: {0}' .format (self .objectFiles ))
399
- _logger .debug ('outputFilename: {0}' .format (self .outputFilename ))
399
+ _logger .debug ('compileArgs: %s\n inputFiles: %s\n linkArgs: %s' ,
400
+ self .compileArgs , self .inputFiles , self .linkArgs )
401
+ _logger .debug ('objectFiles: %s\n outputFilename: %s' ,
402
+ self .objectFiles , self .outputFilename )
400
403
for srcFile in self .inputFiles :
401
- _logger .debug ('srcFile: {0}' . format ( srcFile ) )
404
+ _logger .debug ('srcFile: %s' , srcFile )
402
405
(objFile , bcFile ) = self .getArtifactNames (srcFile )
403
- _logger .debug ('{0} ===> ({1}, {2})' .format (srcFile , objFile , bcFile ))
404
-
405
-
406
-
406
+ _logger .debug ('%s ===> (%s, %s)' , srcFile , objFile , bcFile )
0 commit comments