cxxproject 0.5.48 → 0.5.59

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