Sha256: 8554d31865bc72c360d3a62772cabd4dfa6c60bf6aa4bb71249aeaf7e06bb8ce
Contents?: true
Size: 1.23 KB
Versions: 1
Compression:
Stored size: 1.23 KB
Contents
#!/usr/bin/env ruby require 'mruby_tools' # args like: file1.rb file2.rb -o outfile # possibly: file1.rb -o outfile file2.rb -c generated.c opts = MRubyTools::CLI.args(ARGV) MRubyTools::CLI.usage if opts[:help] FAIL_MRUBY_NOT_FOUND = 1 FAIL_MRBC_BYTECODE = 1 FAIL_GCC = 1 mrb = MRubyTools.new(opts[:mruby_dir]) # nil is fine begin mrb.validate! rescue MRubyTools::MRubyNotFound => e warn "#{e.class}: can't find #{e}" exit FAIL_MRUBY_NOT_FOUND end rb_files = opts.fetch(:rb_files) MRubyTools::CLI.usage("no .rb files provided") if rb_files.empty? # inject a string vs create and inject bytecode if opts[:bytecode] bc_file = 'bytecode.mrb' puts "creating #{bc_file}..." if mrb.mrbc rb_files, bc_file c_code = MRubyTools::C.bytecode_wrapper(bc_file) else warn "FATAL: mrbc bytecode generation failed" exit FAIL_MRBC_BYTECODE end else c_code = MRubyTools::C.wrapper(rb_files) end puts c_code + "\n" if opts[:verbose] c_file = opts.fetch(:c_file) c_file.write(c_code) c_file.close puts "generated #{c_file.path}" if opts[:verbose] out_file = opts.fetch(:out_file) puts "compiling..." if mrb.compile(c_file.path, out_file) puts "created binary executable: #{out_file}" else warn "FATAL: compile failed" exit FAIL_GCC end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mruby_tools-0.0.4.1 | bin/mrbt |