module Airake module Commands class Amxmlc attr_reader :project, :path, :extra_opts def initialize(project, options = {}) @project = project @path = options[:amxmlc_path] || "amxmlc" @extra_opts = options[:amxmlc_extra_opts] end # Get the amxmlc command def compile command = [] command << @path #command << "+configname=air" command << source_path_option command << library_path_option command << "-output #{project.swf_path}" command << project.debug_option command << @extra_opts command << "-disable-incremental-optimizations=true" command << "-- #{project.mxml_path}" command.compact.join(" ") end protected def source_path_option # List of directories in lib/ for source_path += lib_source_paths = Dir["#{project.lib_dir}/*"].collect { |f| f if File.directory?(f) }.compact lib_source_paths << project.test_dir if File.directory?(project.test_dir) lib_source_paths << project.src_dir if File.directory?(project.src_dir) source_paths ||= lib_source_paths source_paths.empty? ? "" : "-source-path #{source_paths.join(" ")}" end def library_path_option library_paths = [] library_paths << project.lib_dir if File.directory?(project.lib_dir) library_paths.empty? ? "" : "-library-path+=#{library_paths.join(" ")}" end end end end