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