cxxproject 0.5.67 → 0.5.68

Sign up to get free protection for your applications and to get access to all the features.
@@ -80,9 +80,16 @@ module Cxxproject
80
80
  end
81
81
 
82
82
  def linker_lib_string()
83
- @lib_path_set = Set.new
83
+ @lib_path_set = []
84
84
  @dep_set = Set.new
85
- calc_linker_lib_string_recursive(self)
85
+ res = calc_linker_lib_string_recursive(self)
86
+ return res if (@tcs[:LINKER][:LIST_MODE] == false)
87
+
88
+ res.map { |x| x+"(*.o)"}
89
+ if not (@lib_path_set.empty?)
90
+ res << (@tcs[:LINKER][:LIB_PATH_FLAG] + @lib_path_set.join(","));
91
+ end
92
+ res
86
93
  end
87
94
 
88
95
  def calc_linker_lib_string_recursive(d)
@@ -108,7 +115,7 @@ module Cxxproject
108
115
  tmp, prefix = adaptPath(elem[1], d, prefix)
109
116
  if not @lib_path_set.include?tmp
110
117
  @lib_path_set << tmp
111
- res << "#{linker[:LIB_PATH_FLAG]}#{tmp}"
118
+ res << "#{linker[:LIB_PATH_FLAG]}#{tmp}" if linker[:LIST_MODE] == false
112
119
  end
113
120
  when HasLibraries::DEPENDENCY
114
121
  if ALL_BUILDING_BLOCKS.include?elem[1]
@@ -134,19 +141,19 @@ module Cxxproject
134
141
 
135
142
  cmd = [linker[:COMMAND]] # g++
136
143
  cmd += linker[:MUST_FLAGS].split(" ")
137
- cmd += Cxxproject::Utils::flagSplit(linker[:FLAGS])
144
+ cmd += Cxxproject::Utils::flagSplit(linker[:FLAGS],true)
138
145
  cmd << linker[:EXE_FLAG]
139
146
  cmd << get_executable_name # -o debug/x.exe
140
147
  cmd += @objects
141
148
  cmd << linker[:SCRIPT] if @linker_script # -T
142
149
  cmd << @linker_script if @linker_script # xy/xy.dld
143
- cmd << linker[:MAP_FILE_FLAG] if @mapfile # -Wl,-m6
144
- if not linker[:MAP_FILE_PIPE]
150
+ cmd += linker[:MAP_FILE_FLAG].split(" ") if @mapfile # -Wl,-m6
151
+ if not linker[:MAP_FILE_PIPE] and @mapfile
145
152
  cmd[cmd.length-1] << @mapfile
146
153
  end
147
- cmd += Cxxproject::Utils::flagSplit(linker[:LIB_PREFIX_FLAGS]) # "-Wl,--whole-archive "
154
+ cmd += Cxxproject::Utils::flagSplit(linker[:LIB_PREFIX_FLAGS],true) # "-Wl,--whole-archive "
148
155
  cmd += linker_lib_string
149
- cmd += Cxxproject::Utils::flagSplit(linker[:LIB_POSTFIX_FLAGS]) # "-Wl,--no-whole-archive "
156
+ cmd += Cxxproject::Utils::flagSplit(linker[:LIB_POSTFIX_FLAGS],true) # "-Wl,--no-whole-archive "
150
157
 
151
158
  mapfileStr = (@mapfile and linker[:MAP_FILE_PIPE]) ? " >#{@mapfile}" : ""
152
159
  if Cxxproject::Utils.old_ruby?
@@ -269,12 +269,11 @@ module Cxxproject
269
269
  end
270
270
  end
271
271
  cmd += compiler[:PREPRO_FLAGS].split(" ") if Rake::application.preproFlags
272
- cmd += Cxxproject::Utils::flagSplit(compiler[:FLAGS])
272
+ cmd += Cxxproject::Utils::flagSplit(compiler[:FLAGS],true)
273
273
  cmd += i_array
274
274
  cmd += d_array
275
275
  cmd += (compiler[:OBJECT_FILE_FLAG] + objectRel).split(" ")
