bake-toolkit 2.20.4 → 2.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Rakefile.rb +3 -3
- data/bin/bake +46 -46
- data/bin/bake-doc +11 -11
- data/bin/bakery +179 -179
- data/bin/createVSProjects +213 -213
- data/documentation/_build/html/_sources/changelog.txt +456 -451
- data/documentation/_build/html/_sources/commandline/commandline.txt +107 -107
- data/documentation/_build/html/_sources/concepts/build_hierarchy.txt +34 -34
- data/documentation/_build/html/_sources/concepts/concepts.txt +14 -14
- data/documentation/_build/html/_sources/concepts/inject.txt +65 -65
- data/documentation/_build/html/_sources/concepts/link_order.txt +91 -91
- data/documentation/_build/html/_sources/concepts/prebuild.txt +56 -56
- data/documentation/_build/html/_sources/concepts/the_main_project.txt +45 -45
- data/documentation/_build/html/_sources/concepts/the_project_meta_file.txt +72 -72
- data/documentation/_build/html/_sources/ide/eclipse/eclipse.txt +25 -25
- data/documentation/_build/html/_sources/ide/eclipse/how_to_convert_existing_cdt_workspace.txt +31 -31
- data/documentation/_build/html/_sources/ide/eclipse/how_to_create_a_new_project_in_eclipse.txt +18 -18
- data/documentation/_build/html/_sources/ide/eclipse/how_to_create_a_workspace_in_eclipse.txt +27 -27
- data/documentation/_build/html/_sources/ide/eclipse/how_to_debug_in_eclipse.txt +38 -38
- data/documentation/_build/html/_sources/ide/eclipse/how_to_install_eclipse_plugin.txt +44 -44
- data/documentation/_build/html/_sources/ide/eclipse/how_to_use_bake_in_eclipse.txt +86 -86
- data/documentation/_build/html/_sources/ide/ide_integrations.txt +8 -8
- data/documentation/_build/html/_sources/ide/vs/how_to_create_vs_projects.txt +15 -15
- data/documentation/_build/html/_sources/ide/vs/how_to_debug_in_vs.txt +35 -35
- data/documentation/_build/html/_sources/ide/vs/how_to_used_bake_in_vs.txt +35 -35
- data/documentation/_build/html/_sources/ide/vs/vs.txt +10 -10
- data/documentation/_build/html/_sources/ide/vs/vs_install.txt +43 -43
- data/documentation/_build/html/_sources/index.txt +33 -33
- data/documentation/_build/html/_sources/install/install_bake.txt +112 -112
- data/documentation/_build/html/_sources/internal.txt +50 -50
- data/documentation/_build/html/_sources/known_issues.txt +9 -9
- data/documentation/_build/html/_sources/license.txt +4 -4
- data/documentation/_build/html/_sources/performance/performance.txt +104 -104
- data/documentation/_build/html/_sources/quickstart/quickstart.txt +70 -70
- data/documentation/_build/html/_sources/syntax/adapt_configs.txt +143 -143
- data/documentation/_build/html/_sources/syntax/auto_adjustment.txt +43 -43
- data/documentation/_build/html/_sources/syntax/derive_configs.txt +93 -94
- data/documentation/_build/html/_sources/syntax/project_meta_syntax.txt +19 -19
- data/documentation/_build/html/_sources/syntax/syntax.txt +11 -11
- data/documentation/_build/html/_sources/syntax/variable_substitutions.txt +147 -147
- data/documentation/_build/html/_sources/tips_and_tricks/dot.txt +34 -34
- data/documentation/_build/html/_sources/tips_and_tricks/how_to_use_bake_with_cygwin.txt +62 -62
- data/documentation/_build/html/_sources/tips_and_tricks/static_code_analysis.txt +122 -122
- data/documentation/_build/html/_sources/tips_and_tricks/the_bakery.txt +72 -72
- data/documentation/_build/html/_sources/tips_and_tricks/the_clang.txt +43 -43
- data/documentation/_build/html/_sources/tips_and_tricks/tips_and_tricks.txt +34 -34
- data/documentation/_build/html/_sources/why_bake/why_bake.txt +40 -40
- data/documentation/_build/html/changelog.html +7 -0
- data/documentation/_build/html/commandline/commandline.html +2 -2
- data/documentation/_build/html/concepts/link_order.html +2 -2
- data/documentation/_build/html/concepts/prebuild.html +2 -2
- data/documentation/_build/html/index.html +4 -4
- data/documentation/_build/html/performance/performance.html +2 -2
- data/documentation/_build/html/searchindex.js +1 -1
- data/documentation/_build/html/syntax/adapt_configs.html +2 -2
- data/documentation/_build/html/syntax/syntax.html +2 -2
- data/documentation/_build/html/tips_and_tricks/the_clang.html +2 -2
- data/documentation/_build/html/why_bake/why_bake.html +2 -2
- data/lib/adapt/config/loader.rb +112 -112
- data/lib/bake/bundle.rb +158 -158
- data/lib/bake/cache.rb +179 -180
- data/lib/bake/config/checks.rb +68 -68
- data/lib/bake/config/loader.rb +363 -363
- data/lib/bake/libElement.rb +176 -176
- data/lib/bake/mergeConfig.rb +208 -208
- data/lib/bake/model/language.rb +45 -45
- data/lib/bake/model/loader.rb +99 -99
- data/lib/bake/model/metamodel.rb +307 -307
- data/lib/bake/model/metamodel_ext.rb +27 -27
- data/lib/bake/options/create.rb +95 -95
- data/lib/bake/options/options.rb +315 -310
- data/lib/bake/options/showDoc.rb +20 -20
- data/lib/bake/options/showLicense.rb +9 -9
- data/lib/bake/options/showToolchains.rb +38 -38
- data/lib/bake/options/usage.rb +79 -68
- data/lib/bake/subst.rb +313 -313
- data/lib/bake/toolchain/clang.rb +44 -44
- data/lib/bake/toolchain/clang_analyze.rb +31 -31
- data/lib/bake/toolchain/colorizing_formatter.rb +125 -125
- data/lib/bake/toolchain/diab.rb +53 -53
- data/lib/bake/toolchain/errorparser/diab_compiler_error_parser.rb +40 -40
- data/lib/bake/toolchain/errorparser/diab_linker_error_parser.rb +41 -41
- data/lib/bake/toolchain/errorparser/error_parser.rb +71 -71
- data/lib/bake/toolchain/errorparser/gcc_compiler_error_parser.rb +35 -35
- data/lib/bake/toolchain/errorparser/gcc_linker_error_parser.rb +35 -35
- data/lib/bake/toolchain/errorparser/greenhills_compiler_error_parser.rb +32 -32
- data/lib/bake/toolchain/errorparser/greenhills_linker_error_parser.rb +44 -44
- data/lib/bake/toolchain/errorparser/keil_compiler_error_parser.rb +40 -40
- data/lib/bake/toolchain/errorparser/keil_linker_error_parser.rb +30 -30
- data/lib/bake/toolchain/errorparser/lint_error_parser.rb +34 -34
- data/lib/bake/toolchain/errorparser/msvc_compiler_error_parser.rb +63 -63
- data/lib/bake/toolchain/errorparser/msvc_linker_error_parser.rb +42 -42
- data/lib/bake/toolchain/errorparser/process_output.rb +2 -2
- data/lib/bake/toolchain/errorparser/ti_compiler_error_parser.rb +30 -30
- data/lib/bake/toolchain/errorparser/ti_linker_error_parser.rb +30 -30
- data/lib/bake/toolchain/gcc.rb +49 -49
- data/lib/bake/toolchain/gcc_env.rb +55 -55
- data/lib/bake/toolchain/greenhills.rb +52 -52
- data/lib/bake/toolchain/keil.rb +53 -53
- data/lib/bake/toolchain/lint.rb +20 -20
- data/lib/bake/toolchain/msvc.rb +58 -58
- data/lib/bake/toolchain/provider.rb +146 -146
- data/lib/bake/toolchain/ti.rb +47 -47
- data/lib/bake/util.rb +149 -149
- data/lib/bakery/buildPattern.rb +24 -24
- data/lib/bakery/model/language.rb +22 -22
- data/lib/bakery/model/loader.rb +55 -55
- data/lib/bakery/model/metamodel.rb +48 -48
- data/lib/bakery/options/options.rb +87 -87
- data/lib/bakery/toBake.rb +81 -81
- data/lib/blocks/block.rb +324 -324
- data/lib/blocks/blockBase.rb +204 -204
- data/lib/blocks/commandLine.rb +38 -38
- data/lib/blocks/compile.rb +529 -528
- data/lib/blocks/convert.rb +41 -41
- data/lib/blocks/docu.rb +30 -30
- data/lib/blocks/executable.rb +174 -174
- data/lib/blocks/has_execute_command.rb +31 -31
- data/lib/blocks/library.rb +114 -114
- data/lib/blocks/lint.rb +56 -56
- data/lib/blocks/makefile.rb +100 -100
- data/lib/blocks/showIncludes.rb +140 -125
- data/lib/common/abortException.rb +4 -4
- data/lib/common/cleanup.rb +10 -10
- data/lib/common/exit_helper.rb +38 -38
- data/lib/common/ext/file.rb +88 -88
- data/lib/common/ext/rtext.rb +11 -11
- data/lib/common/ext/stdout.rb +45 -45
- data/lib/common/ide_interface.rb +194 -194
- data/lib/common/options/parser.rb +95 -85
- data/lib/common/process.rb +64 -64
- data/lib/common/utils.rb +52 -52
- data/lib/common/version.rb +31 -23
- data/lib/multithread/job.rb +44 -44
- data/lib/tocxx.rb +558 -555
- data/lib/vs/options.rb +69 -69
- data/license.txt +90 -90
- metadata +2 -2
data/lib/common/ext/rtext.rb
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
require 'rtext/serializer'
|
|
2
|
-
|
|
3
|
-
module RText
|
|
4
|
-
class Serializer
|
|
5
|
-
alias :old_serialize_values :serialize_values
|
|
6
|
-
def serialize_values(element, feature)
|
|
7
|
-
return nil unless element.eIsSet(feature.name)
|
|
8
|
-
old_serialize_values(element, feature)
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
end
|
|
1
|
+
require 'rtext/serializer'
|
|
2
|
+
|
|
3
|
+
module RText
|
|
4
|
+
class Serializer
|
|
5
|
+
alias :old_serialize_values :serialize_values
|
|
6
|
+
def serialize_values(element, feature)
|
|
7
|
+
return nil unless element.eIsSet(feature.name)
|
|
8
|
+
old_serialize_values(element, feature)
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
data/lib/common/ext/stdout.rb
CHANGED
|
@@ -1,45 +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)
|
|
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)
|
data/lib/common/ide_interface.rb
CHANGED
|
@@ -1,194 +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
|
|
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
|