Class: MRuby::Command::Mrbc

Inherits:
MRuby::Command show all
Defined in:
ext/enterprise_script_service/mruby/lib/mruby/build/command.rb

Constant Summary

Constants inherited from MRuby::Command

NotFoundCommands

Instance Attribute Summary collapse

Attributes inherited from MRuby::Command

#build, #command

Instance Method Summary collapse

Methods inherited from MRuby::Command

#clone, #shellquote

Constructor Details

#initialize(build) ⇒ Mrbc



307
308
309
310
311
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 307

def initialize(build)
  super
  @command = nil
  @compile_options = "-B%{funcname} -o-"
end

Instance Attribute Details

#compile_optionsObject

Returns the value of attribute compile_options.



305
306
307
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 305

def compile_options
  @compile_options
end

Instance Method Details

#run(out, infiles, funcname) ⇒ Object



313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 313

def run(out, infiles, funcname)
  @command ||= @build.mrbcfile
  infiles = [infiles].flatten
  infiles.each do |f|
    _pp "MRBC", f.relative_path, nil, :indent => 2
  end
  cmd = %Q["#{filename @command}" #{@compile_options % {:funcname => funcname}} #{filename(infiles).map{|f| %Q["#{f}"]}.join(' ')}]
  puts cmd if Rake.verbose
  IO.popen(cmd, 'r+') do |io|
    out.puts io.read
  end
  # if mrbc execution fail, drop the file
  if $?.exitstatus != 0
    File.delete(out.path)
    exit(-1)
  end
end