Skip to content

Instantly share code, notes, and snippets.

@leandrosilva
Created July 16, 2010 18:53
Show Gist options
  • Select an option

  • Save leandrosilva/16a7095d8437b490b99e to your computer and use it in GitHub Desktop.

Select an option

Save leandrosilva/16a7095d8437b490b99e to your computer and use it in GitHub Desktop.
A little sugar to use Mono C# 4.0 compiler
#!/usr/bin/env ruby
#
# A little sugar to use Mono C# 4.0 compiler.
#
# Author: Leandro Silva
# . leandrodoze@gmail.com
# . http://leandrosilva.com.br
# . @codezone
#
require 'optparse'
target = 'exe'
target_ext = 'exe'
src_file = nil
out_file = nil
OptionParser.new do |opts|
opts.banner = "Usage: ./compile [options]"
opts.on("-e", "--exe", "Specifies the format of the output assembly to be 'exe'") do |v|
target = 'exe'
target_ext = 'exe'
end
opts.on("-l", "--library", "Specifies the format of the output assembly to be 'library'") do |v|
target = 'library'
target_ext = 'dll'
end
opts.on("-s [FILE]", "--src", "Specifies the file to be compiled") do |s|
src_file = s
out_file = File.basename(src_file, '.cs')
end
end.parse!
command = "dmcs -target:#{target} #{src_file} -out:bin/#{out_file}.#{target_ext}"
puts 'Compiling:'
puts " $ #{command}"
system command
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment