Class: Rake::MultiTask

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

Overview

  • Limit parallel tasks

Constant Summary

Constants inherited from Task

Task::APPLY, Task::BINARY, Task::COMMANDLINE, Task::CONFIG, Task::CUSTOM, Task::DEPFILE, Task::EXECUTABLE, Task::LIBRARY, Task::MAKE, Task::MODULE, Task::OBJECT, Task::RUN, Task::SHARED_LIBRARY, Task::SOURCEMULTI, Task::STANDARD, Task::UNKNOWN, Task::UTIL

Instance Attribute Summary

Attributes inherited from Task

#deps, #failure, #ignore, #immediate_output, #output_after_execute, #output_string, #prerequisites, #tags, #transparent_timestamp, #type

Instance Method Summary collapse

Methods inherited from Task

bail_on_first_error, bail_on_first_error=, #calc_dirty_for_prerequsites, #dirty?, #handle_error, #ignore_missing_file, #new_execute, #new_invoke_prerequisites, #set_failed, #visit

Instance Method Details

#handle_jobs(jobs, args, invocation_chain) ⇒ Object



184
185
186
187
188
189
190
191
192
193
194
195
# 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) ⇒ Object



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
# 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

#mutexObject



212
213
214
# File 'lib/cxxproject/ext/rake.rb', line 212

def mutex
  @mutex ||= Mutex.new
end

#output(prereq, to_output) ⇒ Object



197
198
199
200
201
202
203
204
205
206
207
208
209
210
# 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) ⇒ Object



110
111
112
# File 'lib/cxxproject/ext/rake.rb', line 110

def set_building_block(bb)
  @bb = bb
end