cxxproject 0.5.71 → 0.5.72
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/cxxproject/buildingblocks/building_block.rb +2 -2
- data/lib/cxxproject/buildingblocks/has_sources_mixin.rb +6 -1
- data/lib/cxxproject/buildingblocks/lint.rb +101 -0
- data/lib/cxxproject/errorparser/gcc_lint_error_parser.rb +34 -0
- data/lib/cxxproject/ext/rake.rb +8 -1
- data/lib/cxxproject/toolchain/gcc_lint.rb +73 -0
- data/lib/cxxproject/toolchain/gcc_param.rb +7 -0
- data/lib/cxxproject/toolchain/provider.rb +5 -2
- data/lib/cxxproject/version.rb +1 -1
- metadata +6 -2
@@ -182,7 +182,7 @@ module Cxxproject
|
|
182
182
|
def process_result(cmd, console_output, error_parser, alternate, success)
|
183
183
|
hasError = (success == false)
|
184
184
|
if (cmd != @lastCommand) or (@printedCmdAlternate and hasError)
|
185
|
-
printCmd(cmd, alternate, hasError)
|
185
|
+
printCmd(cmd, alternate, hasError && Rake::application.options.lint == false)
|
186
186
|
end
|
187
187
|
errorPrinted = process_console_output(console_output, error_parser)
|
188
188
|
|
@@ -192,7 +192,7 @@ module Cxxproject
|
|
192
192
|
res = ErrorDesc.new
|
193
193
|
res.file_name = @project_dir
|
194
194
|
res.line_number = 0
|
195
|
-
res.message = "Unknown error, see log output. Maybe the
|
195
|
+
res.message = "Unknown error, see log output. Maybe the bake error parser has to be updated..."
|
196
196
|
res.severity = ErrorParser::SEVERITY_ERROR
|
197
197
|
Rake.application.idei.set_errors([res])
|
198
198
|
end
|
@@ -345,7 +345,11 @@ module Cxxproject
|
|
345
345
|
console_output = console_output_VS
|
346
346
|
end
|
347
347
|
|
348
|
-
|
348
|
+
if Cxxproject::GCCLintErrorParser === error_parser # hack: need to know if lint is enabled...
|
349
|
+
ret = error_descs.any? { |e| e.severity != ErrorParser::SEVERITY_OK }
|
350
|
+
else
|
351
|
+
ret = error_descs.any? { |e| e.severity == ErrorParser::SEVERITY_ERROR }
|
352
|
+
end
|
349
353
|
|
350
354
|
console_output.gsub!(/[\r]/, "")
|
351
355
|
highlighter = @tcs[:CONSOLE_HIGHLIGHTER]
|
@@ -358,6 +362,7 @@ module Cxxproject
|
|
358
362
|
Rake.application.idei.set_errors(error_descs)
|
359
363
|
rescue Exception => e
|
360
364
|
Printer.printWarning "Parsing output failed (maybe language not set to English?): " + e.message
|
365
|
+
puts e.backtrace
|
361
366
|
puts "Original output:"
|
362
367
|
puts console_output
|
363
368
|
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
require 'cxxproject/buildingblocks/source_library'
|
2
|
+
|
3
|
+
module Cxxproject
|
4
|
+
class Lint < SourceLibrary
|
5
|
+
|
6
|
+
def initialize(name)
|
7
|
+
super(name)
|
8
|
+
@lint_max = -1
|
9
|
+
@lint_min = -1
|
10
|
+
end
|
11
|
+
|
12
|
+
def set_lint_min(x)
|
13
|
+
@lint_min = x
|
14
|
+
self
|
15
|
+
end
|
16
|
+
|
17
|
+
def set_lint_max(x)
|
18
|
+
@lint_max = x
|
19
|
+
self
|
20
|
+
end
|
21
|
+
|
22
|
+
def get_task_name()
|
23
|
+
return @task_name if @task_name
|
24
|
+
|
25
|
+
parts = [@output_dir]
|
26
|
+
parts << 'lint' if @output_dir_abs
|
27
|
+
parts << "#{@name}_lint"
|
28
|
+
@task_name = File.join(parts)
|
29
|
+
@task_name = @project_dir + "/" + @task_name unless @output_dir_abs
|
30
|
+
@task_name
|
31
|
+
end
|
32
|
+
|
33
|
+
def convert_to_rake()
|
34
|
+
compiler = @tcs[:COMPILER][:CPP]
|
35
|
+
lintParam = @tcs[:LINT_PARAM]
|
36
|
+
lintParam.init_vars
|
37
|
+
|
38
|
+
res = typed_file_task Rake::Task::LINT, get_task_name do
|
39
|
+
dir = @project_dir
|
40
|
+
|
41
|
+
Dir.chdir(dir) do
|
42
|
+
srcs = calc_sources_to_build.keys
|
43
|
+
|
44
|
+
if @lint_min >= 0 and @lint_min >= srcs.length
|
45
|
+
Printer.printError "Error: lint_min is set to #{@lint_min}, but only #{srcs.length} file(s) are specified to lint"
|
46
|
+
ExitHelper.exit(1)
|
47
|
+
end
|
48
|
+
|
49
|
+
if @lint_max >= 0 and @lint_max >= srcs.length
|
50
|
+
Printer.printError "Error: lint_max is set to #{@lint_max}, but only #{srcs.length} file(s) are specified to lint"
|
51
|
+
ExitHelper.exit(1)
|
52
|
+
end
|
53
|
+
|
54
|
+
@lint_min = 0 if @lint_min < 0
|
55
|
+
@lint_max = -1 if @lint_max < 0
|
56
|
+
srcs = srcs[@lint_min..@lint_max]
|
57
|
+
|
58
|
+
cmd = [compiler[:COMMAND]]
|
59
|
+
cmd += compiler[:COMPILE_FLAGS]
|
60
|
+
|
61
|
+
cmd += lintParam.internalIncludes
|
62
|
+
cmd += lintParam.internalDefines
|
63
|
+
|
64
|
+
cmd += @include_string[:CPP]
|
65
|
+
cmd += @define_string[:CPP]
|
66
|
+
|
67
|
+
cmd += @tcs[:LINT_POLICY]
|
68
|
+
|
69
|
+
cmd += srcs
|
70
|
+
|
71
|
+
if Cxxproject::Utils.old_ruby?
|
72
|
+
cmd.map! {|c| ((c.include?" ") ? ("\""+c+"\"") : c )}
|
73
|
+
|
74
|
+
cmdLine = cmd.join(" ")
|
75
|
+
if cmdLine.length > 8000
|
76
|
+
inputName = aname+".tmp"
|
77
|
+
File.open(inputName,"wb") { |f| f.write(cmd[1..-1].join(" ")) }
|
78
|
+
success, consoleOutput = ProcessHelper.safeExecute() { `#{compiler[:COMMAND] + " @" + inputName}` }
|
79
|
+
else
|
80
|
+
success, consoleOutput = ProcessHelper.safeExecute() { `#{cmd.join(" ")} 2>&1` }
|
81
|
+
end
|
82
|
+
else
|
83
|
+
rd, wr = IO.pipe
|
84
|
+
cmd << {:err=>wr,:out=>wr}
|
85
|
+
success, consoleOutput = ProcessHelper.safeExecute() { sp = spawn(*cmd); ProcessHelper.readOutput(sp, rd, wr) }
|
86
|
+
cmd.pop
|
87
|
+
end
|
88
|
+
|
89
|
+
process_result(cmd, consoleOutput, compiler[:ERROR_PARSER], "Linting #{name}", success)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def res.needed?
|
94
|
+
true
|
95
|
+
end
|
96
|
+
|
97
|
+
return res
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
101
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'cxxproject/errorparser/error_parser'
|
2
|
+
|
3
|
+
module Cxxproject
|
4
|
+
class GCCLintErrorParser < ErrorParser
|
5
|
+
|
6
|
+
def initialize()
|
7
|
+
@error_expression = /([^:]*):([0-9]+): ([A-Za-z]+)(.+)/
|
8
|
+
end
|
9
|
+
|
10
|
+
def scan_lines(consoleOutput, proj_dir)
|
11
|
+
res = []
|
12
|
+
consoleOutputFullnames = ""
|
13
|
+
consoleOutput.each_line do |l|
|
14
|
+
d = ErrorDesc.new
|
15
|
+
scan_res = l.gsub(/\r\n?/, "").scan(@error_expression)
|
16
|
+
if scan_res.length > 0
|
17
|
+
if (scan_res[0][0] == "")
|
18
|
+
d.file_name = proj_dir
|
19
|
+
else
|
20
|
+
d.file_name = File.expand_path(scan_res[0][0])
|
21
|
+
end
|
22
|
+
d.line_number = scan_res[0][1].to_i
|
23
|
+
d.severity = get_severity(scan_res[0][2])
|
24
|
+
d.message = scan_res[0][3]
|
25
|
+
l.gsub!(scan_res[0][0],d.file_name)
|
26
|
+
end
|
27
|
+
res << d
|
28
|
+
consoleOutputFullnames << l
|
29
|
+
end
|
30
|
+
[res, consoleOutputFullnames]
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
data/lib/cxxproject/ext/rake.rb
CHANGED
@@ -24,10 +24,15 @@ module Rake
|
|
24
24
|
attr_writer :consoleOutput_fullnames
|
25
25
|
attr_writer :consoleOutput_visualStudio
|
26
26
|
attr_writer :addEmptyLine
|
27
|
+
attr_writer :debug
|
27
28
|
def max_parallel_tasks
|
28
29
|
@max_parallel_tasks ||= 8
|
29
30
|
end
|
30
31
|
|
32
|
+
def debug
|
33
|
+
@debug ||= false
|
34
|
+
end
|
35
|
+
|
31
36
|
def addEmptyLine
|
32
37
|
@addEmptyLine ||= false
|
33
38
|
end
|
@@ -245,6 +250,7 @@ module Rake
|
|
245
250
|
RUN = 0x0800 #
|
246
251
|
CUSTOM = 0x1000 # x
|
247
252
|
COMMANDLINE = 0x2000 # x
|
253
|
+
LINT = 0x4000 #
|
248
254
|
|
249
255
|
STANDARD = 0x371A # x above means included in STANDARD
|
250
256
|
attr_reader :ignore
|
@@ -305,7 +311,7 @@ module Rake
|
|
305
311
|
Cxxproject::Printer.printError "Error #{name}: #{e.message}"
|
306
312
|
if RakeFileUtils.verbose
|
307
313
|
puts e.backtrace
|
308
|
-
end
|
314
|
+
end
|
309
315
|
set_failed
|
310
316
|
if e.message.include?"Circular dependency detected"
|
311
317
|
Rake.application.idei.set_abort(true)
|
@@ -367,6 +373,7 @@ module Rake
|
|
367
373
|
if not Rake.application.idei.get_abort()
|
368
374
|
if not isSysCmd
|
369
375
|
Cxxproject::Printer.printError "Error for task #{@name}: #{ex1.message}"
|
376
|
+
Cxxproject::Printer.printError(ex1.backtrace) if Rake.application.debug
|
370
377
|
end
|
371
378
|
end
|
372
379
|
begin
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'cxxproject/utils/utils'
|
2
|
+
require 'cxxproject/toolchain/provider'
|
3
|
+
require 'cxxproject/errorparser/error_parser'
|
4
|
+
require 'cxxproject/errorparser/gcc_lint_error_parser'
|
5
|
+
|
6
|
+
module Cxxproject
|
7
|
+
module Toolchain
|
8
|
+
|
9
|
+
class GCC_Param
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
@incs = []
|
13
|
+
@defs = []
|
14
|
+
end
|
15
|
+
|
16
|
+
def init_vars
|
17
|
+
@incs = []
|
18
|
+
@defs = []
|
19
|
+
|
20
|
+
begin
|
21
|
+
isCygwin = system("cygpath --version > /dev/null 2>&1")
|
22
|
+
|
23
|
+
incStart = false
|
24
|
+
defRegex = /^#define (\S+) (.*)/
|
25
|
+
|
26
|
+
gccString = `echo "" | g++ -x c++ -E -dM -v - 2>&1`
|
27
|
+
|
28
|
+
gccString.lines.map(&:chomp).each do |line|
|
29
|
+
if line.include?"#include <...> search starts here:"
|
30
|
+
incStart = true
|
31
|
+
elsif line.include?"End of search list."
|
32
|
+
incStart = false
|
33
|
+
elsif incStart
|
34
|
+
inc = line.strip
|
35
|
+
inc = `cygpath -w #{line.strip}`.strip if isCygwin
|
36
|
+
@incs << "--i#{inc}"
|
37
|
+
elsif regRes = line.match(defRegex)
|
38
|
+
@defs << "-D#{regRes[1]}=\"#{regRes[2]}\""
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
rescue Exception=>e
|
43
|
+
Printer.printError "Error: could not determine GCC's internal includes and defines"
|
44
|
+
raise
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
def internalIncludes
|
50
|
+
@incs
|
51
|
+
end
|
52
|
+
|
53
|
+
def internalDefines
|
54
|
+
@defs
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
GCCLintChain = Provider.add("GCC_Lint")
|
59
|
+
|
60
|
+
GCCLintChain[:COMPILER][:CPP].update({
|
61
|
+
:COMMAND => "lint-nt.exe",
|
62
|
+
:DEFINE_FLAG => "-D",
|
63
|
+
:INCLUDE_PATH_FLAG => "-I",
|
64
|
+
:COMPILE_FLAGS => ["-b","-\"format=%f%(:%l:%) %t %n: %m\"", "-width(0)", "-hF1"], # array, not string!
|
65
|
+
})
|
66
|
+
|
67
|
+
GCCLintChain[:COMPILER][:CPP][:ERROR_PARSER] = GCCLintErrorParser.new
|
68
|
+
GCCLintChain[:LINT_PARAM] = GCC_Param.new
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
end
|
73
|
+
end
|
@@ -91,7 +91,9 @@ module Cxxproject
|
|
91
91
|
:CLEAN => "clean"
|
92
92
|
},
|
93
93
|
|
94
|
-
:CONSOLE_HIGHLIGHTER => ColorizingFormatter.new
|
94
|
+
:CONSOLE_HIGHLIGHTER => ColorizingFormatter.new,
|
95
|
+
|
96
|
+
:LINT_POLICY => []
|
95
97
|
}
|
96
98
|
|
97
99
|
def self.add(name, basedOn = nil)
|
@@ -124,7 +126,7 @@ module Cxxproject
|
|
124
126
|
end
|
125
127
|
|
126
128
|
def self.list
|
127
|
-
return @@settings
|
129
|
+
return @@settings.delete_if {|x| x.include?"_Lint" }
|
128
130
|
end
|
129
131
|
|
130
132
|
end
|
@@ -134,6 +136,7 @@ end
|
|
134
136
|
|
135
137
|
require 'cxxproject/toolchain/diab'
|
136
138
|
require 'cxxproject/toolchain/gcc'
|
139
|
+
require 'cxxproject/toolchain/gcc_lint'
|
137
140
|
require 'cxxproject/toolchain/clang'
|
138
141
|
require 'cxxproject/toolchain/ti'
|
139
142
|
require 'cxxproject/toolchain/greenhills'
|
data/lib/cxxproject/version.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: cxxproject
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.5.
|
5
|
+
version: 0.5.72
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- oliver mueller
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2014-03-
|
13
|
+
date: 2014-03-14 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: highline
|
@@ -52,6 +52,7 @@ files:
|
|
52
52
|
- lib/cxxproject/buildingblocks/has_includes_mixin.rb
|
53
53
|
- lib/cxxproject/buildingblocks/has_libraries_mixin.rb
|
54
54
|
- lib/cxxproject/buildingblocks/has_sources_mixin.rb
|
55
|
+
- lib/cxxproject/buildingblocks/lint.rb
|
55
56
|
- lib/cxxproject/buildingblocks/makefile.rb
|
56
57
|
- lib/cxxproject/buildingblocks/module.rb
|
57
58
|
- lib/cxxproject/buildingblocks/single_source.rb
|
@@ -61,6 +62,7 @@ files:
|
|
61
62
|
- lib/cxxproject/errorparser/error_parser.rb
|
62
63
|
- lib/cxxproject/errorparser/gcc_compiler_error_parser.rb
|
63
64
|
- lib/cxxproject/errorparser/gcc_linker_error_parser.rb
|
65
|
+
- lib/cxxproject/errorparser/gcc_lint_error_parser.rb
|
64
66
|
- lib/cxxproject/errorparser/greenhills_compiler_error_parser.rb
|
65
67
|
- lib/cxxproject/errorparser/greenhills_linker_error_parser.rb
|
66
68
|
- lib/cxxproject/errorparser/keil_compiler_error_parser.rb
|
@@ -80,6 +82,8 @@ files:
|
|
80
82
|
- lib/cxxproject/toolchain/colorizing_formatter.rb
|
81
83
|
- lib/cxxproject/toolchain/diab.rb
|
82
84
|
- lib/cxxproject/toolchain/gcc.rb
|
85
|
+
- lib/cxxproject/toolchain/gcc_lint.rb
|
86
|
+
- lib/cxxproject/toolchain/gcc_param.rb
|
83
87
|
- lib/cxxproject/toolchain/greenhills.rb
|
84
88
|
- lib/cxxproject/toolchain/keil.rb
|
85
89
|
- lib/cxxproject/toolchain/provider.rb
|