lib/airake/commands/amxmlc.rb in airake-0.2.8 vs lib/airake/commands/amxmlc.rb in airake-0.2.9
- old
+ new
@@ -5,50 +5,58 @@
# 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_dir, :test_dir, :debug_option
+ 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_dir, :test_dir, :debug_option
+ # 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)
+ 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_option
- command << library_path_option
+ command << @path
+ command << "-source-path #{@source_paths.join(" ")}"
+ command << "-library-path+=#{@library_path}"
command << "-output"
- command << escape(swf_path)
- command << debug_option
- command << extra_opts
+ command << escape(@swf_path)
+ command << "-debug=#{@debug}" unless @debug.nil?
+ command << @extra_opts
#command << "-disable-incremental-optimizations=true"
command << "--"
- command << escape(mxml_path)
+ command << escape(@mxml_path)
process(command)
end
protected
- def source_path_option
+ def source_paths
+ source_paths = []
# List of directories in lib/ for source_path +=
- lib_source_paths = Dir["#{lib_dir}/*"].collect { |f| escape(f) if File.directory?(f) }.compact
- lib_source_paths << escape(test_dir) if test_dir and File.directory?(test_dir)
- lib_source_paths << escape(src_dir) if src_dir and File.directory?(src_dir)
-
- source_paths ||= lib_source_paths
- source_paths.empty? ? "" : "-source-path #{source_paths.join(" ")}"
+ if @lib_dir and File.directory?(@lib_dir)
+ 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
end
- def library_path_option
- library_paths = []
- library_paths << escape(lib_dir) if lib_dir and File.directory?(lib_dir)
- library_paths.empty? ? "" : "-library-path+=#{library_paths.join(" ")}"
+ def library_path
+ escape(@lib_dir) if @lib_dir and File.directory?(@lib_dir)
end
end
end
\ No newline at end of file