276
276
  cmd << sourceRel
277
-
278
277
  if Cxxproject::Utils.old_ruby?
279
278
  cmd.map! {|c| ((c.include?" ") ? ("\""+c+"\"") : c )}
280
279
  cmdLine = cmd.join(" ")
@@ -79,7 +79,7 @@ module Cxxproject
79
79
  end
80
80
 
81
81
  cmd = [archiver[:COMMAND]] # ar
82
- cmd += Cxxproject::Utils::flagSplit(archiver[:FLAGS]) # --all_load
82
+ cmd += Cxxproject::Utils::flagSplit(archiver[:FLAGS],true) # --all_load
83
83
  cmd += archiver[:ARCHIVE_FLAGS].split(" ")
84
84
  cmd << aname
85
85
  cmd += objs
@@ -22,11 +22,11 @@ module Cxxproject
22
22
  end
23
23
 
24
24
  def get_severity(str)
25
- if str == "info" || str == "note"
25
+ if str.downcase == "info" || str.downcase == "note"
26
26
  SEVERITY_INFO
27
- elsif str == "warning"
27
+ elsif str.downcase == "warning"
28
28
  SEVERITY_WARNING
29
- elsif str == "error"
29
+ elsif str.downcase == "error"
30
30
  SEVERITY_ERROR
31
31
  else
32
32
  raise "Unknown severity: #{str}"
@@ -0,0 +1,40 @@
1
+ require 'cxxproject/errorparser/error_parser'
2
+
3
+ module Cxxproject
4
+ class KeilCompilerErrorParser < ErrorParser
5
+
6
+ def initialize()
7
+ @error_expression_start = /\"(.+)\", line ([0-9]+): (?!included)(catastrophic |fatal )*([A-Za-z]+)[:]* (.+)/
8
+ @error_expression_end = /^[ \t]*\^/ # well, it may end without "^"... in this case the error will last the next one starts or console text ends
9
+ end
10
+
11
+ def scan_lines(consoleOutput, proj_dir)
12
+ res = []
13
+ error_severity = 255
14
+ consoleOutputFullnames = ""
15
+ consoleOutput.each_line do |l|
16
+ d = ErrorDesc.new
17
+ lstripped = l.rstrip
18
+ scan_res = lstripped.scan(@error_expression_start)
19
+ if scan_res.length == 0
20
+ d.severity = error_severity
21
+ d.message = lstripped
22
+ if lstripped.scan(@error_expression_end).length > 0
23
+ error_severity = 255
24
+ end
25
+ else
26
+ d.file_name = File.expand_path(scan_res[0][0])
27
+ d.line_number = scan_res[0][1].to_i
28
+ d.message = scan_res[0][4]
29
+ d.severity = get_severity(scan_res[0][3])
30
+ error_severity = d.severity
31
+ l.gsub!(scan_res[0][0],d.file_name)
32
+ end
33
+ res << d
34
+ consoleOutputFullnames << l
35
+ end
36
+ [res, consoleOutputFullnames]
37
+ end
38
+
39
+ end
40
+ end
@@ -0,0 +1,35 @@
1
+ require 'cxxproject/errorparser/error_parser'
2
+
3
+ module Cxxproject
4
+ class KeilLinkerErrorParser < ErrorParser
5
+
6
+ def initialize()
7
+ @error_exclude = /Finished: [0-9]+ information, [0-9]+ warning and [0-9]+ error messages./
8
+ end
9
+
10
+ def scan_lines(consoleOutput, proj_dir)
11
+ res = []
12
+ consoleOutput.each_line do |l|
13
+ l.rstrip!
14
+ scan_res = l.scan(@error_exclude)
15
+ d = ErrorDesc.new
16
+ if scan_res.length == 0
17
+ d.file_name = proj_dir
18
+ d.line_number = 0
19
+ d.message = l
20
+ if l.length == 0
21
+ d.severity = SEVERITY_OK
22
+ elsif l.include?" Warning:"
23
+ d.severity = SEVERITY_WARNING
24
+ else
25
+ d.severity = SEVERITY_ERROR
26
+ end
27
+ end
28
+ res << d
29
+ end
30
+ [res, consoleOutput]
31
+ end
32
+
33
+
34
+ end
35
+ end
@@ -102,11 +102,13 @@ module Cxxproject
102
102
  merged_messages = []
