Class: Bake::Blocks::Lint

Inherits:
Compile show all
Defined in:
lib/blocks/lint.rb

Instance Attribute Summary

Attributes inherited from Compile

#include_list, #objects

Attributes inherited from BlockBase

#tcs

Instance Method Summary collapse

Methods inherited from Compile

#calcCmdlineFile, #calcDefines, #calcDepFile, #calcDepFileConv, #calcFileTcs, #calcFlags, #calcIncludes, #calcObjects, #calcSources, #compileFile, #getDefines, #getFlags, #get_object_file, #get_source_type, #maybe_needed?, #mutex, #needed?, read_depfile, #tcs4source, write_depfile

Methods inherited from BlockBase

#calcOutputDir, #check_config_file, #config_changed?, #defaultToolchainTime, isCmdLineEqual?, prepareOutput, #printCmd, #process_console_output, #process_result, writeCmdLineFile

Constructor Details

#initialize(block, config, referencedConfigs, tcs) ⇒ Lint

Returns a new instance of Lint.



7
8
9
# File 'lib/blocks/lint.rb', line 7

def initialize(block, config, referencedConfigs, tcs)
  super(block,config, referencedConfigs, tcs)
end

Instance Method Details

#cleanObject



50
51
52
# File 'lib/blocks/lint.rb', line 50

def clean
  return true
end

#executeObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/blocks/lint.rb', line 11

def execute
  success = true
  Dir.chdir(@projectDir) do
    compiler = @tcs[:COMPILER][:CPP]
    calcSources
    
    noFilesToLint = (@source_files.length == 0)
    
    if Bake.options.lint_min >= 1 and Bake.options.lint_min >= @source_files.length
      noFilesToLint = true 
    end
    
    if Bake.options.lint_max >= 0 and Bake.options.lint_max < Bake.options.lint_min
      noFilesToLint = true 
    end
              
    if noFilesToLint
      Bake.formatter.printInfo("No files to lint", @config)
    else
      @source_files = @source_files[Bake.options.lint_min..Bake.options.lint_max]    
      
      cmd = [compiler[:COMMAND]]
      cmd += compiler[:COMPILE_FLAGS]
        
      cmd += @include_array[:CPP]
      cmd += @define_array[:CPP]
        
      cmd += @tcs[:LINT_POLICY]
      
      cmd += @source_files
             
      printCmd(cmd, "Linting #{@source_files.length} file(s)...", nil, false)
      success, consoleOutput = ProcessHelper.run(cmd, false)
      process_result(cmd, consoleOutput, compiler[:ERROR_PARSER], "Linting...", nil, success)
    end
  end
  return success
end