Class: Buildr::AS3::Compiler::FlexCompilerBase

Inherits:
Compiler::Base
  • Object
show all
Defined in:
lib/buildr/as3/compiler/base.rb

Overview

:nodoc:

Direct Known Subclasses

Compc, Mxmlc

Constant Summary collapse

COMPILE_OPTIONS =
[:warnings, :debug, :other, :flexsdk, :apparat]

Instance Method Summary collapse

Constructor Details

#initialize(project, options) ⇒ FlexCompilerBase

:nodoc:



33
34
35
36
37
# File 'lib/buildr/as3/compiler/base.rb', line 33

def initialize(project, options) #:nodoc:
  super
  options[:debug] = Buildr.options.debug if options[:debug].nil?
  options[:warnings] ||= true
end

Instance Method Details

#compile(sources, target, dependencies) ⇒ Object

:nodoc:



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/buildr/as3/compiler/base.rb', line 39

def compile(sources, target, dependencies) #:nodoc:
  check_options options, COMPILE_OPTIONS
  flex_sdk = options[:flexsdk].invoke
  output = @project.get_as3_output( is_test(sources,target,dependencies) )
  cmd_args = []
  cmd_args << "-jar" << @compiler_jar
  cmd_args << "+flexlib" << "#{flex_sdk.home}/frameworks"
  cmd_args << "-output" << output
  cmd_args << "+configname=air" if @air
  cmd_args << @main unless @main.nil?
  cmd_args << "-define+=CONFIG::debug,#{options[:debug]}"
  cmd_args << "-define+=CONFIG::environment,\"#{Buildr.environment}\""
  cmd_args << "-load-config" << flex_sdk.flex_config unless @air
  cmd_args << "-load-config" << flex_sdk.air_config if @air
  cmd_args += generate_source_args sources
  cmd_args += generate_dependency_args dependencies
  cmd_args += flex_compiler_args
  unless Buildr.application.options.dryrun
    trace(cmd_args.join(' '))
    Java::Commands.java cmd_args
  end
end

#needed?(sources, target, dependencies) ⇒ Boolean

Returns:

  • (Boolean)


62
63
64
65
66
67
68
69
70
# File 'lib/buildr/as3/compiler/base.rb', line 62

def needed?(sources, target, dependencies)
  return true unless File.exist?(@project.get_as3_output(is_test(sources,target,dependencies)))
  source_files = Dir.glob(sources.collect{|source| source = "#{source}/**/*"})
  dep_files = dependencies.collect{ |dep|
    File.directory?(dep) ? Dir.glob("#{dep}/**/*") : dep
  }.flatten
  maxtime = (source_files + dep_files).collect{ |file| File.stat(file).mtime }.max || Time.at(0)
  maxtime > File.stat(@project.get_as3_output(is_test(sources,target,dependencies))).mtime
end