103
103
  last_msg = nil
104
104
  error_array.each do |msg|
105
- if msg.file_name.nil?
106
- last_msg.message += "\r\n#{msg.message}" if last_msg
107
- else
108
- last_msg = msg.dup
109
- merged_messages << last_msg
105
+ if msg.severity != 255
106
+ if msg.file_name.nil?
107
+ last_msg.message += "\r\n#{msg.message}" if last_msg
108
+ else
109
+ last_msg = msg.dup
110
+ merged_messages << last_msg
111
+ end
110
112
  end
111
113
  end
112
114
 
@@ -0,0 +1,52 @@
1
+ require 'cxxproject/utils/utils'
2
+ require 'cxxproject/toolchain/provider'
3
+ require 'cxxproject/errorparser/error_parser'
4
+ require 'cxxproject/errorparser/keil_compiler_error_parser'
5
+ require 'cxxproject/errorparser/keil_linker_error_parser'
6
+
7
+ module Cxxproject
8
+ module Toolchain
9
+
10
+ KeilChain = Provider.add("Keil")
11
+
12
+ KeilChain[:COMPILER][:CPP].update({
13
+ :COMMAND => "armcc",
14
+ :DEFINE_FLAG => "-D",
15
+ :OBJECT_FILE_FLAG => "-o ",
16
+ :INCLUDE_PATH_FLAG => "-I",
17
+ :COMPILE_FLAGS => "-c ",
18
+ :DEP_FLAGS => "--depend=",
19
+ :DEP_FLAGS_SPACE => false,
20
+ :PREPRO_FLAGS => "-E -P"
21
+ })
22
+
23
+ KeilChain[:COMPILER][:C] = Utils.deep_copy(KeilChain[:COMPILER][:CPP])
24
+ KeilChain[:COMPILER][:C][:SOURCE_FILE_ENDINGS] = Provider.default[:COMPILER][:C][:SOURCE_FILE_ENDINGS]
25
+
26
+ KeilChain[:COMPILER][:ASM] = Utils.deep_copy(KeilChain[:COMPILER][:C])
27
+ KeilChain[:COMPILER][:ASM][:SOURCE_FILE_ENDINGS] = Provider.default[:COMPILER][:ASM][:SOURCE_FILE_ENDINGS]
28
+ KeilChain[:COMPILER][:ASM][:COMMAND] = "armasm"
29
+ KeilChain[:COMPILER][:ASM][:COMPILE_FLAGS] = ""
30
+
31
+ KeilChain[:ARCHIVER][:COMMAND] = "armar"
32
+ KeilChain[:ARCHIVER][:ARCHIVE_FLAGS] = "--create"
33
+
34
+ KeilChain[:LINKER][:COMMAND] = "armlink"
35
+ KeilChain[:LINKER][:SCRIPT] = "--scatter"
36
+ KeilChain[:LINKER][:USER_LIB_FLAG] = ""
37
+ KeilChain[:LINKER][:EXE_FLAG] = "-o"
38
+ KeilChain[:LINKER][:LIB_FLAG] = ""
39
+ KeilChain[:LINKER][:LIB_PATH_FLAG] = "--userlibpath="
40
+ KeilChain[:LINKER][:MAP_FILE_FLAG] = "--map --list="
41
+ KeilChain[:LINKER][:MAP_FILE_PIPE] = false
42
+ KeilChain[:LINKER][:LIST_MODE] = true
43
+
44
+ keilCompilerErrorParser = KeilCompilerErrorParser.new
45
+ KeilChain[:COMPILER][:C][:ERROR_PARSER] = keilCompilerErrorParser
46
+ KeilChain[:COMPILER][:CPP][:ERROR_PARSER] = keilCompilerErrorParser
47
+ KeilChain[:COMPILER][:ASM][:ERROR_PARSER] = keilCompilerErrorParser
48
+ KeilChain[:ARCHIVER][:ERROR_PARSER] = keilCompilerErrorParser
49
+ KeilChain[:LINKER][:ERROR_PARSER] = KeilLinkerErrorParser.new
50
+
51
+ end
52
+ end
@@ -78,7 +78,8 @@ module Cxxproject
78
78
  :MAP_FILE_FLAG => "",
