module Airake #:nodoc: module Commands #:nodoc: # AMXMLC (AIR MXML compiler) # # http://livedocs.adobe.com/labs/air/1/devappsflex/help.html?content=CommandLineTools_2.html#1032546 class Amxmlc < Base attr_reader :path, :extra_opts, :swf_path, :mxml_path, :lib_dir, :src_dirs, :debug # options:: :amxmlc_path, :amxmlc_extra_opts, :swf_path, :mxml_path, :lib_dir, :src_dirs, :debug def initialize(options = {}) @path = options[:amxmlc_path] || "mxmlc +configname=air" @extra_opts = options[:amxmlc_extra_opts] with_options(options) assert_required([ :path, :swf_path, :mxml_path ]) @source_paths = source_paths raise ArgumentError, "There aren't any valid source directories to compile" if @source_paths.empty? @library_path = library_path end # Get the amxmlc compile command def compile command = [] command << @path command << "-source-path #{@source_paths.join(" ")}" command << "-library-path+=#{@library_path}" command << "-output" command << escape(@swf_path) command << "-debug=#{@debug}" unless @debug.nil? command << @extra_opts #command << "-disable-incremental-optimizations=true" command << "--" command << escape(@mxml_path) process(command) end protected def source_paths source_paths = [] # List of directories in lib/ for source_path += if @lib_dir and File.directory?(@lib_dir) source_paths += Dir["#{@lib_dir}/*"].collect { |f| escape(f) if File.directory?(f) }.compact end @src_dirs.each do |src_dir| if File.directory?(src_dir) source_paths << escape(src_dir) else raise "Source directory: #{src_dir} is not a directory or does not exist" end end source_paths end def library_path escape(@lib_dir) if @lib_dir and File.directory?(@lib_dir) end end end end