32
32
# Internal logger
33
33
_logger = logging .getLogger (__name__ )
34
34
35
- # Flag for debugging
36
- DEBUG = False
35
+ # Flag for dumping
36
+ DUMPING = False
37
37
38
38
39
39
# This class applies filters to GCC argument lists. It has a few
@@ -282,7 +282,7 @@ def __init__(self, inputList, exactMatches={}, patternMatches={}):
282
282
_logger .warning ('Did not recognize the compiler flag "{0}"' .format (currentItem ))
283
283
self .compileUnaryCallback (currentItem )
284
284
285
- if DEBUG :
285
+ if DUMPING :
286
286
self .dump ()
287
287
288
288
def _shiftArgs (self , nargs ):
@@ -300,7 +300,7 @@ def abortUnaryCallback(self, flag):
300
300
def inputFileCallback (self , infile ):
301
301
_logger .debug ('Input file: ' + infile )
302
302
self .inputFiles .append (infile )
303
- if re .search ('\\ .(s|S)' , infile ):
303
+ if re .search ('\\ .(s|S)$ ' , infile ):
304
304
self .isAssembly = True
305
305
306
306
def outputFileCallback (self , flag , filename ):
@@ -368,7 +368,7 @@ def getOutputFilename(self):
368
368
369
369
# iam: returns a pair [objectFilename, bitcodeFilename] i.e .o and .bc.
370
370
# the hidden flag determines whether the objectFile is hidden like the
371
- # bitcodeFile is (starts with a '.'), use the DEBUG flag to get a sense
371
+ # bitcodeFile is (starts with a '.'), use the logging level & DUMPING flag to get a sense
372
372
# of what is being written out.
373
373
def getArtifactNames (self , srcFile , hidden = False ):
374
374
(srcpath , srcbase ) = os .path .split (srcFile )
@@ -385,15 +385,15 @@ def getArtifactNames(self, srcFile, hidden=False):
385
385
386
386
#iam: for printing our partitioning of the args
387
387
def dump (self ):
388
- print ( " compileArgs: " , self .compileArgs )
389
- print ( " inputFiles: " , self .inputFiles )
390
- print ( " linkArgs: " , self .linkArgs )
391
- print ( " objectFiles: " , self .objectFiles )
392
- print ( " outputFilename: " , self .outputFilename )
388
+ _logger . debug ( ' compileArgs: {0}' . format ( self .compileArgs ) )
389
+ _logger . debug ( ' inputFiles: {0}' . format ( self .inputFiles ) )
390
+ _logger . debug ( ' linkArgs: {0}' . format ( self .linkArgs ) )
391
+ _logger . debug ( ' objectFiles: {0}' . format ( self .objectFiles ) )
392
+ _logger . debug ( ' outputFilename: {0}' . format ( self .outputFilename ) )
393
393
for srcFile in self .inputFiles :
394
- print ( " srcFile: " , srcFile )
394
+ _logger . debug ( ' srcFile: {0}' . format ( srcFile ) )
395
395
(objFile , bcFile ) = self .getArtifactNames (srcFile )
396
- print ( " {0} ===> ({1}, {2})" .format (srcFile , objFile , bcFile ))
396
+ _logger . debug ( ' {0} ===> ({1}, {2})' .format (srcFile , objFile , bcFile ))
397
397
398
398
399
399
@@ -459,8 +459,7 @@ def attachBitcodePathToObject(bcPath, outFileName):
459
459
# Don't try to attach a bitcode path to a binary. Unfortunately
460
460
# that won't work.
461
461
(root , ext ) = os .path .splitext (outFileName )
462
- if DEBUG :
463
- print ('attachBitcodePathToObject: {0} ===> {1} [ext = {2}]\n ' .format (bcPath , outFileName , ext ))
462
+ _logger .debug ('attachBitcodePathToObject: {0} ===> {1} [ext = {2}]\n ' .format (bcPath , outFileName , ext ))
464
463
#iam: this also looks very dodgey; we need a more reliable way to do this:
465
464
if ext not in ('.o' , '.lo' , '.os' , '.So' , '.po' ):
466
465
_logger .warning ('Cannot attach bitcode path to "{0} of type {1}"' .format (outFileName , FileType .getFileType (outFileName )))
@@ -570,8 +569,7 @@ def getBitcodeCompiler(self):
570
569
# When we build LLVM bitcode we do not want to use the GNU assembler,
571
570
# instead we want gcc to use our own assembler (see driver/as).
572
571
cmd = cc + ['-B' , driverDir , '-fplugin={0}' .format (pth ), '-fplugin-arg-dragonegg-emit-ir' ]
573
- if DEBUG :
574
- print (cmd )
572
+ _logger .debug (cmd )
575
573
return cmd
576
574
577
575
def getCompiler (self ):
@@ -696,8 +694,7 @@ def buildBitcodeFile(builder, srcFile, bcFile):
696
694
bcc .extend (af .compileArgs )
697
695
bcc .extend (['-c' , srcFile ])
698
696
bcc .extend (['-o' , bcFile ])
699
- if DEBUG :
700
- print ('buildBitcodeFile: {0}\n ' .format (bcc ))
697
+ _logger .debug ('buildBitcodeFile: {0}\n ' .format (bcc ))
701
698
proc = Popen (bcc )
702
699
rc = proc .wait ()
703
700
if rc != 0 :
@@ -710,8 +707,7 @@ def buildObjectFile(builder, srcFile, objFile):
710
707
cc .extend (af .compileArgs )
711
708
cc .append (srcFile )
712
709
cc .extend (['-c' , '-o' , objFile ])
713
- if DEBUG :
714
- print ('buildObjectFile: {0}\n ' .format (cc ))
710
+ _logger .debug ('buildObjectFile: {0}\n ' .format (cc ))
715
711
proc = Popen (cc )
716
712
rc = proc .wait ()
717
713
if rc != 0 :
0 commit comments