bake-toolkit 1.8.0.1 → 2.0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/bin/bake +14 -53
  3. data/bin/bakery +50 -43
  4. data/bin/createVSProjects +3 -3
  5. data/doc/cmd/install.html +1 -5
  6. data/doc/cmd/usecmd.html +29 -5
  7. data/doc/dyk/lint.html +21 -4
  8. data/doc/dyk/tipps.html +0 -6
  9. data/doc/eclipse/import.html +3 -1
  10. data/doc/eclipse/import/Import.png +0 -0
  11. data/doc/eclipse/use.html +8 -5
  12. data/doc/further/change.html +134 -1
  13. data/doc/further/issues.html +1 -0
  14. data/doc/further/wish.html +24 -21
  15. data/doc/index.html +1 -1
  16. data/doc/syntax/subst.html +8 -1
  17. data/doc/syntax/syntax.html +42 -14
  18. data/lib/bake/cache.rb +51 -59
  19. data/lib/bake/config/loader.rb +289 -0
  20. data/lib/bake/libElement.rb +134 -0
  21. data/lib/bake/mergeConfig.rb +1 -1
  22. data/lib/bake/model/language.rb +1 -1
  23. data/lib/bake/model/loader.rb +88 -0
  24. data/lib/bake/model/metamodel.rb +24 -16
  25. data/lib/bake/model/metamodel_ext.rb +9 -4
  26. data/lib/bake/options/options.rb +222 -0
  27. data/lib/bake/options/showConfigNames.rb +44 -0
  28. data/lib/bake/options/showDoc.rb +19 -0
  29. data/lib/bake/options/showLicense.rb +9 -0
  30. data/lib/bake/options/showToolchains.rb +39 -0
  31. data/lib/bake/options/usage.rb +54 -0
  32. data/lib/bake/process_output.rb +10 -0
  33. data/lib/bake/subst.rb +105 -40
  34. data/lib/bake/toolchain/clang.rb +44 -0
  35. data/lib/bake/toolchain/colorizing_formatter.rb +125 -0
  36. data/lib/bake/toolchain/diab.rb +53 -0
  37. data/lib/bake/toolchain/errorparser/diab_compiler_error_parser.rb +40 -0
  38. data/lib/bake/toolchain/errorparser/diab_linker_error_parser.rb +41 -0
  39. data/lib/bake/toolchain/errorparser/error_parser.rb +71 -0
  40. data/lib/bake/toolchain/errorparser/gcc_compiler_error_parser.rb +35 -0
  41. data/lib/bake/toolchain/errorparser/gcc_linker_error_parser.rb +35 -0
  42. data/lib/bake/toolchain/errorparser/greenhills_compiler_error_parser.rb +32 -0
  43. data/lib/bake/toolchain/errorparser/greenhills_linker_error_parser.rb +44 -0
  44. data/lib/bake/toolchain/errorparser/keil_compiler_error_parser.rb +40 -0
  45. data/lib/bake/toolchain/errorparser/keil_linker_error_parser.rb +30 -0
  46. data/lib/bake/toolchain/errorparser/lint_error_parser.rb +34 -0
  47. data/lib/bake/toolchain/errorparser/process_output.rb +3 -0
  48. data/lib/bake/toolchain/errorparser/ti_compiler_error_parser.rb +30 -0
  49. data/lib/bake/toolchain/errorparser/ti_linker_error_parser.rb +30 -0
  50. data/lib/bake/toolchain/gcc.rb +49 -0
  51. data/lib/bake/toolchain/gcc_param.rb +7 -0
  52. data/lib/bake/toolchain/greenhills.rb +52 -0
  53. data/lib/bake/toolchain/keil.rb +55 -0
  54. data/lib/bake/toolchain/lint.rb +20 -0
  55. data/lib/bake/toolchain/provider.rb +136 -0
  56. data/lib/bake/toolchain/ti.rb +47 -0
  57. data/lib/bake/util.rb +27 -15
  58. data/lib/bakery/buildPattern.rb +1 -1
  59. data/lib/bakery/model/language.rb +1 -1
  60. data/lib/bakery/model/loader.rb +56 -0
  61. data/lib/bakery/model/metamodel.rb +1 -1
  62. data/lib/bakery/options/options.rb +87 -0
  63. data/lib/bakery/toBake.rb +10 -6
  64. data/lib/blocks/block.rb +225 -0
  65. data/lib/blocks/blockBase.rb +155 -0
  66. data/lib/blocks/commandLine.rb +25 -0
  67. data/lib/blocks/compile.rb +382 -0
  68. data/lib/blocks/docu.rb +28 -0
  69. data/lib/blocks/executable.rb +143 -0
  70. data/lib/blocks/has_execute_command.rb +31 -0
  71. data/lib/blocks/library.rb +78 -0
  72. data/lib/blocks/lint.rb +53 -0
  73. data/lib/blocks/makefile.rb +87 -0
  74. data/lib/blocks/showIncludes.rb +114 -0
  75. data/lib/common/abortException.rb +4 -0
  76. data/lib/common/cleanup.rb +9 -0
  77. data/lib/common/exit_helper.rb +28 -0
  78. data/lib/common/ext/file.rb +88 -0
  79. data/lib/common/ext/stdout.rb +45 -0
  80. data/lib/common/ide_interface.rb +194 -0
  81. data/lib/common/options/option.rb +13 -0
  82. data/lib/common/options/parser.rb +59 -0
  83. data/lib/common/process.rb +64 -0
  84. data/lib/common/utils.rb +52 -0
  85. data/lib/{bake → common}/version.rb +3 -10
  86. data/lib/multithread/job.rb +44 -0
  87. data/lib/tocxx.rb +201 -932
  88. data/lib/vs/options.rb +3 -2
  89. data/license.txt +47 -22
  90. metadata +90 -30
  91. data/bin/bake-doc +0 -12
  92. data/lib/alias/loader.rb +0 -56
  93. data/lib/alias/model/language.rb +0 -22
  94. data/lib/alias/model/metamodel.rb +0 -29
  95. data/lib/bake/loader.rb +0 -92
  96. data/lib/bake/options.rb +0 -421
  97. data/lib/bakery/loader.rb +0 -57
  98. data/lib/bakery/options.rb +0 -105
  99. data/lib/option/parser.rb +0 -73
