Permalink
Browse files

Fixing jrubyc to be callable programmatically with hand-built ARGV-st…

…yle array of parameters.

git-svn-id: http://svn.codehaus.org/jruby/trunk/jruby@5938 961051c9-f516-0410-bf72-c9f7e237a7b7
  • Loading branch information...
1 parent 114cc41 commit ba459309fff7fdd947917f2fad80ed3ecf0151aa @headius headius committed Feb 15, 2008
Showing with 34 additions and 30 deletions.
  1. +1 −29 bin/jrubyc
  2. +33 −1 lib/ruby/site_ruby/1.8/jruby/jrubyc.rb
View
@@ -2,32 +2,4 @@
require 'jruby/jrubyc'
-basedir = Dir.pwd
-prefix = "ruby"
-target = Dir.pwd
-
-opt_parser = OptionParser.new("", 24, ' ') do |opts|
- opts.banner = "jrubyc [options] (FILE|DIRECTORY)"
- opts.separator ""
-
- opts.on("-d", "--dir DIR", "Use DIR as the root of the compiled package and filename") do |dir|
- basedir = dir
- end
-
- opts.on("-p", "--prefix PREFIX", "Prepend PREFIX to the file path and package. \"ruby\" is default") do |pre|
- prefix = pre
- end
-
- opts.on("-t", "--target TARGET", "Output files to TARGET directory") do |tgt|
- target = tgt
- end
-
- opts.parse!(ARGV)
-end
-
-if (ARGV.length == 0)
- puts "No files or directories specified"
- exit 1
-end
-
-JRubyCompiler::compile_files(ARGV, basedir, prefix, target)
+JRubyCompiler::compile_argv(ARGV)
@@ -9,6 +9,38 @@ module JRubyCompiler
JavaFile = java.io.File
module_function
+ def compile_argv(argv)
+ basedir = Dir.pwd
+ prefix = "ruby"
+ target = Dir.pwd
+
+ opt_parser = OptionParser.new("", 24, ' ') do |opts|
+ opts.banner = "jrubyc [options] (FILE|DIRECTORY)"
+ opts.separator ""
+
+ opts.on("-d", "--dir DIR", "Use DIR as the root of the compiled package and filename") do |dir|
+ basedir = dir
+ end
+
+ opts.on("-p", "--prefix PREFIX", "Prepend PREFIX to the file path and package. \"ruby\" is default") do |pre|
+ prefix = pre
+ end
+
+ opts.on("-t", "--target TARGET", "Output files to TARGET directory") do |tgt|
+ target = tgt
+ end
+
+ opts.parse!(argv)
+ end
+
+ if (argv.length == 0)
+ puts "No files or directories specified"
+ exit 1
+ end
+
+ compile_files(argv, basedir, prefix, target)
+ end
+
def compile_files(filenames, basedir = Dir.pwd, prefix = "ruby", target = Dir.pwd)
runtime = JRuby.runtime
@@ -59,4 +91,4 @@ def compile_files(filenames, basedir = Dir.pwd, prefix = "ruby", target = Dir.pw
end
end
end
-end
+end

0 comments on commit ba45930

Please sign in to comment.