79
79
  :MAP_FILE_PIPE => true,
80
80
  :OUTPUT_ENDING => ".exe", # or .elf
81
- :ERROR_PARSER => nil
81
+ :ERROR_PARSER => nil,
82
+ :LIST_MODE => false
82
83
  },
83
84
 
84
85
  :MAKE =>
@@ -136,3 +137,4 @@ require 'cxxproject/toolchain/gcc'
136
137
  require 'cxxproject/toolchain/clang'
137
138
  require 'cxxproject/toolchain/ti'
138
139
  require 'cxxproject/toolchain/greenhills'
140
+ require 'cxxproject/toolchain/keil'
@@ -1,22 +1,31 @@
1
1
  module Cxxproject
2
2
  module Utils
3
3
 
4
- def self.flagSplit(str)
4
+ def self.flagSplit(str, removeQuotes)
5
5
  hasQuote = false
6
6
  hasDoubleQuote = false
7
+ hadQuote = false
7
8
  ar = []
8
9
  s = ""
9
10
 
11
+ #puts str
12
+
10
13
  str.split("").each do |i|
11
14
  hasDoubleQuote = !hasDoubleQuote if !hasQuote and i == '"'
12
- hasQuote = !hasQuote if !hasDoubleQuote and i == '\''
13
- if i == ' '
14
- if not hasDoubleQuote and not hasQuote
15
- ar << s if s.length > 0
16
- s = ""
17
- next
18
- end
19
- end
15
+ hasQuote = !hasQuote if !hasDoubleQuote and i == '\''
16
+ hadQuote = true if hasDoubleQuote
17
+ if i == ' '
18
+ if not hasDoubleQuote and not hasQuote
19
+ if hadQuote and removeQuotes
20
+ ar << s[1..-2] if s.length > 2
21
+ hadQuote = false
22
+ else
23
+ ar << s if s.length > 0
24
+ end
25
+ s = ""
26
+ next
27
+ end
28
+ end
20
29
  s << i
21
30
  end
22
31
  ar << s if s.length > 0
@@ -1,7 +1,7 @@
1
1
  module Cxxproject
2
2
  class Version
3
3
  def self.cxxproject
4
- "0.5.67"
4
+ "0.5.68"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: cxxproject
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.5.67
5
+ version: 0.5.68
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: 2013-06-21 00:00:00 Z
13
+ date: 2013-09-09 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: highline
@@ -63,6 +63,8 @@ files:
63
63
  - lib/cxxproject/errorparser/gcc_linker_error_parser.rb
64
64
  - lib/cxxproject/errorparser/greenhills_compiler_error_parser.rb
65
65
  - lib/cxxproject/errorparser/greenhills_linker_error_parser.rb
66
+ - lib/cxxproject/errorparser/keil_compiler_error_parser.rb
67
+ - lib/cxxproject/errorparser/keil_linker_error_parser.rb
66
68
  - lib/cxxproject/errorparser/ti_compiler_error_parser.rb
67
69
  - lib/cxxproject/errorparser/ti_linker_error_parser.rb
68
70
  - lib/cxxproject/eval_context.rb
@@ -79,6 +81,7 @@ files:
79
81
  - lib/cxxproject/toolchain/diab.rb
80
82
  - lib/cxxproject/toolchain/gcc.rb
81
83
  - lib/cxxproject/toolchain/greenhills.rb
84
+ - lib/cxxproject/toolchain/keil.rb
82
85
  - lib/cxxproject/toolchain/provider.rb
83
86
  - lib/cxxproject/toolchain/ti.rb
84
87
  - lib/cxxproject/toolchain/toolchain.rb