Class: Rake::Task

Inherits:
Object
  • Object
show all
Defined in:
lib/cxxproject/ext/rake.rb,
lib/cxxproject/ext/rake_dirty.rb

Direct Known Subclasses

MultiTask

Constant Summary collapse

UNKNOWN =
0x0000
OBJECT =
0x0001
SOURCEMULTI =

x

0x0002
DEPFILE =
0x0004
LIBRARY =

x

0x0008
EXECUTABLE =

x

0x0010
CONFIG =
0x0020
APPLY =
0x0040
UTIL =
0x0080
BINARY =

x

0x0100
MODULE =

x

0x0200
MAKE =

x

0x0400
RUN =
0x0800
CUSTOM =

x

0x1000
COMMANDLINE =

x

0x2000
SHARED_LIBRARY =

x

0x4000
STANDARD =

x above means included in STANDARD

0x371A
@@bail_on_first_error =
true

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.output_disabledObject

Returns the value of attribute output_disabled.



227
228
229
# File 'lib/cxxproject/ext/rake.rb', line 227

def output_disabled
  @output_disabled
end

Instance Attribute Details

#depsObject

used to store deps by depfile task for the apply task (no re-read of depsfile)



231
232
233
# File 'lib/cxxproject/ext/rake.rb', line 231

def deps
  @deps
end

#failureObject

specified if that task has failed



230
231
232
# File 'lib/cxxproject/ext/rake.rb', line 230

def failure
  @failure
end

#ignoreObject (readonly)

Returns the value of attribute ignore.



262
263
264
# File 'lib/cxxproject/ext/rake.rb', line 262

def ignore
  @ignore
end

#immediate_outputObject

Returns the value of attribute immediate_output.



236
237
238
# File 'lib/cxxproject/ext/rake.rb', line 236

def immediate_output
  @immediate_output
end

#output_after_executeObject

Returns the value of attribute output_after_execute.



235
236
237
# File 'lib/cxxproject/ext/rake.rb', line 235

def output_after_execute
  @output_after_execute
end

#output_stringObject

Returns the value of attribute output_string.



234
235
236
# File 'lib/cxxproject/ext/rake.rb', line 234

def output_string
  @output_string
end

#prerequisitesObject

Returns the value of attribute prerequisites.



237
238
239
# File 'lib/cxxproject/ext/rake.rb', line 237

def prerequisites
  @prerequisites
end

#tagsObject



239
240
241
242
# File 'lib/cxxproject/ext/rake.rb', line 239

def tags
  @tags = Set.new unless @tags
  return @tags
end

#transparent_timestampObject

Returns the value of attribute transparent_timestamp.



233
234
235
# File 'lib/cxxproject/ext/rake.rb', line 233

def transparent_timestamp
  @transparent_timestamp
end

#typeObject

Returns the value of attribute type.



232
233
234
# File 'lib/cxxproject/ext/rake.rb', line 232

def type
  @type
end

Class Method Details

.bail_on_first_errorObject



220
221
222
# File 'lib/cxxproject/ext/rake.rb', line 220

def self.bail_on_first_error
  return @@bail_on_first_error
end

.bail_on_first_error=(v) ⇒ Object



223
224
225
# File 'lib/cxxproject/ext/rake.rb', line 223

def self.bail_on_first_error=(v)
  @@bail_on_first_error = v
end

Instance Method Details

#calc_dirty_for_prerequsitesObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/cxxproject/ext/rake_dirty.rb', line 14

def calc_dirty_for_prerequsites
  res = prerequisites.find do |p|
    t = Task[p]
    if t != nil
      if t.dirty?
        true
      else
        false
      end
    else
      false
    end
  end
  return res != nil
end

#dirty?Boolean

return true if this or one of the prerequisites is dirty

Returns:

  • (Boolean)


5
6
7
8
9
10
11
12
# File 'lib/cxxproject/ext/rake_dirty.rb', line 5

def dirty?
  return calc_dirty_for_prerequsites if apply?(name)

  if needed?
    return true
  end
  return calc_dirty_for_prerequsites
