#!/usr/bin/env jruby ENV['APP_ROOT'] ||= File.expand_path(Dir.pwd) ENV['JAVA_ROOT'] = File.join(ENV['APP_ROOT'],'java','project') ENV['GAME_ENV'] = 'development' require 'rubygems' require 'fileutils' def load_game_machine begin require 'game_machine' rescue LoadError require_relative '../lib/game_machine' end end def load_config require_relative '../lib/game_machine/app_config' GameMachine::AppConfig.instance.load_config end ARGV << '--help' if ARGV.empty? aliases = { "b" => "build", "s" => "server" } command = ARGV.shift command = aliases[command] || command require_relative '../lib/game_machine/console' if command == 'install' || command == 'upgrade' bin_path = File.dirname(__FILE__) install_source_path = File.expand_path( File.join(bin_path,'../') ) GameMachine::Console::Install.new(command,ARGV,install_source_path).run! elsif command == 'build' || command == 'bundle' require_relative '../java/project/local_lib/protostuff-compiler-1.0.8-jarjar.jar' require_relative '../lib/game_machine/protobuf/game_messages.rb' require_relative '../lib/game_machine/protobuf/generate.rb' if command == 'bundle' GameMachine::Console::Build.new(ARGV,true).run! else GameMachine::Console::Build.new(ARGV).run! end elsif command == 'server' # Need to set environment vars before loading everything. server = GameMachine::Console::Server.new(ARGV) server.set_environment load_game_machine # Run the server server.run! else puts <