class DakeProtocol::AWK

Constants

EXT_NAME

Public Instance Methods

execute_step(log=false) click to toggle source
# File lib/dake/protocol.rb, line 51
def execute_step(log=false)
  if @step.targets.size != 1 or (!@step.targets[0].tag and not @step.targets[0].scheme.is_a? DakeScheme::Local)
    raise "awk step should have only one local output file or tag."
  end
  inputs = @step.prerequisites.reject { |target| target.tag }
  infile = inputs.map do |input|
    raise "awk step should have only local input files." unless input.scheme.is_a? DakeScheme::Local
    input.scheme.path
  end.join(' ')
  file = create_script
  if @step.targets[0].tag
    if log
      ret = system(@step.context, "awk -f #{file.path} #{infile} " +
                   "2> #{@script_stderr} 1> #{@script_stdout}", :chdir=>@step.context['BASE'])
    else
      ret = system(@step.context, "awk -f #{file.path} #{infile}", :chdir=>@step.context['BASE'])
    end
  else
    if log
      ret = system(@step.context, "awk -f #{file.path} #{infile} " +
                   "2> #{@script_stderr} 1> #{@step.targets[0].path}", :chdir=>@step.context['BASE'])
    else
      ret = system(@step.context, "awk -f #{file.path} #{infile}", :chdir=>@step.context['BASE'])
    end
  end
  unless ret
    line, column = @analyzer.step_line_and_column @step
    raise "Step(#{@step.object_id}) defined in #{@step.src_file} at #{line}:#{column} failed."
  end
end