module AsProject class MXMLC < EnvTask attr_accessor :accessible, :debug, :external_library_path, :default_frame_rate, :default_background_color, :default_script_limits, :default_size, :frames, :incremental, :library_path, :link_report, :load_externs, :locale, :optimize, :show_actionscript_warnings, :source_path, :theme, :runtime_shared_libraries, :output, :use_network, :warnings, :input def initialize(name=:mxmlc) @options = [] @source_path = [] @external_library_path = [] @frames = [] @library_path = [] @theme = [] @runtime_shared_libraries = [] @incremental = false @target = 'mxmlc' @name = name yield self if block_given? define end def define @external_library_path = add_path_list(@external_library_path) if @external_library_path.size > 0 @library_path = add_path_list(@library_path) if @library_path.size > 0 @source_path = add_path_list(@source_path) if @source_path.size > 0 @theme.collect do |item| file item file @output => item end if(!@input.nil?) add_path(File.dirname(@input)) end file @output do |t| execute(@target, option_list.join(' ')) end CLEAN.add(@output) if(@incremental) CLEAN.add(FileList['**/**/*.cache']) end desc "Compile #{@name} using MXMLC" task @name => [@output] end def execute(cmd, args) sh(%{#{cmd} #{args}}) end def sp return @source_path end def el return @external_library_path end def rsl return @runtime_shared_libraries end def l return @library_path end def option_list result = @options.dup result << "-accessible" if accessible result << "-debug" if debug result << "-optimize" if optimize result << "-warnings" if warnings result << "-use-network" if use_network result << "-show-actionscript-warnings" if show_actionscript_warnings result << "-locale" << locale if locale result << "-default-frame-rate" << default_frame_rate if default_frame_rate result << "-default-background-color" << default_background_color if default_background_color result << "-default-script-limits" << default_script_limits if default_script_limits result << "-default-size" << default_size if default_size result << "-load-externs" << load_externs if load_externs result << "-link-report" << link_report if link_report result << "-output" << clean_path(output) if output result << "-theme " + theme.join(" -theme ") if theme.size > 0 result << "-frame " + frames.join(" -frame ") if frames.size > 0 result << "-rsl=" + runtime_shared_libraries.join(" -rsl=") if runtime_shared_libraries.size > 0 result << "-el+=" + external_library_path.join(" -el+=") if external_library_path.size > 0 result << "-l=" + library_path.join(" -l=") if library_path.size > 0 result << "-sp=" + source_path.join(" -sp=") if source_path.size > 0 result << "-incremental" if incremental result << clean_path(input) return result end def add_path_list(list) list.collect do |path| add_path(path) clean_path(path) end end def add_path(path) input_files = FileList[File.dirname(path) + '/**/*.as'] file input_files file @output => input_files end def clean_path(path) if(!path.index(' ').nil?) path = %{"#{path}"} end return path end end end