Class: Buildr::AS3::Toolkits::Compiler::AlcGcc

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

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Instance Attribute Details

- (Object) project (readonly)

Returns the value of attribute project



98
99
100
# File 'lib/buildr/as3/toolkits/alchemy.rb', line 98

def project
  @project
end

Instance Method Details

- (Object) compile(sources, target, dependencies)



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/buildr/as3/toolkits/alchemy.rb', line 106

def compile(sources, target, dependencies)
  alchemy_tk = options[:alchemy].invoke
  flex_sdk = alchemy_tk.flex_sdk
  output = @project.get_as3_output

  cmd_args = []
  cmd_args << "gcc"
  cmd_args << File.basename(options[:main])
  cmd_args << "-O3 -Wall -swc"
  cmd_args << "-o #{File.basename output}"

  reserved = [:flexsdk, :main, :alchemy]
  options.to_hash.reject { |key, value| reserved.include?(key) }.
      each do |key, value|
    cmd_args << "-#{key}=#{value}"
  end

  unless Buildr.application.options.dryrun
    ENV["ALCHEMY_HOME"]= alchemy_tk.home
    ENV["ALCHEMY_VER"] = "0.4a"
    ENV["PATH"] = "#{alchemy_tk.bin}#{File::PATH_SEPARATOR}#{ENV["PATH"]}"
    ENV["ASC"]="#{alchemy_tk.home}/bin/asc.jar"
    ENV["ADL"]=alchemy_tk.flex_sdk.adl
    ENV["SWFBRIDGE"]=alchemy_tk.swfbridge
    ENV["PATH"] = "#{alchemy_tk.achacks}#{File::PATH_SEPARATOR}#{ENV["PATH"]}"
    ENV["PATH"] = "#{ENV["PATH"]}:#{flex_sdk.bin}"
    project_dir = Dir.getwd
    Dir.chdir File.dirname options[:main]
    system(cmd_args.join(" "))
    File.copy(File.basename(output), output)
    File.delete File.basename(output)
    Dir.chdir project_dir
  end
end

- (Boolean) needed?(sources, target, dependencies)

Returns:

  • (Boolean)


100
101
102
103
104
# File 'lib/buildr/as3/toolkits/alchemy.rb', line 100

def needed?(sources, target, dependencies)
  return true unless File.exist?(@project.get_as3_output)
  Dir.glob(FileList[sources,dependencies].to_a.collect{ |file| file += "**/*" } ).
      map{|file| File.stat(file).mtime}.max > File.stat(@project.get_as3_output).mtime
end