@@ -0,0 +1,45 @@
1
+ require 'stringio'
2
+
3
+ class ThreadOut
4
+
5
+ def initialize(out)
6
+ @out = out
7
+ end
8
+
9
+ def write(stuff='')
10
+ if Thread.current[:stdout] then
11
+ Thread.current[:stdout].write stuff
12
+ else
13
+ @out.write stuff
14
+ end
15
+ end
16
+
17
+ def puts(stuff='')
18
+ if Thread.current[:stdout] then
19
+ Thread.current[:stdout].puts stuff
20
+ else
21
+ @out.puts stuff
22
+ end
23
+ end
24
+
25
+ def print(stuff='')
26
+ if Thread.current[:stdout] then
27
+ Thread.current[:stdout].puts stuff
28
+ else
29
+ @out.print stuff
30
+ end
31
+ end
32
+
33
+ def flush
34
+ if Thread.current[:stdout] then
35
+ Thread.current[:stdout].flush
36
+ else
37
+ @out.flush
38
+ end
39
+ end
40
+ end
41
+
42
+ STDOUT.sync = true
43
+ STDERR.sync = true
44
+ $stdout = ThreadOut.new(STDOUT)
45
+ $stderr = ThreadOut.new(STDERR)
@@ -0,0 +1,194 @@
1
+ require 'bake/toolchain/errorparser/error_parser'
2
+ require 'bake/toolchain/colorizing_formatter'
3
+ require 'thread'
4
+
5
+ module Bake
6
+
7
+ # header of tcp msg from bake to eclipse:
8
+ # 1 byte = type (problem = 0x01)
9
+ # 4 bytes = length of msg
10
+
11
+ # payload of problem type:
12
+ # 4 bytes = length filename
13
+ # x bytes = filename
14
+ # 4 bytes = linenumber
15
+ # 1 byte = severity (0..2)
16
+ # rest = error msg
17
+ class IDEInterface < ErrorParser
18
+
19
+ def initialize()
20
+ @socket = nil
21
+ @abort = false
22
+ @thread = nil
23
+ end
24
+
25
+ def self.instance
26
+ @@ide ||= IDEInterface.new
27
+ end
28
+
29
+
30
+ def mutex
31
+ @mutex ||= Mutex.new
32
+ end
33
+
34
+ def connect(port)
35
+ begin
36
+ @socket = TCPSocket.new('localhost', port)
37
+
38
+ @thread = Thread.new do
39
+ while true do
40
+ begin
41
+ @socket.recv_nonblock(1)
42
+ set_abort(true)
43
+ break
44
+ rescue Errno::EWOULDBLOCK
45
+ sleep 0.1
46
+ rescue Errno::EAGAIN
47
+ sleep 0.1
48
+ rescue Exception => e
49
+ break
50
+ end
51
+ end
52
+ end
53
+
54
+ rescue Exception => e
55
+ Bake.formatter.printError("Error: #{e.message}")
56
+ ExitHelper.exit(1)
57
+ end
58
+ end
59
+
60
+ def disconnect()
61
+ if @socket
62
+ sleep 0.1 # hack to let ruby send all data via streams before closing ... strange .. perhaps this should be synchronized!
63
+ begin
64
+ @socket.close
65
+ rescue Exception => e
66
+ Bake.formatter.printError("Error: #{e.message}")
67
+ ExitHelper.exit(1)
68
+ end
69
+ @socket = nil
70
+ end
71
+
72
+ begin
73
+ @thread.join if @thread
74
+ rescue
75
+ end
76
+ @thread = nil
77
+ end
78
+
79
+ def write_long(packet, l)
80
+ 4.times do
81
+ packet << (l & 0xff)
82
+ l = l >> 8
83
+ end
84
+ end
85
+
86
+ def force_encoding(s)
87
+ s.force_encoding("binary") if s.respond_to?("force_encoding") # for ruby >= 1.9
88
+ end
89
+
90
+ def set_length_in_header(packet)
91
+ l = packet.length - 5
92
+ if packet.respond_to?("setbyte")
93
+ (1..4).each { |i| packet.setbyte(i, (l & 0xFF)); l = l >> 8 } # ruby >= 1.9
94
+ else
95
+ (1..4).each { |i| packet[i] = (l & 0xFF); l = l >> 8 } # ruby < 1.9
96
+ end
97
+ end
98
+
99
+ def write_string(packet, s)
100
+ write_long(packet, s.length)
101
+ packet << s
102
+ end
103
+
104
+ def set_errors(error_array)
105
+ if @socket
106
+
107
+ merged_messages = []
108
+ last_msg = nil
109
+ error_array.each do |msg|
110
+ if msg.severity != 255
111
+ if msg.file_name.nil?
112
+ last_msg.message += "\r\n#{msg.message}" if last_msg
113
+ else
114
+ last_msg = msg.dup
115
+ merged_messages << last_msg
116
+ end
117
+ end
118
+ end
119
+
120
+ merged_messages.each do |msg|
121
+ msg.message.rstrip!
122
+ packet = create_error_packet(msg)
123
+ begin
124
+ mutex.synchronize { @socket.write(packet) }
125
+ rescue Exception => e
126
+ Bake.formatter.printError("Error: #{e.message}")
127
+ set_abort(true)
128
+ end
129
+ end
130
+
131
+ end
132
+ end
133
+
134
+ def create_error_packet(msg)
135
+ packet = ""
136
+ [packet, msg.file_name, msg.message].each {|s|force_encoding(s)}
137
+
138
+ packet << 1 # error type
139
+ write_long(packet,0) # length (will be corrected below)
140
+
141
+ write_string(packet, msg.file_name)
142
+ write_long(packet,msg.line_number)
143
+ packet << (msg.severity & 0xFF)
144
+ packet << msg.message
145
+
146
+ set_length_in_header(packet)
147
+ packet
148
+ end
149
+
150
+ def set_build_info(name_attr, config_name_attr, num = -1)
151
+ @num = num if (num >= 0)
152
+ name = String.new(name_attr)
153
+ config_name = String.new(config_name_attr)
154
+
155
+ packet = ""
156
+ [packet, name, config_name].each {|s|force_encoding(s)}
157
+
158
+ lname = name.length
159
+ lconfig = config_name.length
160
+ lsum = 4 + lname + 4 + lconfig + 4
161
+
162
+ packet << 10 # build info type
163
+
164
+ write_long(packet, lsum)
165
+ write_long(packet, lname)
166
+ packet << name
167
+ write_long(packet, lconfig)
168
+ packet << config_name
169
+ write_long(packet, num >=0 ? num : 0)
170
+
171
+ begin
172
+ mutex.synchronize { @socket.write(packet) if @socket }
173
+ rescue Exception => e
174
+ Bake.formatter.printError("Error: #{e.message}")
175
+ set_abort(true)
176
+ end
177
+
178
+ end
179
+
180
+ def get_number_of_projects
181
+ @num ||= 0
182
+ end
183
+
184
+ def get_abort()
185
+ @abort
186
+ end
187
+
188
+ def set_abort(value)
189
+ @abort = value
190
+ ProcessHelper.killProcess(false) if @abort
191
+ end
192
+
193
+ end
194
+ end
@@ -0,0 +1,13 @@
1
+ module Bake
2
+
3
+ class Option
4
+ attr_reader :param, :arg, :block
5
+ def initialize(param, arg, &f)
6
+ @param = param
7
+ @arg = arg # true / false
8
+ @block = f
9
+ f
10
+ end
11
+ end
12
+
13
+ end
@@ -0,0 +1,59 @@
1
+ require 'bake/toolchain/colorizing_formatter'
2
+ require 'common/exit_helper'
3
+
4
+ module Bake
5
+
6
+ class Parser
7
+
8
+ def initialize(argv)
9
+ @arguments = {}
10
+ @argv = argv
11
+ @default = nil
12
+ end
13
+
14
+ def add_option(opt)
15
+ @arguments[opt.param] = opt
16
+ end
17
+
18
+ def add_default(opt)
19
+ @default = opt
20
+ end
21
+
22
+ def parse_internal(ignoreInvalid = true)
23
+ pos = 0
24
+ begin
25
+ while pos < @argv.length do
26
+ if not @arguments.include?@argv[pos]
27
+ if @default
28
+ res = @default.call(@argv[pos])
29
+ if (not res and not ignoreInvalid)
30
+ raise "Option #{@argv[pos]} unknown"
31
+ end
32
+ end
33
+ else
34
+ option = @arguments[@argv[pos]]
35
+ if option.arg
36
+ if pos+1 < @argv.length and @argv[pos+1][0] != "-"
37
+ option.block.call(@argv[pos+1])
38
+ pos = pos + 1
39
+ else
40
+ raise "Argument for option #{@argv[pos]} missing"
41
+ end
42
+ else
43
+ option.block.call()
44
+ end
45
+ end
46
+ pos = pos + 1
47
+ end
48
+ rescue SystemExit => e
49
+ raise
50
+ rescue Exception => e
51
+ Bake.formatter.printError("Error: " + e.message)
52
+ ExitHelper.exit(1)
53
+ end
54
+
55
+ end
56
+
57
+ end
58
+
59
+ end
@@ -0,0 +1,64 @@
1
+ module Bake
2
+
3
+ class ProcessHelper
4
+ @@pid = nil
5
+ @@rd = nil
6
+
7
+ def self.run(cmdLineArray, immediateOutput=false, force=true, outpipe=nil)
8
+ rd, wr = IO.pipe
9
+ @@rd = rd if force
10
+ cmdLineArray << { :err=>wr, :out=>(outpipe ? outpipe : wr) }
11
+ begin
12
+ pid = spawn(*cmdLineArray)
13
+ rescue Exception => e
14
+ return [false, e.message]
15
+ end
16
+ @@pid = pid if force
17
+ wr.close
18
+ output = ""
19
+ begin
20
+ while not rd.eof?
21
+ tmp = rd.read(1)
22
+ if (tmp != nil)
23
+ tmp.encode!('UTF-8', :invalid => :replace, :undef => :replace, :replace => '')
24
+ tmp.encode!('binary', :invalid => :replace, :undef => :replace, :replace => '')
25
+ output << tmp
26
+
27
+ print tmp if immediateOutput
28
+ end
29
+ end
30
+ rescue
31
+ # Seems to be a bug in ruby: sometimes there is a bad file descriptor on Windows instead of eof, which causes
32
+ # an exception on read(). However, this happens not before everything is read, so there is no practical difference
33
+ # how to "break" the loop.
34
+ # This problem occurs on Windows command shell and Cygwin.
35
+ end
36
+
37
+ begin
38
+ rd.close
39
+ rescue
40
+ end
41
+ pid, status = Process.wait2(pid)
42
+ @@pid = nil
43
+ @@rd = nil
44
+ cmdLineArray.pop
45
+ return [false, output] if status.nil?
46
+ [status.success?, output]
47
+ end
48
+
49
+ def self.killProcess(force) # do not kill compile processes or implement rd and pid array if really needed
50
+ begin
51
+ @@rd.close
52
+ rescue Exception => e
53
+ end
54
+ begin
55
+ Process.kill("KILL",@@pid)
56
+ rescue Exception => e
57
+ end
58
+ @@rd = nil
59
+ @@pid = nil
60
+ end
61
+
62
+ end
63
+
64
+ end
@@ -0,0 +1,52 @@
1
+ module Bake
2
+
3
+ module Utils
4
+
5
+ def self.flagSplit(str, removeQuotes)
6
+ return [] if str == ""
7
+ return [str] unless str.include?" "
8
+
9
+ hasQuote = false
10
+ hasDoubleQuote = false
11
+ hadQuote = false
12
+ ar = []
13
+ s = ""
14
+
15
+ str.split("").each do |i|
16
+ hasDoubleQuote = !hasDoubleQuote if !hasQuote and i == '"'
17
+ hasQuote = !hasQuote if !hasDoubleQuote and i == '\''
18
+ hadQuote = true if hasDoubleQuote
19
+ if i == ' '
20
+ if not hasDoubleQuote and not hasQuote
21
+ if hadQuote and removeQuotes
22
+ ar << s[1..-2] if s.length > 2
23
+ hadQuote = false
24
+ else
25
+ ar << s if s.length > 0
26
+ end
27
+ s = ""
28
+ next
29
+ end
30
+ end
31
+ s << i
32
+ end
33
+ ar << s if s.length > 0
34
+ ar
35
+ end
36
+
37
+ # Simple helper query the operating system we are running in
38
+ module OS
39
+
40
+ # Is it windows
41
+ def OS.windows?
42
+ (RUBY_PLATFORM =~ /cygwin|mswin|mingw|bccwin|wince|emx/) != nil
43
+ end
44
+
45
+ end
46
+
47
+ def self.deep_copy(x)
48
+ Marshal.load(Marshal.dump(x))
49
+ end
50
+
51
+ end
52
+ end
@@ -1,20 +1,13 @@
1
- module Cxxproject
1
+ module Bake
2
2
  class Version
3
- def self.bake
4
- "1.8.0.1"
3
+ def self.number
4
+ "2.0.10"
5
5
  end
6
6
  end
7
7
 
8
- expectedCxx = "0.5.76"
9
8
  expectedRGen = "0.6.0"
10
9
  expectedRText = "0.2.0"
11
10
 
12
- begin
13
- gem "cxxproject", "=#{expectedCxx}"
14
- rescue Exception => e
15
- puts "Warning: Failed to load cxxproject #{expectedCxx}, using latest version"
16
- end
17
-
18
11
  begin
19
12
  gem "rgen", "=#{expectedRGen}"
20
13
  rescue Exception => e