class Rake::MultiTask

Public Instance Methods

handle_jobs(jobs, args, invocation_chain) click to toggle source
# File lib/cxxproject/ext/rake.rb, line 184
def handle_jobs(jobs, args, invocation_chain)
  while true do
    job = jobs.get_next_or_nil
    break unless job

    prereq = application[job]
    prereq.output_after_execute = false
    prereq.invoke_with_call_chain(args, invocation_chain)
    set_failed if prereq.failure
    output(prereq, prereq.output_string)
  end
end
invoke_prerequisites(args, invocation_chain) click to toggle source
Calls superclass method
# File lib/cxxproject/ext/rake.rb, line 114
def invoke_prerequisites(args, invocation_chain)
  super(args, invocation_chain)

  return if @failure # pre step has failed

  Dir.chdir(@bb.project_dir) do
    if Dir.pwd != @bb.project_dir and File.dirname(Dir.pwd) != File.dirname(@bb.project_dir)
      isSym = false
      begin
        isSym = File.symlink?(@bb.project_dir)
      rescue
      end
      if isSym
        message = "Symlinks only allowed with the same parent dir as the target: #{@bb.project_dir} --> #{Dir.pwd}"
        res = Cxxproject::ErrorDesc.new
        res.file_name = @bb.project_dir
        res.line_number = 0
        res.severity = Cxxproject::ErrorParser::SEVERITY_ERROR
        res.message = message
        Rake.application.idei.set_errors([res])
        Cxxproject::Printer.printError message
        set_failed
        return
      end
    end

    file_tasks = @bb.create_object_file_tasks

    if file_tasks == nil # = error
      set_failed
      return
    end

    enhance(file_tasks)
    return if file_tasks.length == 0

    @error_strings = {}

    Jobs.new(file_tasks, application.max_parallel_tasks) do |jobs|
      handle_jobs(jobs, args, invocation_chain)
    end.join

    # can only happen in case of bail_on_first_error.
    # if not sorted, it may be confusing when builing more than once and the order of the error appearances changes from build to build
    # (it is not deterministic which file compilation finishes first)
    @error_strings.sort.each {|es| puts es[1]}

    if Rake.application.check_unnecessary_includes
      if not @failure # otherwise the dependency files might be incorrect or not complete
        @bb.incArray.each do |i|
          next if i=="."
          if not @bb.deps_in_depFiles.any? { |d| d.index(i) == 0 }
            msg = "Info: Include to #{i} seems to be unnecessary"
            Cxxproject::Printer.printInfo msg
            res = Cxxproject::ErrorDesc.new
            res.file_name = @project_dir
            res.line_number = 0
            res.severity = Cxxproject::ErrorParser::SEVERITY_INFO
            res.message = msg
            Rake.application.idei.set_errors([res])
          end
        end
      end
    end

  end


end
mutex() click to toggle source
# File lib/cxxproject/ext/rake.rb, line 212
def mutex
  @mutex ||= Mutex.new
end
output(prereq, to_output) click to toggle source
# File lib/cxxproject/ext/rake.rb, line 197
def output(prereq, to_output)
  return if Rake::Task.output_disabled
  return unless output_after_execute

  mutex.synchronize do
    if to_output and to_output.length > 0
      if Rake::Task.bail_on_first_error and prereq and prereq.failure
        @error_strings[prereq.name] = to_output
      else
        puts to_output
      end
    end
  end
end
set_building_block(bb) click to toggle source
# File lib/cxxproject/ext/rake.rb, line 110
def set_building_block(bb)
  @bb = bb
end