end

#handle_error(exception, isSysCmd) ⇒ Object



381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
# File 'lib/cxxproject/ext/rake.rb', line 381

def handle_error(exception, isSysCmd)
   if not application.raise_exceptions
      if not Rake.application.idei.get_abort()
         if not isSysCmd
            Cxxproject::Printer.printError "Error for task #{@name}: #{exception.message}"
            if Rake.application.options.trace
               exception.backtrace.each do |t|
                  Cxxproject::Printer.printError t
               end
            end
         end
      end
      begin
         FileUtils.rm(@name) if File.exists?(@name)
      rescue Exception => follow_up_exception
         Cxxproject::Printer.printError "Error: Could not delete #{@name}: #{follow_up_exception.message}"
      end
      set_failed
   else
      raise exception
   end
end

#ignore_missing_fileObject



432
433
434
# File 'lib/cxxproject/ext/rake.rb', line 432

def ignore_missing_file
  @ignore = true
end

#new_execute(execute_org, arg) ⇒ Object



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
# File 'lib/cxxproject/ext/rake.rb', line 355

def new_execute(execute_org, arg)
  if not @immediate_output
    s = name == 'console' ? nil : StringIO.new
    tmp = Thread.current[:stdout]
    Thread.current[:stdout] = s unless tmp
  end

  begin
    execute_org.bind(self).call(arg)
  rescue Cxxproject::ExitHelperException
    raise
  rescue Cxxproject::SystemCommandFailed => scf
    handle_error(scf, true)
  rescue SystemExit => exSys
    Rake.application.idei.set_abort(true)
  rescue Exception => ex1
    handle_error(ex1, false)
  end

  if not @immediate_output
    self.output_string = s.string
    Thread.current[:stdout] = tmp
    output(nil, self.output_string)
  end
end

#new_invoke_prerequisites(task_args, invocation_chain) ⇒ Object



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
321
322
323
324
325
326
327
328
329
330
331
332
# File 'lib/cxxproject/ext/rake.rb', line 291

def new_invoke_prerequisites(task_args, invocation_chain)
  orgLength = 0
  while @prerequisites.length > orgLength do
    orgLength = @prerequisites.length

    @prerequisites.dup.each do |n| # dup needed when apply tasks changes that array
      break if Rake.application.idei.get_abort
      #break if @failure

      prereq = nil
      begin
        prereq = application[n, @scope]
        prereq_args = task_args.new_scope(prereq.arg_names)
        prereq.invoke_with_call_chain(prereq_args, invocation_chain)
        set_failed if prereq.failure
      rescue Cxxproject::ExitHelperException
        raise
      rescue Exception => e
         if not application.raise_exceptions
            if prereq and Rake::Task[n].ignore
               @prerequisites.delete(n)
               def self.needed?
                  true
               end
               return
            end
            Cxxproject::Printer.printError "Error #{name}: #{e.message}"
            if RakeFileUtils.verbose == true
               puts e.backtrace
            end
            set_failed
            if e.message.include?('Circular dependency detected')
               Rake.application.idei.set_abort(true)
            end
         else 
            raise e
         end
      end

    end
  end
end

#output(name, to_output) ⇒ Object



404
405
406
407
408
409
410
411
# File 'lib/cxxproject/ext/rake.rb', line 404

def output(name, to_output)
  return if Rake::Task.output_disabled
  return unless output_after_execute

  if to_output and to_output.length > 0
    puts to_output
  end
end

#set_failedObject



334
335
336
337
338
339
# File 'lib/cxxproject/ext/rake.rb', line 334

def set_failed()
  @failure = true
  if Rake::Task.bail_on_first_error
    Rake.application.idei.set_abort(true)
  end
end

#visit(&block) ⇒ Object



436
437
438
439
440
441
442
# File 'lib/cxxproject/ext/rake.rb', line 436

def visit(&block)
  if block.call(self)
    prerequisite_tasks.each do |t|
      t.visit(&block)
    end
  end
end