Skip to content

Instantly share code, notes, and snippets.

@lemieuxster
Created July 18, 2012 16:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lemieuxster/3137383 to your computer and use it in GitHub Desktop.
Save lemieuxster/3137383 to your computer and use it in GitHub Desktop.
MXMLC Interface in Ruby
#For compiling swfs using MXMLC, tooled to fit Flite build needs.
class MXMLCInterface
MXMLC = ENV["FLEX_HOME"] ? File.join(ENV["FLEX_HOME"], "bin/mxmlx") : "./bin/mxmlc"
FLEX_CONFIG = ENV["FLEX_CONFIG"] || "./"
@@mxmlc = MXMLC
def self.mxmlc= (value)
@@mxmlc = value
end
@@flex_config = FLEX_CONFIG
def self.flex_config= (value)
@@flex_config = value
end
@@source_path = "./"
def self.source_path= (value)
@@source_path = value
end
def self.compile (input, output, debug = false, authoring = false, ignore_warnings = false, library_paths = [], version = 0)
release = !to_boolean(debug) || !to_boolean(authoring)
#Build mxmlc command
mxmlc_command = [
"#{@@mxmlc}",
"-optimize=true",
"-compress=true",
"-compiler.as3=true",
"-compiler.incremental=true",
"-compiler.source-path=#{@@source_path}",
"-compiler.show-actionscript-warnings=#{!ignore_warnings}",
"-static-link-runtime-shared-libraries=true",
"-load-config=#{@@flex_config}",
"-debug=#{debug}",
"-define=CONFIG::FLASH_AUTHORING,#{authoring}",
"-define=CONFIG::DEBUG,#{debug}",
"-define=CONFIG::IS_RELEASE,#{release}",
"-define=CONFIG::VERSION,#{version}",
"#{library_paths.join(" ")}",
"-o #{output} #{input}"
].join(" ")
#Run command
output = `#{mxmlc_command}`
output.each_line {|line| print " #{line}"}
#Return success of command
$?.success?
end
def self.to_boolean(str)
str == true || str =~ (/(true|t|yes|y|1)$/i)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment