bake-toolkit 2.32.0 → 2.33.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/lib/bake/toolchain/errorparser/diab_compiler_error_parser.rb +40 -40
- data/lib/bake/toolchain/errorparser/gcc_compiler_error_parser.rb +35 -35
- data/lib/bake/toolchain/errorparser/greenhills_compiler_error_parser.rb +32 -32
- data/lib/bake/toolchain/errorparser/keil_compiler_error_parser.rb +40 -40
- data/lib/bake/toolchain/errorparser/msvc_compiler_error_parser.rb +63 -63
- data/lib/bake/toolchain/errorparser/tasking_compiler_error_parser.rb +31 -31
- data/lib/bake/toolchain/errorparser/ti_compiler_error_parser.rb +30 -30
- data/lib/blocks/block.rb +121 -22
- data/lib/blocks/blockBase.rb +206 -205
- data/lib/blocks/compile.rb +124 -147
- data/lib/blocks/executable.rb +1 -1
- data/lib/blocks/library.rb +147 -131
- data/lib/common/cleanup.rb +14 -10
- data/lib/common/ext/dir.rb +19 -0
- data/lib/common/ext/stdout.rb +95 -45
- data/lib/common/process.rb +64 -64
- data/lib/common/version.rb +1 -1
- data/lib/multithread/job.rb +73 -44
- data/lib/tocxx.rb +13 -2
- metadata +3 -2
data/lib/common/cleanup.rb
CHANGED
@@ -1,10 +1,14 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
Blocks::
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
1
|
+
require "blocks/block"
|
2
|
+
|
3
|
+
module Bake
|
4
|
+
|
5
|
+
def self.cleanup()
|
6
|
+
Blocks::ALL_BLOCKS.clear
|
7
|
+
Blocks::ALL_COMPILE_BLOCKS.clear
|
8
|
+
Blocks::CC2J.clear
|
9
|
+
Bake::IDEInterface.instance.set_abort(false)
|
10
|
+
Blocks::Block.reset_block_counter
|
11
|
+
Blocks::Block.delayed_result
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class Dir
|
2
|
+
|
3
|
+
@@mutex = Mutex.new
|
4
|
+
|
5
|
+
def self.glob_dir(pattern, dir)
|
6
|
+
result = nil
|
7
|
+
@@mutex.synchronize do
|
8
|
+
Dir.chdir(dir) do
|
9
|
+
result = Dir.glob(pattern)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
return result
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.mutex
|
16
|
+
@@mutex
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
data/lib/common/ext/stdout.rb
CHANGED
@@ -1,45 +1,95 @@
|
|
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)
|
46
|
+
|
47
|
+
|
48
|
+
class SyncOut
|
49
|
+
def self.mutex
|
50
|
+
@@mutex ||= Mutex.new
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.flushOutput
|
54
|
+
mutex.synchronize do
|
55
|
+
tmp = Thread.current[:stdout]
|
56
|
+
if tmp.string.length > 0
|
57
|
+
Thread.current[:stdout] = Thread.current[:tmpStdout]
|
58
|
+
puts tmp.string
|
59
|
+
tmp.reopen("")
|
60
|
+
Thread.current[:stdout] = tmp
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.startStream
|
66
|
+
s = StringIO.new
|
67
|
+
Thread.current[:tmpStdout] = Thread.current[:stdout]
|
68
|
+
Thread.current[:stdout] = s
|
69
|
+
end
|
70
|
+
|
71
|
+
def self.stopStream(result)
|
72
|
+
s = Thread.current[:stdout]
|
73
|
+
Thread.current[:stdout] = Thread.current[:tmpStdout]
|
74
|
+
if s.string.length > 0
|
75
|
+
mutex.synchronize do
|
76
|
+
if !result && Bake.options.stopOnFirstError
|
77
|
+
@@errors << s.string
|
78
|
+
else
|
79
|
+
puts s.string
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def self.flush_errors
|
86
|
+
puts @@errors unless @@errors.empty?
|
87
|
+
reset_errors
|
88
|
+
end
|
89
|
+
|
90
|
+
def self.reset_errors
|
91
|
+
@@errors = ""
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
|
data/lib/common/process.rb
CHANGED
@@ -1,65 +1,65 @@
|
|
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, exitCodeArray = [0])
|
8
|
-
rd, wr = IO.pipe
|
9
|
-
@@rd = rd if force
|
10
|
-
duppedCmdLineArray = cmdLineArray.dup
|
11
|
-
duppedCmdLineArray << { :err=>wr, :out=>(outpipe ? outpipe : wr) }
|
12
|
-
begin
|
13
|
-
pid = spawn(*duppedCmdLineArray)
|
14
|
-
rescue Exception => e
|
15
|
-
return [false, e.message]
|
16
|
-
end
|
17
|
-
@@pid = pid if force
|
18
|
-
wr.close
|
19
|
-
output = ""
|
20
|
-
begin
|
21
|
-
while not rd.eof?
|
22
|
-
tmp = rd.read(1)
|
23
|
-
if (tmp != nil)
|
24
|
-
tmp.encode!('UTF-8', :invalid => :replace, :undef => :replace, :replace => '')
|
25
|
-
tmp.encode!('binary', :invalid => :replace, :undef => :replace, :replace => '')
|
26
|
-
output << tmp
|
27
|
-
|
28
|
-
print tmp if immediateOutput
|
29
|
-
end
|
30
|
-
end
|
31
|
-
rescue
|
32
|
-
# Seems to be a bug in ruby: sometimes there is a bad file descriptor on Windows instead of eof, which causes
|
33
|
-
# an exception on read(). However, this happens not before everything is read, so there is no practical difference
|
34
|
-
# how to "break" the loop.
|
35
|
-
# This problem occurs on Windows command shell and Cygwin.
|
36
|
-
end
|
37
|
-
|
38
|
-
begin
|
39
|
-
rd.close
|
40
|
-
rescue
|
41
|
-
end
|
42
|
-
pid, status = Process.wait2(pid)
|
43
|
-
@@pid = nil
|
44
|
-
@@rd = nil
|
45
|
-
return [false, output] if status.nil?
|
46
|
-
exitCodeArray = [0] if exitCodeArray.empty?
|
47
|
-
[(exitCodeArray.include?status.exitstatus), output]
|
48
|
-
end
|
49
|
-
|
50
|
-
def self.killProcess(force) # do not kill compile processes or implement rd and pid array if really needed
|
51
|
-
begin
|
52
|
-
@@rd.close
|
53
|
-
rescue Exception => e
|
54
|
-
end
|
55
|
-
begin
|
56
|
-
Process.kill("KILL",@@pid)
|
57
|
-
rescue Exception => e
|
58
|
-
end
|
59
|
-
@@rd = nil
|
60
|
-
@@pid = nil
|
61
|
-
end
|
62
|
-
|
63
|
-
end
|
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, exitCodeArray = [0], dir = Dir.pwd)
|
8
|
+
rd, wr = IO.pipe
|
9
|
+
@@rd = rd if force
|
10
|
+
duppedCmdLineArray = cmdLineArray.dup
|
11
|
+
duppedCmdLineArray << { :chdir=>dir, :err=>wr, :out=>(outpipe ? outpipe : wr) }
|
12
|
+
begin
|
13
|
+
pid = spawn(*duppedCmdLineArray)
|
14
|
+
rescue Exception => e
|
15
|
+
return [false, e.message]
|
16
|
+
end
|
17
|
+
@@pid = pid if force
|
18
|
+
wr.close
|
19
|
+
output = ""
|
20
|
+
begin
|
21
|
+
while not rd.eof?
|
22
|
+
tmp = rd.read(1)
|
23
|
+
if (tmp != nil)
|
24
|
+
tmp.encode!('UTF-8', :invalid => :replace, :undef => :replace, :replace => '')
|
25
|
+
tmp.encode!('binary', :invalid => :replace, :undef => :replace, :replace => '')
|
26
|
+
output << tmp
|
27
|
+
|
28
|
+
print tmp if immediateOutput
|
29
|
+
end
|
30
|
+
end
|
31
|
+
rescue
|
32
|
+
# Seems to be a bug in ruby: sometimes there is a bad file descriptor on Windows instead of eof, which causes
|
33
|
+
# an exception on read(). However, this happens not before everything is read, so there is no practical difference
|
34
|
+
# how to "break" the loop.
|
35
|
+
# This problem occurs on Windows command shell and Cygwin.
|
36
|
+
end
|
37
|
+
|
38
|
+
begin
|
39
|
+
rd.close
|
40
|
+
rescue
|
41
|
+
end
|
42
|
+
pid, status = Process.wait2(pid)
|
43
|
+
@@pid = nil
|
44
|
+
@@rd = nil
|
45
|
+
return [false, output] if status.nil?
|
46
|
+
exitCodeArray = [0] if exitCodeArray.empty?
|
47
|
+
[(exitCodeArray.include?status.exitstatus), output]
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.killProcess(force) # do not kill compile processes or implement rd and pid array if really needed
|
51
|
+
begin
|
52
|
+
@@rd.close
|
53
|
+
rescue Exception => e
|
54
|
+
end
|
55
|
+
begin
|
56
|
+
Process.kill("KILL",@@pid)
|
57
|
+
rescue Exception => e
|
58
|
+
end
|
59
|
+
@@rd = nil
|
60
|
+
@@pid = nil
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
65
|
end
|
data/lib/common/version.rb
CHANGED
data/lib/multithread/job.rb
CHANGED
@@ -1,44 +1,73 @@
|
|
1
|
-
require 'common/ext/stdout'
|
2
|
-
require 'stringio'
|
3
|
-
require 'thread'
|
4
|
-
|
5
|
-
module Bake
|
6
|
-
module Multithread
|
7
|
-
|
8
|
-
class Jobs
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
def
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
@
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
1
|
+
require 'common/ext/stdout'
|
2
|
+
require 'stringio'
|
3
|
+
require 'thread'
|
4
|
+
|
5
|
+
module Bake
|
6
|
+
module Multithread
|
7
|
+
|
8
|
+
class Jobs
|
9
|
+
|
10
|
+
@@mutex_sempaphore = Mutex.new
|
11
|
+
@@running_threads = 0
|
12
|
+
@@waiting_threads = 0
|
13
|
+
@@cv = ConditionVariable.new
|
14
|
+
|
15
|
+
def self.incThread
|
16
|
+
@@mutex_sempaphore.synchronize do
|
17
|
+
if @@running_threads >= Bake.options.threads
|
18
|
+
@@waiting_threads += 1
|
19
|
+
@@cv.wait(@@mutex_sempaphore)
|
20
|
+
@@waiting_threads -= 1
|
21
|
+
@@running_threads += 1
|
22
|
+
else
|
23
|
+
@@running_threads += 1
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
def self.decThread
|
28
|
+
@@mutex_sempaphore.synchronize do
|
29
|
+
@@running_threads -= 1
|
30
|
+
if @@waiting_threads > 0
|
31
|
+
@@cv.signal
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def initialize(jobs, &block)
|
37
|
+
nr_of_threads = [Bake.options.threads, jobs.length].min
|
38
|
+
@jobs = jobs
|
39
|
+
@threads = []
|
40
|
+
nr_of_threads.times do
|
41
|
+
@threads << ::Thread.new do
|
42
|
+
Jobs.incThread()
|
43
|
+
block.call(self)
|
44
|
+
Jobs.decThread()
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def failed
|
50
|
+
@failed ||= false
|
51
|
+
end
|
52
|
+
def set_failed
|
53
|
+
@failed = true
|
54
|
+
end
|
55
|
+
|
56
|
+
def get_next_or_nil
|
57
|
+
the_next = nil
|
58
|
+
mutex.synchronize {
|
59
|
+
the_next = @jobs.shift
|
60
|
+
}
|
61
|
+
the_next
|
62
|
+
end
|
63
|
+
def join
|
64
|
+
@threads.each{|t| while not t.join(2) do end}
|
65
|
+
end
|
66
|
+
def mutex
|
67
|
+
@mutex ||= Mutex.new
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
data/lib/tocxx.rb
CHANGED
@@ -33,6 +33,7 @@ require 'blocks/showIncludes'
|
|
33
33
|
require 'common/abortException'
|
34
34
|
|
35
35
|
require 'adapt/config/loader'
|
36
|
+
require "thwait"
|
36
37
|
|
37
38
|
module Bake
|
38
39
|
|
@@ -350,7 +351,14 @@ module Bake
|
|
350
351
|
Blocks::Block.reset_block_counter
|
351
352
|
result = true
|
352
353
|
startBlocks.each do |block|
|
353
|
-
|
354
|
+
begin
|
355
|
+
SyncOut.reset_errors
|
356
|
+
result = callBlock(block, method) && result
|
357
|
+
ensure
|
358
|
+
ThreadsWait.all_waits(Blocks::Block::threads)
|
359
|
+
SyncOut.flush_errors
|
360
|
+
end
|
361
|
+
result &&= Blocks::Block.delayed_result
|
354
362
|
if not ignoreStopOnFirstError
|
355
363
|
return false if not result and Bake.options.stopOnFirstError
|
356
364
|
end
|
@@ -510,7 +518,10 @@ module Bake
|
|
510
518
|
Bake::IDEInterface.instance.set_build_info(@mainConfig.parent.name, @mainConfig.name, Blocks::ALL_BLOCKS.length)
|
511
519
|
|
512
520
|
ideAbort = false
|
521
|
+
Blocks::Block.reset_delayed_result
|
522
|
+
|
513
523
|
begin
|
524
|
+
Blocks::Block.init_threads()
|
514
525
|
result = callBlocks(startBlocks, :startup, true)
|
515
526
|
if Bake.options.clean or Bake.options.rebuild
|
516
527
|
if not Bake.options.stopOnFirstError or result
|
@@ -527,7 +538,7 @@ module Bake
|
|
527
538
|
end
|
528
539
|
result = callBlocks(startBlocks, :exits, true) && result
|
529
540
|
|
530
|
-
if ideAbort
|
541
|
+
if ideAbort || Bake::IDEInterface.instance.get_abort
|
531
542
|
Bake.formatter.printError("\n#{taskType} aborted.")
|
532
543
|
ExitHelper.set_exit_code(1)
|
533
544
|
return
|