Skip to content

Instantly share code, notes, and snippets.

@duckinator
Created November 23, 2009 23:16
Show Gist options
  • Save duckinator/241474 to your computer and use it in GitHub Desktop.
Save duckinator/241474 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'shell'
def err(s)
puts s
exit 1
end
err "Usage: ./build APP_NAME" if !ARGV[0]
shell = Shell.new
app = ARGV[0]
dir = "/home/#{ENV['USER']}/dev/asm/#{app}"
err "Directory does not exist: #{dir}" if !File.exist? (dir)
err "Not a directory: #{dir}" if !File.directory? (dir)
if IO.readlines("#{dir}/#{app}.s")[0] =~ /;32/
bits = 32
else
bits = 64
end
shell.transact {
shell.cd(dir)
shell.system("nasm -felf#{bits} #{app}.s -o #{app}.o")
shell.system("ld -melf_i386 #{app}.o -o #{app}")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment