require File.dirname(__FILE__) + '/remote_file_task' module AsProject class MTASCError < StandardError; end class MTASC < RemoteFileTask attr_accessor :name, :version, :compiler_version, :main, :header, :frame, :verbose, :mx, :input, :input_swf, :class_path, :output def initialize(name=:compile, do_not_define=false) @compiler_version = '1.13' @options = [] @class_path = [] @user_task = nil @win_url = "http://www.mtasc.org/zip/mtasc-#{compiler_version}.zip" @win_extracted_file = "/mtasc-#{compiler_version}/mtasc.exe" @osx_url = "http://www.mtasc.org/zip/mtasc-#{compiler_version}.dmg" @osx_extracted_file = "/mtasc-#{compiler_version}/mtasc.app" @unix_url = "http://www.mtasc.org/zip/mtasc-#{compiler_version}.tar.gz" @unix_extracted_file = "/mtasc-#{compiler_version}/mtasc" super(name, true) define unless do_not_define end def remote_task_name return "mtasc-#{compiler_version}" end def compile_task_desc return "Compile #{name} using MTASC" end # Create the tasks defined by this task lib. def define super # if(!input_swf && !header && pack_path.size == 0) # raise MTASCError.new('MTASC task must be provided with an input_swf, a header argument, or at least one pack_path') # end # if(header && !input_swf && output) # raise MTASCError.new('It looks like you used the output parameter where you should have used the swf parameter') # end desc compile_task_desc task name => [output] CLEAN.add(output) if(input_swf) file input_swf task name => [input_swf] end @cleaned_class_paths = [] class_path.each do |path| add_path(path, @cleaned_class_paths) end file output do |f| user_task.execute(option_list.join(' ')) end self end def recurse_exclude_path(dir) paths = [dir] Dir[dir + '/*'].each do |f| if(File.directory?(f)) paths << recurse_exclude_path(f) end end return paths end def add_path(path, list) as_files = FileList[path + '/**/**/*.as'] file as_files file output => as_files xml_files = FileList[path + '/**/**/*.xml'] file xml_files file output => xml_files list << clean_path(path) end def option_list result = @options.dup result << "-header" << header if header result << "-mx" if mx result << "-v" if verbose result << "-frame" << frame if frame result << "-cp " + @cleaned_class_paths.join(" -cp ") if class_path.size > 0 result << "-swf" << clean_path(input_swf) if input_swf result << "-out" << clean_path(output) if output result << "-main" if main result << clean_path(input) if input return result end end end