asrake 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +19 -0
- data/README.md +156 -0
- data/lib/asrake.rb +25 -0
- data/lib/asrake/adt_task.rb +146 -0
- data/lib/asrake/base_compiler_args.rb +191 -0
- data/lib/asrake/base_compiler_task.rb +74 -0
- data/lib/asrake/clean_task.rb +34 -0
- data/lib/asrake/compc_args.rb +38 -0
- data/lib/asrake/compc_task.rb +52 -0
- data/lib/asrake/copy_task.rb +87 -0
- data/lib/asrake/flexsdk.rb +81 -0
- data/lib/asrake/host.rb +46 -0
- data/lib/asrake/mxmlc_args.rb +14 -0
- data/lib/asrake/mxmlc_task.rb +37 -0
- data/lib/asrake/package_task.rb +55 -0
- data/lib/asrake/version/component.rb +90 -0
- data/lib/asrake/version/version.rb +250 -0
- data/lib/asrake/version_task.rb +90 -0
- metadata +114 -0
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'rake/tasklib'
|
2
|
+
|
3
|
+
require 'asrake/base_compiler_args'
|
4
|
+
|
5
|
+
module ASRake
|
6
|
+
class BaseCompilerTask < Rake::TaskLib
|
7
|
+
include BaseCompilerArguments_Module
|
8
|
+
|
9
|
+
def initialize(name, args)
|
10
|
+
super()
|
11
|
+
|
12
|
+
self.merge_in args if args != nil
|
13
|
+
|
14
|
+
yield self if block_given?
|
15
|
+
|
16
|
+
@name = name
|
17
|
+
|
18
|
+
# create named task first so it gets the desc if one is added
|
19
|
+
Rake::Task.define_task @name
|
20
|
+
|
21
|
+
# if the task name is a hash (ie, has dependencies defined) make sure we pull out the task name from it
|
22
|
+
@name, _ = name.first if name.is_a? Hash
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
protected
|
27
|
+
|
28
|
+
def build
|
29
|
+
fail "build must be defined in subclass"
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
# Try to include helpful information about specific errors
|
35
|
+
def generate_error_message_tips(line)
|
36
|
+
advice = []
|
37
|
+
if((target_player == nil || Float(target_player) < 11) && line.include?("Error: Access of undefined property JSON"))
|
38
|
+
advice << "Be sure you are compiling with 'target_player' set to 11.0 or higher"
|
39
|
+
advice << "to have access to the native JSON parser. It is currently set to #{target_player}"
|
40
|
+
elsif line.include?("Error: The definition of base class Object was not found")
|
41
|
+
advice << "If you have removed the default flex-config by setting 'load_config' to"
|
42
|
+
advice << "an empty or alternate value (i.e., not appended to it) you must be sure to"
|
43
|
+
advice << "still reference the necessary core Flash files, especially playerglobal.swc"
|
44
|
+
end
|
45
|
+
|
46
|
+
if !advice.empty?
|
47
|
+
puts "*********************************"
|
48
|
+
puts "ASRake Note: " + advice.join("\n")
|
49
|
+
puts "*********************************"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
##fill config with the default flex_config options
|
57
|
+
#if use_default_flex_config
|
58
|
+
# #initialize with default values from flex-config
|
59
|
+
# flex_config = Nokogiri::XML(File.read(FlexSDK::flex_config))
|
60
|
+
#
|
61
|
+
# target_player = flex_config.css('target-player').children.to_s
|
62
|
+
# swf_version = flex_config.css('swf-version').children.to_s
|
63
|
+
#
|
64
|
+
# flex_config.css('compiler external-library-path path-element').each { |ext|
|
65
|
+
# puts ext.children
|
66
|
+
# }
|
67
|
+
#end
|
68
|
+
|
69
|
+
#http://fpdownload.macromedia.com/get/flashplayer/updaters/11/playerglobal11_2.swc
|
70
|
+
#frameworks\libs\player
|
71
|
+
|
72
|
+
#-dump-config compiler_config.xml
|
73
|
+
#-link-report compiler_linkreport.xml
|
74
|
+
#-size-report compiler_sizereport.xml
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'rake/tasklib'
|
2
|
+
|
3
|
+
module ASRake
|
4
|
+
class CleanTask < Rake::TaskLib
|
5
|
+
|
6
|
+
attr_accessor :clean_list
|
7
|
+
attr_accessor :clobber_list
|
8
|
+
|
9
|
+
def initialize(*args)
|
10
|
+
|
11
|
+
self.clean_list = FileList.new
|
12
|
+
self.clobber_list = FileList.new
|
13
|
+
|
14
|
+
args.each do |configArgs|
|
15
|
+
clean_list.include(File.join(configArgs.output_dir, "*"))
|
16
|
+
clean_list.exclude(configArgs.output)
|
17
|
+
|
18
|
+
clobber_list.include(File.join(configArgs.output_dir, "*"))
|
19
|
+
end
|
20
|
+
|
21
|
+
desc "Remove package results & build artifacts"
|
22
|
+
task :clean do
|
23
|
+
clean_list.each { |f| rm_r f rescue nil }
|
24
|
+
end
|
25
|
+
|
26
|
+
desc "Remove all build & package results"
|
27
|
+
# adding clean as a dependency in case anything is added to the clean task later
|
28
|
+
task :clobber => [:clean] do
|
29
|
+
clobber_list.each { |f| rm_r f rescue nil }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'asrake/flexsdk'
|
2
|
+
require 'asrake/base_compiler_args'
|
3
|
+
|
4
|
+
module ASRake
|
5
|
+
|
6
|
+
module CompcArguments_Module
|
7
|
+
include BaseCompilerArguments_Module
|
8
|
+
|
9
|
+
def generate_args
|
10
|
+
compc = super
|
11
|
+
|
12
|
+
#compc << " -include-sources=#{cf source_path.join(',')}" if !source_path.empty?
|
13
|
+
self.source_path.each do |path|
|
14
|
+
compc << " -include-classes #{get_classes(path).join(' ')}"
|
15
|
+
end
|
16
|
+
|
17
|
+
return compc
|
18
|
+
end
|
19
|
+
|
20
|
+
def get_classes(path)
|
21
|
+
arr = []
|
22
|
+
Dir.chdir(path) do
|
23
|
+
FileList["**/*.as"].pathmap('%X').each do |file|
|
24
|
+
name = file.gsub(/^\.[\/\\]/, "").gsub(/[\/\\]/, ".")
|
25
|
+
yield name if block_given?
|
26
|
+
arr << name
|
27
|
+
end
|
28
|
+
end
|
29
|
+
return arr
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
class CompcArguments
|
35
|
+
include CompcArguments_Module
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'rake/tasklib'
|
2
|
+
|
3
|
+
require 'asrake/host'
|
4
|
+
require 'asrake/base_compiler_task'
|
5
|
+
require 'asrake/compc_args'
|
6
|
+
|
7
|
+
module ASRake
|
8
|
+
class CompcTask < BaseCompilerTask
|
9
|
+
include CompcArguments_Module
|
10
|
+
|
11
|
+
# Create a swc compilation task with the given name.
|
12
|
+
def initialize(name = :build, args = nil)
|
13
|
+
super
|
14
|
+
|
15
|
+
# create directory task for output
|
16
|
+
directory self.output_dir
|
17
|
+
|
18
|
+
# create file task for output
|
19
|
+
file self.output => self.output_dir do
|
20
|
+
self.build
|
21
|
+
end
|
22
|
+
|
23
|
+
# set dependencies on all .as and .mxml files in the source paths
|
24
|
+
dependencies = FileList.new
|
25
|
+
source_path.each do |path|
|
26
|
+
path = cf path
|
27
|
+
dependencies.include(File.join(path, "*.as"))
|
28
|
+
dependencies.include(File.join(path, "*.mxml"))
|
29
|
+
dependencies.include(File.join(path, "**", "*.as"))
|
30
|
+
dependencies.include(File.join(path, "**", "*.mxml"))
|
31
|
+
end
|
32
|
+
file(self.output => dependencies) if !dependencies.empty?
|
33
|
+
|
34
|
+
# add output file task as a dependency to the named task created
|
35
|
+
task @name => self.output do
|
36
|
+
result = c self.output
|
37
|
+
result << " (#{File.size(output)} bytes)" unless self.output_is_dir?
|
38
|
+
puts result
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
protected
|
44
|
+
|
45
|
+
def build
|
46
|
+
run "#{FlexSDK::compc}#{generate_args}" do |line|
|
47
|
+
generate_error_message_tips(line)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require 'rake/tasklib'
|
2
|
+
|
3
|
+
module ASRake
|
4
|
+
class CopyTask < Rake::TaskLib
|
5
|
+
|
6
|
+
attr_accessor :copy_list
|
7
|
+
|
8
|
+
def initialize(name = :copy)
|
9
|
+
self.copy_list = Hash.new
|
10
|
+
|
11
|
+
yield self if block_given?
|
12
|
+
|
13
|
+
#define named task first so if desc was called it will be attached to it instead of the file task
|
14
|
+
Rake::Task.define_task name do
|
15
|
+
# use longest source path to space the output. yup, seriously that OCD
|
16
|
+
len = self.copy_list.keys.group_by(&:size).max.last[0].length
|
17
|
+
self.copy_list.each do |from, to|
|
18
|
+
copy_files from, to
|
19
|
+
puts "Files copied. %#{len}s => %s" % [from, to]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def copy(from_path, to_path=nil)
|
25
|
+
if from_path == nil
|
26
|
+
fail puts "Cannot copy files. No source provided."
|
27
|
+
end
|
28
|
+
|
29
|
+
# special case getting a hash as an argument
|
30
|
+
if from_path.is_a? Hash
|
31
|
+
from_path.each {|from, to| copy from, to}
|
32
|
+
return
|
33
|
+
end
|
34
|
+
|
35
|
+
if to_path == nil
|
36
|
+
fail puts "Cannot copy files from #{from_path}. No destination provided."
|
37
|
+
end
|
38
|
+
|
39
|
+
self.copy_list[from_path] = to_path
|
40
|
+
end
|
41
|
+
alias_method :add, :copy
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def copy_files(from_path, to_path, times=0)
|
46
|
+
from = FileList[from_path]
|
47
|
+
unless from.length == 0
|
48
|
+
from.each do |from|
|
49
|
+
if File.directory?(from)
|
50
|
+
#recurse the "from" dir tree, appending the path to to_path
|
51
|
+
Dir.foreach(from) do |fr|
|
52
|
+
if fr != ".." && fr != "."
|
53
|
+
#puts fr + "|" + File.join(from, fr) + "|" + File.join(to_path, fr)
|
54
|
+
copy_files(File.join(from, fr), File.join(to_path, fr), times+1)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
else
|
58
|
+
# if this is the first iteration, we haven't gotten to join the "to" path in the directory loop above, so
|
59
|
+
# append it to the file here if either the to or from path are a directory
|
60
|
+
if times == 0 && (File.directory?(to_path) || File.directory?(from_path) || from_path =~ /\*/)
|
61
|
+
to = File.join(to_path, File.basename(from))
|
62
|
+
else
|
63
|
+
to = to_path
|
64
|
+
end
|
65
|
+
|
66
|
+
if !File.exists?(to) || (File.mtime(to.to_s) < File.mtime(from.to_s))
|
67
|
+
begin
|
68
|
+
dir = File.dirname(to)
|
69
|
+
mkdir_p(dir, :verbose => false) if !File.exist?(dir)
|
70
|
+
rescue
|
71
|
+
fail "Error copying #{from} to #{to}. Cannot create directory. #{$!}"
|
72
|
+
end
|
73
|
+
begin
|
74
|
+
cp_r from, to#, :verbose => false
|
75
|
+
rescue
|
76
|
+
fail "Error copying #{from} to #{to}. #{$!}"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
else
|
82
|
+
puts "Error copying to #{to_path}. No files exist at source #{from_path}."
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'asrake/host'
|
2
|
+
|
3
|
+
class FlexSDK
|
4
|
+
SDK_PATHS = []
|
5
|
+
|
6
|
+
class << self
|
7
|
+
|
8
|
+
@@initialized = false
|
9
|
+
|
10
|
+
@@executables = %w[adt adl asdoc mxmlc compc]
|
11
|
+
@@configs = %w[flex-config air-config]
|
12
|
+
|
13
|
+
def root
|
14
|
+
init()
|
15
|
+
return @root
|
16
|
+
end
|
17
|
+
|
18
|
+
@@configs.each do |name|
|
19
|
+
method = name.gsub('-','_')
|
20
|
+
define_method method do
|
21
|
+
init()
|
22
|
+
instance_variable_get "@#{method}"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
@@executables.each do |name|
|
27
|
+
define_method name do
|
28
|
+
init()
|
29
|
+
instance_variable_get "@#{name}"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def init()
|
36
|
+
if !@@initialized
|
37
|
+
@@root = nil
|
38
|
+
|
39
|
+
# Find where the flex sdk is installed
|
40
|
+
SDK_PATHS.each do |path|
|
41
|
+
#remove /bin/ fom the end of the path if it exists
|
42
|
+
path.sub!(/[\/\\]bin[\/\\]?$/,'')
|
43
|
+
if File.exists?(path)
|
44
|
+
allValid = true
|
45
|
+
|
46
|
+
@@configs.each do |name|
|
47
|
+
config = c File.join(path, 'frameworks', "#{name}.xml")
|
48
|
+
allValid = false if !File.exists?(config)
|
49
|
+
instance_variable_set "@#{name.gsub('-','_')}", config
|
50
|
+
end
|
51
|
+
|
52
|
+
@@executables.each do |name|
|
53
|
+
exec = c File.join(path, 'bin', name)
|
54
|
+
allValid = false if !File.exists?(exec)
|
55
|
+
instance_variable_set "@#{name}", exec
|
56
|
+
end
|
57
|
+
|
58
|
+
if allValid
|
59
|
+
@@root = path
|
60
|
+
break
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
if @@root == nil
|
66
|
+
str = ""
|
67
|
+
if !SDK_PATHS.empty?
|
68
|
+
str << "Could not find a valid Flex SDK at any of the paths in FlexSDK::SDK_PATHS\n=> "
|
69
|
+
str << SDK_PATHS.join("\n=> ")
|
70
|
+
str << "\n"
|
71
|
+
end
|
72
|
+
str << "Append a valid SDK path in your rakefile, e.g.:\nFlexSDK::SDK_PATHS << 'C:\\develop\\sdk\\flex_sdk_4.6.0.23201'"
|
73
|
+
str << "\nFor more information, see: http://adobe.com/go/flex_sdk/"
|
74
|
+
fail str
|
75
|
+
end
|
76
|
+
end
|
77
|
+
@@initialized = true
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
data/lib/asrake/host.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
module OS
|
2
|
+
def OS.is_mac?
|
3
|
+
RUBY_PLATFORM.downcase.include?("darwin")
|
4
|
+
end
|
5
|
+
|
6
|
+
def OS.is_windows?
|
7
|
+
require 'rbconfig'
|
8
|
+
RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
|
9
|
+
end
|
10
|
+
|
11
|
+
def OS.is_linux?
|
12
|
+
RUBY_PLATFORM.downcase.include?("linux")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def run(command, abort_on_failure = true)
|
17
|
+
command.strip!
|
18
|
+
|
19
|
+
puts "> #{command}"
|
20
|
+
IO.popen("#{command} 2>&1") do |proc|
|
21
|
+
while !proc.closed? && (line = proc.gets)
|
22
|
+
puts "> #{line}"
|
23
|
+
yield line if block_given?
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
if $?.exitstatus != 0
|
28
|
+
msg = "Operation exited with status #{$?.exitstatus}"
|
29
|
+
fail msg if abort_on_failure
|
30
|
+
puts msg
|
31
|
+
end
|
32
|
+
|
33
|
+
return $?
|
34
|
+
end
|
35
|
+
|
36
|
+
def c(str)
|
37
|
+
OS::is_windows? ? cb(str) : cf(str)
|
38
|
+
end
|
39
|
+
|
40
|
+
def cb(str)
|
41
|
+
str.gsub("/", "\\")
|
42
|
+
end
|
43
|
+
|
44
|
+
def cf(str)
|
45
|
+
str.gsub("\\", "/")
|
46
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'rake/tasklib'
|
2
|
+
|
3
|
+
require 'asrake/host'
|
4
|
+
require 'asrake/base_compiler_task'
|
5
|
+
require 'asrake/mxmlc_args'
|
6
|
+
|
7
|
+
module ASRake
|
8
|
+
class MxmlcTask < BaseCompilerTask
|
9
|
+
include MxmlcArguments_Module
|
10
|
+
|
11
|
+
# Create a swc compilation task with the given name.
|
12
|
+
def initialize(name = :build, args = nil)
|
13
|
+
super
|
14
|
+
|
15
|
+
# create directory task for output
|
16
|
+
directory self.output_dir
|
17
|
+
|
18
|
+
# always build until we can properly grab dependencies
|
19
|
+
task @name => self.output_dir do
|
20
|
+
self.build
|
21
|
+
result = c self.output
|
22
|
+
result << " (#{File.size(output)} bytes)" unless self.output_is_dir?
|
23
|
+
puts result
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
protected
|
29
|
+
|
30
|
+
def build
|
31
|
+
run "#{FlexSDK::mxmlc}#{generate_args}" do |line|
|
32
|
+
generate_error_message_tips(line)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|