Sha256: fe32898c8fdd65fa33ea65d7d941e41cc5198c81597a5022cf3e84a758189650

Contents?: true

Size: 1.01 KB

Versions: 2

Compression:

Stored size: 1.01 KB

Contents

#!/usr/bin/env ruby

BIN_NAME    = File.basename(__FILE__)
BIN_PATH    = File.dirname(__FILE__)
BIN         = File.join( File.expand_path("../ext/mtl", BIN_PATH), BIN_NAME)
FILE        = ARGV.first

FILTER      = ENV['FILTER'] || "| grep -v 'bytes' | grep -e'[a-z]'"
MERGE       = File.join(BIN_PATH, 'mtl_merge')
TMP         = ENV['TMP'] || '.tmp.mtl'
OUT         = ENV['OUT'] || "bytecode.bin"

HOST        = ENV['HOST']
REMOTE_PATH = ENV['REMOTE'] || "~/"
REMOTE_BIN  = ENV['REMOTE_BIN']

unless FILE
  puts "usage: #{File.basename(__FILE__)} [filename]"
  abort
end

# merge
`TMP='#{TMP}' #{MERGE} #{FILE}`

# compile
out = nil
if File.exists?(BIN)
  out = `#{BIN} -s #{FILE} #{OUT} 2>&1 #{FILTER}`
else
  print "local binary not found"
end

if HOST
  puts " - falling back to remote"
  `scp #{TMP} #{HOST}:#{REMOTE_PATH}#{TMP}`
  out = `ssh #{HOST} "cd #{REMOTE_PATH} && rm -f #{TMP}.bin && #{REMOTE_BIN}#{BIN_NAME} -s #{TMP} #{TMP}.bin 2>&1 #{FILTER}"`
  `scp #{HOST}:#{REMOTE_PATH}#{TMP}.bin #{OUT}`
end

puts out
`rm #{TMP}`

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
nabaztag_hack_kit-0.0.3 bin/mtl_comp
nabaztag_hack_kit-0.0.2 bin/mtl_comp