Created
July 18, 2012 16:46
-
-
Save lemieuxster/3137383 to your computer and use it in GitHub Desktop.
MXMLC Interface in Ruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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