cxxproject 0.5.48 → 0.5.59
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.
- data/Rakefile.rb +116 -116
- data/bin/cxx +10 -10
- data/lib/cxxproject.rb +23 -23
- data/lib/cxxproject/buildingblocks/binary_library.rb +39 -39
- data/lib/cxxproject/buildingblocks/building_block.rb +251 -239
- data/lib/cxxproject/buildingblocks/command_line.rb +79 -79
- data/lib/cxxproject/buildingblocks/custom_building_block.rb +39 -41
- data/lib/cxxproject/buildingblocks/executable.rb +257 -249
- data/lib/cxxproject/buildingblocks/has_dependencies_mixin.rb +83 -83
- data/lib/cxxproject/buildingblocks/has_includes_mixin.rb +20 -20
- data/lib/cxxproject/buildingblocks/has_libraries_mixin.rb +34 -34
- data/lib/cxxproject/buildingblocks/has_sources_mixin.rb +371 -364
- data/lib/cxxproject/buildingblocks/makefile.rb +153 -153
- data/lib/cxxproject/buildingblocks/module.rb +35 -35
- data/lib/cxxproject/buildingblocks/single_source.rb +33 -33
- data/lib/cxxproject/buildingblocks/source_library.rb +124 -124
- data/lib/cxxproject/errorparser/diab_compiler_error_parser.rb +40 -40
- data/lib/cxxproject/errorparser/diab_linker_error_parser.rb +41 -33
- data/lib/cxxproject/errorparser/error_parser.rb +50 -50
- data/lib/cxxproject/errorparser/gcc_compiler_error_parser.rb +35 -30
- data/lib/cxxproject/errorparser/gcc_linker_error_parser.rb +35 -29
- data/lib/cxxproject/errorparser/ti_compiler_error_parser.rb +30 -30
- data/lib/cxxproject/errorparser/ti_linker_error_parser.rb +30 -29
- data/lib/cxxproject/eval_context.rb +144 -136
- data/lib/cxxproject/ext/file.rb +71 -71
- data/lib/cxxproject/ext/filelist.rb +6 -6
- data/lib/cxxproject/ext/progressbar.rb +20 -20
- data/lib/cxxproject/ext/rake.rb +419 -397
- data/lib/cxxproject/ext/rake_dirty.rb +30 -30
- data/lib/cxxproject/ext/rake_listener.rb +59 -59
- data/lib/cxxproject/ext/stdout.rb +44 -44
- data/lib/cxxproject/ext/string.rb +9 -9
- data/lib/cxxproject/ide_interface.rb +187 -181
- data/lib/cxxproject/toolchain/clang.rb +39 -39
- data/lib/cxxproject/toolchain/colorizing_formatter.rb +99 -99
- data/lib/cxxproject/toolchain/diab.rb +3 -1
- data/lib/cxxproject/toolchain/gcc.rb +2 -1
- data/lib/cxxproject/toolchain/provider.rb +131 -128
- data/lib/cxxproject/toolchain/toolchain.rb +38 -38
- data/lib/cxxproject/toolchain/toolchain_benchmark.rb +23 -23
- data/lib/cxxproject/torake.rb +218 -216
- data/lib/cxxproject/utils/cleanup.rb +20 -20
- data/lib/cxxproject/utils/console.rb +6 -6
- data/lib/cxxproject/utils/exit_helper.rb +40 -40
- data/lib/cxxproject/utils/graphstream.rb +154 -154
- data/lib/cxxproject/utils/optional.rb +16 -16
- data/lib/cxxproject/utils/printer.rb +50 -50
- data/lib/cxxproject/utils/process.rb +52 -52
- data/lib/cxxproject/utils/progress.rb +66 -66
- data/lib/cxxproject/utils/progress_helper.rb +77 -77
- data/lib/cxxproject/utils/rbcurse.rb +284 -284
- data/lib/cxxproject/utils/rbcurse_executable_ext.rb +14 -14
- data/lib/cxxproject/utils/rbcurse_progress.rb +71 -71
- data/lib/cxxproject/utils/rbcurse_tasktable.rb +51 -51
- data/lib/cxxproject/utils/stats.rb +60 -60
- data/lib/cxxproject/utils/ubigraph.rb +228 -228
- data/lib/cxxproject/utils/utils.rb +60 -37
- data/lib/cxxproject/utils/valgrind.rb +11 -11
- data/lib/cxxproject/version.rb +7 -7
- data/lib/tools/Rakefile.rb.template +10 -10
- data/lib/tools/project.rb.template +6 -6
- data/lib/tools/project_wizard.rb +66 -66
- data/spec/building_block_spec.rb +56 -56
- data/spec/cxxproject_2_rake_spec.rb +186 -186
- data/spec/file_ext_spec.rb +30 -30
- data/spec/ide_interface_spec.rb +41 -41
- data/spec/object_dependency_spec.rb +83 -83
- data/spec/project_path_spec.rb +71 -71
- data/spec/rake_listener_ext_spec.rb +58 -58
- data/spec/spec_helper.rb +18 -18
- data/spec/string_spec.rb +11 -11
- data/spec/testdata/basic/exe12/project.rb +5 -5
- data/spec/testdata/basic/lib1/project.rb +5 -5
- data/spec/testdata/basic/lib2/project.rb +8 -8
- data/spec/testdata/multiple_levels/libs/lib1/project.rb +5 -5
- data/spec/testdata/multiple_levels/libs/lib2/project.rb +19 -19
- data/spec/testdata/multiple_levels/mainproject/basic/project.rb +8 -8
- data/spec/testdata/onlyOneHeader/Rakefile.rb +4 -4
- data/spec/testdata/onlyOneHeader/project.rb +4 -4
- data/spec/toolchain_spec.rb +29 -29
- metadata +58 -58
@@ -1,6 +1,6 @@
|
|
1
|
-
module Rake
|
2
|
-
class FileList
|
3
|
-
attr_accessor :pending_add
|
4
|
-
attr_accessor :items
|
5
|
-
end
|
6
|
-
end
|
1
|
+
module Rake
|
2
|
+
class FileList
|
3
|
+
attr_accessor :pending_add
|
4
|
+
attr_accessor :items
|
5
|
+
end
|
6
|
+
end
|
@@ -1,20 +1,20 @@
|
|
1
|
-
class ::ProgressBar
|
2
|
-
attr_writer :title
|
3
|
-
|
4
|
-
def title_width=(w)
|
5
|
-
@title_width = w
|
6
|
-
@format = "%-#{@title_width}s #{'%3d%%'.red} #{'%s'.green} #{'%s'.blue}"
|
7
|
-
end
|
8
|
-
|
9
|
-
show_original = self.instance_method(:show)
|
10
|
-
define_method(:show) do
|
11
|
-
if @unblocked && !RakeFileUtils.verbose
|
12
|
-
show_original.bind(self).call
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def unblock
|
17
|
-
@unblocked = true
|
18
|
-
show
|
19
|
-
end
|
20
|
-
end
|
1
|
+
class ::ProgressBar
|
2
|
+
attr_writer :title
|
3
|
+
|
4
|
+
def title_width=(w)
|
5
|
+
@title_width = w
|
6
|
+
@format = "%-#{@title_width}s #{'%3d%%'.red} #{'%s'.green} #{'%s'.blue}"
|
7
|
+
end
|
8
|
+
|
9
|
+
show_original = self.instance_method(:show)
|
10
|
+
define_method(:show) do
|
11
|
+
if @unblocked && !RakeFileUtils.verbose
|
12
|
+
show_original.bind(self).call
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def unblock
|
17
|
+
@unblocked = true
|
18
|
+
show
|
19
|
+
end
|
20
|
+
end
|
data/lib/cxxproject/ext/rake.rb
CHANGED
@@ -1,397 +1,419 @@
|
|
1
|
-
require 'cxxproject/ext/stdout'
|
2
|
-
require 'cxxproject/utils/exit_helper'
|
3
|
-
require 'cxxproject/errorparser/error_parser'
|
4
|
-
|
5
|
-
|
6
|
-
require 'rake'
|
7
|
-
require 'stringio'
|
8
|
-
require 'thread'
|
9
|
-
|
10
|
-
require 'cxxproject/utils/printer'
|
11
|
-
|
12
|
-
module Cxxproject
|
13
|
-
class SystemCommandFailed < Exception
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
module Rake
|
18
|
-
|
19
|
-
class Application
|
20
|
-
attr_writer :max_parallel_tasks
|
21
|
-
attr_writer :check_unnecessary_includes
|
22
|
-
attr_writer :deriveIncludes
|
23
|
-
attr_writer :
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
@
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
def
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
if
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
end
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
1
|
+
require 'cxxproject/ext/stdout'
|
2
|
+
require 'cxxproject/utils/exit_helper'
|
3
|
+
require 'cxxproject/errorparser/error_parser'
|
4
|
+
|
5
|
+
|
6
|
+
require 'rake'
|
7
|
+
require 'stringio'
|
8
|
+
require 'thread'
|
9
|
+
|
10
|
+
require 'cxxproject/utils/printer'
|
11
|
+
|
12
|
+
module Cxxproject
|
13
|
+
class SystemCommandFailed < Exception
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
module Rake
|
18
|
+
|
19
|
+
class Application
|
20
|
+
attr_writer :max_parallel_tasks
|
21
|
+
attr_writer :check_unnecessary_includes
|
22
|
+
attr_writer :deriveIncludes
|
23
|
+
attr_writer :preproFlags
|
24
|
+
attr_writer :consoleOutput_fullnames
|
25
|
+
attr_writer :addEmptyLine
|
26
|
+
def max_parallel_tasks
|
27
|
+
@max_parallel_tasks ||= 8
|
28
|
+
end
|
29
|
+
|
30
|
+
def addEmptyLine
|
31
|
+
@addEmptyLine ||= false
|
32
|
+
end
|
33
|
+
|
34
|
+
def check_unnecessary_includes
|
35
|
+
@check_unnecessary_includes ||= false
|
36
|
+
end
|
37
|
+
|
38
|
+
def idei
|
39
|
+
@idei ||= Cxxproject::IDEInterface.new
|
40
|
+
end
|
41
|
+
|
42
|
+
def idei=(value)
|
43
|
+
@idei = value
|
44
|
+
end
|
45
|
+
|
46
|
+
def command_line_number
|
47
|
+
@command_line_number ||= 1
|
48
|
+
res = @command_line_number
|
49
|
+
@command_line_number += 1
|
50
|
+
res
|
51
|
+
end
|
52
|
+
|
53
|
+
def makefile_number
|
54
|
+
@makefile_number ||= 1
|
55
|
+
res = @makefile_number
|
56
|
+
@makefile_number += 1
|
57
|
+
res
|
58
|
+
end
|
59
|
+
|
60
|
+
def deriveIncludes
|
61
|
+
@deriveIncludes ||= false
|
62
|
+
end
|
63
|
+
|
64
|
+
def preproFlags
|
65
|
+
@preproFlags ||= false
|
66
|
+
end
|
67
|
+
|
68
|
+
def consoleOutput_fullnames
|
69
|
+
@consoleOutput_fullnames ||= false
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
class Jobs
|
75
|
+
def initialize(jobs, max, &block)
|
76
|
+
nr_of_threads = [max, jobs.length].min
|
77
|
+
@jobs = jobs
|
78
|
+
@threads = []
|
79
|
+
nr_of_threads.times do
|
80
|
+
@threads << Thread.new do
|
81
|
+
block.call(self)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def get_next_or_nil
|
87
|
+
the_next = nil
|
88
|
+
mutex.synchronize {
|
89
|
+
the_next = @jobs.shift
|
90
|
+
}
|
91
|
+
the_next
|
92
|
+
end
|
93
|
+
def join
|
94
|
+
@threads.each{|t| while not t.join(2) do end}
|
95
|
+
end
|
96
|
+
def mutex
|
97
|
+
@mutex ||= Mutex.new
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
#############
|
102
|
+
# - Limit parallel tasks
|
103
|
+
#############
|
104
|
+
class MultiTask < Task
|
105
|
+
def set_building_block(bb)
|
106
|
+
@bb = bb
|
107
|
+
end
|
108
|
+
|
109
|
+
def invoke_prerequisites(args, invocation_chain)
|
110
|
+
super(args, invocation_chain)
|
111
|
+
|
112
|
+
return if @failure # pre step has failed
|
113
|
+
|
114
|
+
Dir.chdir(@bb.project_dir) do
|
115
|
+
if Dir.pwd != @bb.project_dir and File.dirname(Dir.pwd) != File.dirname(@bb.project_dir)
|
116
|
+
isSym = false
|
117
|
+
begin
|
118
|
+
isSym = File.symlink?(@bb.project_dir)
|
119
|
+
rescue
|
120
|
+
end
|
121
|
+
if isSym
|
122
|
+
message = "Symlinks only allowed with the same parent dir as the target: #{@bb.project_dir} --> #{Dir.pwd}"
|
123
|
+
res = Cxxproject::ErrorDesc.new
|
124
|
+
res.file_name = @bb.project_dir
|
125
|
+
res.line_number = 0
|
126
|
+
res.severity = Cxxproject::ErrorParser::SEVERITY_ERROR
|
127
|
+
res.message = message
|
128
|
+
Rake.application.idei.set_errors([res])
|
129
|
+
Cxxproject::Printer.printError message
|
130
|
+
set_failed
|
131
|
+
return
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
file_tasks = @bb.create_object_file_tasks
|
136
|
+
|
137
|
+
if file_tasks == nil # = error
|
138
|
+
set_failed
|
139
|
+
return
|
140
|
+
end
|
141
|
+
|
142
|
+
enhance(file_tasks)
|
143
|
+
return if file_tasks.length == 0
|
144
|
+
|
145
|
+
@error_strings = {}
|
146
|
+
|
147
|
+
Jobs.new(file_tasks, application.max_parallel_tasks) do |jobs|
|
148
|
+
handle_jobs(jobs, args, invocation_chain)
|
149
|
+
end.join
|
150
|
+
|
151
|
+
# can only happen in case of bail_on_first_error.
|
152
|
+
# if not sorted, it may be confusing when builing more than once and the order of the error appearances changes from build to build
|
153
|
+
# (it is not deterministic which file compilation finishes first)
|
154
|
+
@error_strings.sort.each {|es| puts es[1]}
|
155
|
+
|
156
|
+
if Rake.application.check_unnecessary_includes
|
157
|
+
if not @failure # otherwise the dependency files might be incorrect or not complete
|
158
|
+
@bb.incArray.each do |i|
|
159
|
+
next if i=="."
|
160
|
+
if not @bb.deps_in_depFiles.any? { |d| d.index(i) == 0 }
|
161
|
+
msg = "Info: Include to #{i} seems to be unnecessary"
|
162
|
+
Cxxproject::Printer.printInfo msg
|
163
|
+
res = Cxxproject::ErrorDesc.new
|
164
|
+
res.file_name = @project_dir
|
165
|
+
res.line_number = 0
|
166
|
+
res.severity = Cxxproject::ErrorParser::SEVERITY_INFO
|
167
|
+
res.message = msg
|
168
|
+
Rake.application.idei.set_errors([res])
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
end
|
175
|
+
|
176
|
+
|
177
|
+
end
|
178
|
+
|
179
|
+
def handle_jobs(jobs, args, invocation_chain)
|
180
|
+
while true do
|
181
|
+
job = jobs.get_next_or_nil
|
182
|
+
break unless job
|
183
|
+
|
184
|
+
prereq = application[job]
|
185
|
+
prereq.output_after_execute = false
|
186
|
+
prereq.invoke_with_call_chain(args, invocation_chain)
|
187
|
+
set_failed if prereq.failure
|
188
|
+
output(prereq, prereq.output_string)
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
def output(prereq, to_output)
|
193
|
+
return if Rake::Task.output_disabled
|
194
|
+
return unless output_after_execute
|
195
|
+
|
196
|
+
mutex.synchronize do
|
197
|
+
if to_output and to_output.length > 0
|
198
|
+
if Rake::Task.bail_on_first_error and prereq and prereq.failure
|
199
|
+
@error_strings[prereq.name] = to_output
|
200
|
+
else
|
201
|
+
puts to_output
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
def mutex
|
208
|
+
@mutex ||= Mutex.new
|
209
|
+
end
|
210
|
+
|
211
|
+
end
|
212
|
+
|
213
|
+
class Task
|
214
|
+
class << self
|
215
|
+
attr_accessor :bail_on_first_error
|
216
|
+
attr_accessor :output_disabled
|
217
|
+
end
|
218
|
+
|
219
|
+
attr_accessor :failure # specified if that task has failed
|
220
|
+
attr_accessor :deps # used to store deps by depfile task for the apply task (no re-read of depsfile)
|
221
|
+
attr_accessor :type
|
222
|
+
attr_accessor :transparent_timestamp
|
223
|
+
attr_accessor :progress_count
|
224
|
+
attr_accessor :output_string
|
225
|
+
attr_accessor :output_after_execute
|
226
|
+
attr_accessor :immediate_output
|
227
|
+
attr_accessor :prerequisites
|
228
|
+
|
229
|
+
UNKNOWN = 0x0000 #
|
230
|
+
OBJECT = 0x0001 #
|
231
|
+
SOURCEMULTI = 0x0002 # x
|
232
|
+
DEPFILE = 0x0004 #
|
233
|
+
LIBRARY = 0x0008 # x
|
234
|
+
EXECUTABLE = 0x0010 # x
|
235
|
+
CONFIG = 0x0020 #
|
236
|
+
APPLY = 0x0040 #
|
237
|
+
UTIL = 0x0080 #
|
238
|
+
BINARY = 0x0100 # x
|
239
|
+
MODULE = 0x0200 # x
|
240
|
+
MAKE = 0x0400 # x
|
241
|
+
RUN = 0x0800 #
|
242
|
+
CUSTOM = 0x1000 # x
|
243
|
+
COMMANDLINE = 0x2000 # x
|
244
|
+
|
245
|
+
STANDARD = 0x371A # x above means included in STANDARD
|
246
|
+
attr_reader :ignore
|
247
|
+
execute_org = self.instance_method(:execute)
|
248
|
+
initialize_org = self.instance_method(:initialize)
|
249
|
+
timestamp_org = self.instance_method(:timestamp)
|
250
|
+
invoke_prerequisites_org = self.instance_method(:invoke_prerequisites)
|
251
|
+
invoke_org = self.instance_method(:invoke)
|
252
|
+
|
253
|
+
define_method(:initialize) do |task_name, app|
|
254
|
+
initialize_org.bind(self).call(task_name, app)
|
255
|
+
@type = UNKNOWN
|
256
|
+
@deps = nil
|
257
|
+
@transparent_timestamp = false
|
258
|
+
@progress_count = 0
|
259
|
+
@ignore = false
|
260
|
+
@failure = false
|
261
|
+
@output_after_execute = true
|
262
|
+
@immediate_output = false
|
263
|
+
end
|
264
|
+
|
265
|
+
define_method(:invoke) do |*args|
|
266
|
+
Cxxproject::ExitHelper.set_exit_code(0)
|
267
|
+
invoke_org.bind(self).call(*args)
|
268
|
+
if @failure or Rake.application.idei.get_abort
|
269
|
+
Cxxproject::ExitHelper.set_exit_code(1)
|
270
|
+
end
|
271
|
+
end
|
272
|
+
|
273
|
+
define_method(:invoke_prerequisites) do |task_args, invocation_chain|
|
274
|
+
new_invoke_prerequisites(task_args, invocation_chain)
|
275
|
+
end
|
276
|
+
|
277
|
+
def new_invoke_prerequisites(task_args, invocation_chain)
|
278
|
+
orgLength = 0
|
279
|
+
while @prerequisites.length > orgLength do
|
280
|
+
orgLength = @prerequisites.length
|
281
|
+
|
282
|
+
@prerequisites.dup.each do |n| # dup needed when apply tasks changes that array
|
283
|
+
break if Rake.application.idei.get_abort
|
284
|
+
#break if @failure
|
285
|
+
|
286
|
+
prereq = nil
|
287
|
+
begin
|
288
|
+
prereq = application[n, @scope]
|
289
|
+
prereq_args = task_args.new_scope(prereq.arg_names)
|
290
|
+
prereq.invoke_with_call_chain(prereq_args, invocation_chain)
|
291
|
+
set_failed if prereq.failure
|
292
|
+
rescue Cxxproject::ExitHelperException
|
293
|
+
raise
|
294
|
+
rescue Exception => e
|
295
|
+
if prereq and Rake::Task[n].ignore
|
296
|
+
@prerequisites.delete(n)
|
297
|
+
def self.needed?
|
298
|
+
true
|
299
|
+
end
|
300
|
+
return
|
301
|
+
end
|
302
|
+
Cxxproject::Printer.printError "Error #{name}: #{e.message}"
|
303
|
+
if RakeFileUtils.verbose
|
304
|
+
puts e.backtrace
|
305
|
+
end
|
306
|
+
set_failed
|
307
|
+
if e.message.include?"Circular dependency detected"
|
308
|
+
Rake.application.idei.set_abort(true)
|
309
|
+
end
|
310
|
+
end
|
311
|
+
|
312
|
+
end
|
313
|
+
end
|
314
|
+
end
|
315
|
+
|
316
|
+
def set_failed()
|
317
|
+
@failure = true
|
318
|
+
if Rake::Task.bail_on_first_error
|
319
|
+
Rake.application.idei.set_abort(true)
|
320
|
+
end
|
321
|
+
end
|
322
|
+
|
323
|
+
define_method(:execute) do |arg|
|
324
|
+
|
325
|
+
if Rake::application.preproFlags
|
326
|
+
if self.type == SOURCEMULTI
|
327
|
+
@failure = true
|
328
|
+
break
|
329
|
+
end
|
330
|
+
end
|
331
|
+
|
332
|
+
break if @failure # check if a prereq has failed
|
333
|
+
break if Rake.application.idei.get_abort
|
334
|
+
new_execute(execute_org, arg)
|
335
|
+
end
|
336
|
+
|
337
|
+
def new_execute(execute_org, arg)
|
338
|
+
if not @immediate_output
|
339
|
+
s = name == 'console' ? nil : StringIO.new
|
340
|
+
tmp = Thread.current[:stdout]
|
341
|
+
Thread.current[:stdout] = s unless tmp
|
342
|
+
end
|
343
|
+
|
344
|
+
begin
|
345
|
+
execute_org.bind(self).call(arg)
|
346
|
+
rescue Cxxproject::ExitHelperException
|
347
|
+
raise
|
348
|
+
rescue Cxxproject::SystemCommandFailed => scf
|
349
|
+
handle_error(scf, true)
|
350
|
+
rescue SystemExit => exSys
|
351
|
+
Rake.application.idei.set_abort(true)
|
352
|
+
rescue Exception => ex1
|
353
|
+
handle_error(ex1, false)
|
354
|
+
end
|
355
|
+
|
356
|
+
if not @immediate_output
|
357
|
+
self.output_string = s.string
|
358
|
+
Thread.current[:stdout] = tmp
|
359
|
+
output(nil, self.output_string)
|
360
|
+
end
|
361
|
+
end
|
362
|
+
|
363
|
+
def handle_error(ex1, isSysCmd)
|
364
|
+
if not Rake.application.idei.get_abort()
|
365
|
+
if not isSysCmd
|
366
|
+
Cxxproject::Printer.printError "Error for task #{@name}: #{ex1.message}"
|
367
|
+
end
|
368
|
+
end
|
369
|
+
begin
|
370
|
+
FileUtils.rm(@name) if File.exists?(@name)
|
371
|
+
rescue Exception => ex2
|
372
|
+
Cxxproject::Printer.printError "Error: Could not delete #{@name}: #{ex2.message}"
|
373
|
+
end
|
374
|
+
set_failed
|
375
|
+
end
|
376
|
+
|
377
|
+
def output(name, to_output)
|
378
|
+
return if Rake::Task.output_disabled
|
379
|
+
return unless output_after_execute
|
380
|
+
|
381
|
+
if to_output and to_output.length > 0
|
382
|
+
puts to_output
|
383
|
+
end
|
384
|
+
end
|
385
|
+
|
386
|
+
reenable_org = self.instance_method(:reenable)
|
387
|
+
define_method(:reenable) do
|
388
|
+
reenable_org.bind(self).call
|
389
|
+
@failure = false
|
390
|
+
end
|
391
|
+
|
392
|
+
define_method(:timestamp) do
|
393
|
+
if @transparent_timestamp
|
394
|
+
ts = Rake::EARLY
|
395
|
+
@prerequisites.each do |pre|
|
396
|
+
prereq_timestamp = Rake.application[pre].timestamp
|
397
|
+
ts = prereq_timestamp if prereq_timestamp > ts
|
398
|
+
end
|
399
|
+
else
|
400
|
+
ts = timestamp_org.bind(self).call()
|
401
|
+
end
|
402
|
+
ts
|
403
|
+
end
|
404
|
+
|
405
|
+
def ignore_missing_file
|
406
|
+
@ignore = true
|
407
|
+
end
|
408
|
+
|
409
|
+
def visit(&block)
|
410
|
+
if block.call(self)
|
411
|
+
prerequisite_tasks.each do |t|
|
412
|
+
t.visit(&block)
|
413
|
+
end
|
414
|
+
end
|
415
|
+
end
|
416
|
+
|
417
|
+
end
|
418
|
+
|
419
|
+
end
|