@@ -235,7 +235,8 @@ class CacheableSourceFileProcessor(SourceFileProcessor):
235235 the files requiring intervention after processing the source files.
236236 """
237237
238- def __init__ (self , cache_file_path , file_type ):
238+ def __init__ (self , use_cache , cache_file_path , file_type ):
239+ self .use_cache = use_cache
239240 self .cache_file_path = cache_file_path
240241 self .file_type = file_type
241242
@@ -260,9 +261,10 @@ def GetProcessorCommand(self):
260261 return command
261262
262263 def ProcessFiles (self , files ):
263- cache = FileContentsCache (self .cache_file_path )
264- cache .Load ()
265- files = cache .FilterUnchangedFiles (files )
264+ if self .use_cache :
265+ cache = FileContentsCache (self .cache_file_path )
266+ cache .Load ()
267+ files = cache .FilterUnchangedFiles (files )
266268
267269 if len (files ) == 0 :
268270 print 'No changes in %s files detected. Skipping check' % self .file_type
@@ -272,10 +274,12 @@ def ProcessFiles(self, files):
272274 print (
273275 'Total %s files found that require formatting: %d' %
274276 (self .file_type , len (files_requiring_changes )))
275- for file in files_requiring_changes :
276- cache .RemoveFile (file )
277+ if self .use_cache :
278+ for file in files_requiring_changes :
279+ cache .RemoveFile (file )
280+
281+ cache .Save ()
277282
278- cache .Save ()
279283 return files_requiring_changes == []
280284
281285 def DetectFilesToChange (self , files ):
@@ -306,9 +310,9 @@ class CppLintProcessor(CacheableSourceFileProcessor):
306310 Lint files to check that they follow the google code style.
307311 """
308312
309- def __init__ (self ):
313+ def __init__ (self , use_cache = True ):
310314 super (CppLintProcessor , self ).__init__ (
311- cache_file_path = '.cpplint-cache' , file_type = 'C/C++' )
315+ use_cache = use_cache , cache_file_path = '.cpplint-cache' , file_type = 'C/C++' )
312316
313317 def IsRelevant (self , name ):
314318 return name .endswith ('.cc' ) or name .endswith ('.h' )
@@ -348,9 +352,9 @@ class TorqueFormatProcessor(CacheableSourceFileProcessor):
348352 Check .tq files to verify they follow the Torque style guide.
349353 """
350354
351- def __init__ (self ):
355+ def __init__ (self , use_cache = True ):
352356 super (TorqueFormatProcessor , self ).__init__ (
353- cache_file_path = '.torquelint-cache' , file_type = 'Torque' )
357+ use_cache = use_cache , cache_file_path = '.torquelint-cache' , file_type = 'Torque' )
354358
355359 def IsRelevant (self , name ):
356360 return name .endswith ('.tq' )
@@ -660,6 +664,9 @@ def GetOptions():
660664 result = optparse .OptionParser ()
661665 result .add_option ('--no-lint' , help = "Do not run cpplint" , default = False ,
662666 action = "store_true" )
667+ result .add_option ('--no-linter-cache' , help = "Do not cache linter results" , default = False ,
668+ action = "store_true" )
669+
663670 return result
664671
665672
@@ -670,11 +677,13 @@ def Main():
670677 success = True
671678 print "Running checkdeps..."
672679 success &= CheckDeps (workspace )
680+ use_linter_cache = not options .no_linter_cache
673681 if not options .no_lint :
674682 print "Running C++ lint check..."
675- success &= CppLintProcessor ().RunOnPath (workspace )
683+ success &= CppLintProcessor (use_cache = use_linter_cache ).RunOnPath (workspace )
684+
676685 print "Running Torque formatting check..."
677- success &= TorqueFormatProcessor ().RunOnPath (workspace )
686+ success &= TorqueFormatProcessor (use_cache = use_linter_cache ).RunOnPath (workspace )
678687 print "Running copyright header, trailing whitespaces and " \
679688 "two empty lines between declarations check..."
680689 success &= SourceProcessor ().RunOnPath (workspace )
0 commit comments