Skip to content

Instantly share code, notes, and snippets.

@duckinator
Created November 15, 2009 18:26
Show Gist options
  • Save duckinator/235382 to your computer and use it in GitHub Desktop.
Save duckinator/235382 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'shell'
def err(s)
puts s
exit 1
end
shell = Shell.new
bits = 64
err "Usage: ./build APP_NAME" if !ARGV[0]
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)
bits = 32 if IO.readlines("#{dir}/#{app}.s")[0] =~ /;32/
shell.cd(dir)
shell.transact {
shell.system("nasm -felf#{bits} #{app}.s -o #{app}.o")
shell.system("ld #{app}.o -o #{app}")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment