buildr-as3 0.1.1
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/lib/buildr/as3.rb +25 -0
- data/lib/buildr/as3/compiler.rb +263 -0
- data/lib/buildr/as3/doc.rb +61 -0
- data/lib/buildr/as3/flexsdk.rb +64 -0
- data/lib/buildr/as3/packaging.rb +101 -0
- metadata +86 -0
data/lib/buildr/as3.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2011 by Dominic Graefen / http://devboy.org
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
#
|
22
|
+
require "#{File.dirname(__FILE__)}/as3/compiler"
|
23
|
+
require "#{File.dirname(__FILE__)}/as3/packaging"
|
24
|
+
require "#{File.dirname(__FILE__)}/as3/flexsdk"
|
25
|
+
require "#{File.dirname(__FILE__)}/as3/doc"
|
@@ -0,0 +1,263 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2011 by Dominic Graefen / http://devboy.org
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
#
|
22
|
+
#TODO: Refactor compiler classes, right now everything is copy&paste
|
23
|
+
module Buildr
|
24
|
+
module Compiler
|
25
|
+
module NeededTools
|
26
|
+
def is_output_outdated?(output,file_to_check)
|
27
|
+
return true unless File.exists? output
|
28
|
+
older(output,file_to_check)
|
29
|
+
end
|
30
|
+
|
31
|
+
def older(a,b) # a older than b
|
32
|
+
timestamp_from_file(a) < timestamp_from_file(b)
|
33
|
+
end
|
34
|
+
|
35
|
+
def timestamp_from_file(file)
|
36
|
+
File.directory?(file) ? get_last_modified(file) : File.mtime(file)
|
37
|
+
end
|
38
|
+
|
39
|
+
def get_last_modified(dir)
|
40
|
+
file_mtimes = []
|
41
|
+
dirs = Dir.new(dir).select { |file| file!= '.' && file!='..' && File.directory?(dir+"/"+file)==true }
|
42
|
+
dirs = dirs.collect { |subdir| dir+"/"+subdir }
|
43
|
+
dirs.each do |subdir|
|
44
|
+
file_mtimes << get_last_modified(subdir)
|
45
|
+
end
|
46
|
+
files = Dir.new(dir).select { |file| file!= '.' && file!='..' && File.directory?(dir+"/"+file)==false }
|
47
|
+
files = files.collect { |file| dir+'/'+file }
|
48
|
+
files.each do |file|
|
49
|
+
file_mtimes << File.mtime(file)
|
50
|
+
end
|
51
|
+
file_mtimes.sort!
|
52
|
+
file_mtimes.reverse!
|
53
|
+
file_mtimes.length > 0 ? file_mtimes.first : Time.at(0)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
class Mxmlc < Base
|
57
|
+
specify :language => :actionscript,
|
58
|
+
:sources => [:as3, :mxml], :source_ext => [:as, :mxml],
|
59
|
+
:target => "bin", :target_ext => "swf",
|
60
|
+
:packaging => :swf
|
61
|
+
|
62
|
+
|
63
|
+
def initialize(project, options)
|
64
|
+
super
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
include NeededTools
|
69
|
+
def needed?(sources, target, dependencies)
|
70
|
+
main = options[:main]
|
71
|
+
mainfile = File.basename(main, File.extname(main))
|
72
|
+
output = (options[:output] || "#{target}/#{mainfile}.swf")
|
73
|
+
sources.each do |source|
|
74
|
+
return true if is_output_outdated?(output,source)
|
75
|
+
end
|
76
|
+
dependencies.each do |dependency|
|
77
|
+
return true if is_output_outdated?(output,dependency)
|
78
|
+
end
|
79
|
+
false
|
80
|
+
end
|
81
|
+
|
82
|
+
|
83
|
+
|
84
|
+
def compile(sources, target, dependencies)
|
85
|
+
flex_sdk = options[:flexsdk]
|
86
|
+
main = options[:main]
|
87
|
+
mainfile = File.basename(main, File.extname(main))
|
88
|
+
output = (options[:output] || "#{target}/#{mainfile}.swf")
|
89
|
+
|
90
|
+
cmd_args = []
|
91
|
+
cmd_args << "-jar" << flex_sdk.mxmlc_jar
|
92
|
+
cmd_args << "+flexlib" << "#{flex_sdk.home}/frameworks"
|
93
|
+
cmd_args << main
|
94
|
+
cmd_args << "-output" << output
|
95
|
+
cmd_args << "-load-config" << flex_sdk.flex_config
|
96
|
+
cmd_args << "-source-path" << sources.join(" ")
|
97
|
+
cmd_args << "-library-path+=#{dependencies.join(",")}" unless dependencies.empty?
|
98
|
+
reserved = [:flexsdk,:main]
|
99
|
+
options.to_hash.reject { |key, value| reserved.include?(key) }.
|
100
|
+
each do |key, value|
|
101
|
+
cmd_args << "-#{key}=#{value}"
|
102
|
+
end
|
103
|
+
flex_sdk.default_options.each do |key, value|
|
104
|
+
cmd_args << "-#{key}=#{value}"
|
105
|
+
end
|
106
|
+
|
107
|
+
unless Buildr.application.options.dryrun
|
108
|
+
Java::Commands.java cmd_args
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
class AirMxmlc < Base
|
113
|
+
specify :language => :actionscript,
|
114
|
+
:sources => [:as3, :mxml], :source_ext => [:as, :mxml],
|
115
|
+
:target => "bin", :target_ext => "swf",
|
116
|
+
:packaging => :swf
|
117
|
+
|
118
|
+
|
119
|
+
def initialize(project, options)
|
120
|
+
super
|
121
|
+
end
|
122
|
+
|
123
|
+
|
124
|
+
include NeededTools
|
125
|
+
def needed?(sources, target, dependencies)
|
126
|
+
main = options[:main]
|
127
|
+
mainfile = File.basename(main, File.extname(main))
|
128
|
+
output = (options[:output] || "#{target}/#{mainfile}.swf")
|
129
|
+
sources.each do |source|
|
130
|
+
return true if is_output_outdated?(output,source)
|
131
|
+
end
|
132
|
+
dependencies.each do |dependency|
|
133
|
+
return true if is_output_outdated?(output,dependency)
|
134
|
+
end
|
135
|
+
false
|
136
|
+
end
|
137
|
+
|
138
|
+
def compile(sources, target, dependencies)
|
139
|
+
flex_sdk = options[:flexsdk]
|
140
|
+
main = options[:main]
|
141
|
+
mainfile = File.basename(main, File.extname(main))
|
142
|
+
output = (options[:output] || "#{target}/#{mainfile}.swf")
|
143
|
+
|
144
|
+
cmd_args = []
|
145
|
+
cmd_args << "-jar" << flex_sdk.mxmlc_jar
|
146
|
+
cmd_args << "+flexlib" << "#{flex_sdk.home}/frameworks"
|
147
|
+
cmd_args << main
|
148
|
+
cmd_args << "-output" << output
|
149
|
+
cmd_args << "-load-config" << flex_sdk.air_config
|
150
|
+
cmd_args << "-source-path" << sources.join(" ")
|
151
|
+
cmd_args << "-library-path+=#{dependencies.join(",")}" unless dependencies.empty?
|
152
|
+
reserved = [:flexsdk,:main]
|
153
|
+
options.to_hash.reject { |key, value| reserved.include?(key) }.
|
154
|
+
each do |key, value|
|
155
|
+
cmd_args << "-#{key}=#{value}"
|
156
|
+
end
|
157
|
+
flex_sdk.default_options.each do |key, value|
|
158
|
+
cmd_args << "-#{key}=#{value}"
|
159
|
+
end
|
160
|
+
|
161
|
+
unless Buildr.application.options.dryrun
|
162
|
+
Java::Commands.java cmd_args
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
class Compc < Base
|
167
|
+
specify :language => :actionscript,
|
168
|
+
:sources => [:as3, :mxml], :source_ext => [:as, :mxml],
|
169
|
+
:target => "bin", :target_ext => "swc",
|
170
|
+
:packaging => :swc
|
171
|
+
attr_reader :project
|
172
|
+
def initialize(project, options)
|
173
|
+
super
|
174
|
+
@project = project
|
175
|
+
end
|
176
|
+
include NeededTools
|
177
|
+
def needed?(sources, target, dependencies)
|
178
|
+
output = (options[:output] || "#{target}/#{project.to_s}.swc")
|
179
|
+
sources.each do |source|
|
180
|
+
return true if is_output_outdated?(output,source)
|
181
|
+
end
|
182
|
+
dependencies.each do |dependency|
|
183
|
+
return true if is_output_outdated?(output,dependency)
|
184
|
+
end
|
185
|
+
false
|
186
|
+
end
|
187
|
+
|
188
|
+
def compile(sources, target, dependencies)
|
189
|
+
flex_sdk = options[:flexsdk]
|
190
|
+
output = (options[:output] || "#{target}/#{project.to_s}.swc")
|
191
|
+
cmd_args = []
|
192
|
+
cmd_args << "-jar" << flex_sdk.compc_jar
|
193
|
+
cmd_args << "-output" << output
|
194
|
+
cmd_args << "+flexlib" << "#{flex_sdk.home}/frameworks"
|
195
|
+
cmd_args << "-load-config" << flex_sdk.flex_config
|
196
|
+
cmd_args << "-include-sources" << sources.join(" ")
|
197
|
+
cmd_args << "-library-path+=#{dependencies.join(",")}" unless dependencies.empty?
|
198
|
+
reserved = [:flexsdk, :main]
|
199
|
+
options.to_hash.reject { |key, value| reserved.include?(key) }.
|
200
|
+
each do |key, value|
|
201
|
+
cmd_args << "-#{key}=#{value}"
|
202
|
+
end
|
203
|
+
flex_sdk.default_options.each do |key, value|
|
204
|
+
cmd_args << "-#{key}=#{value}"
|
205
|
+
end
|
206
|
+
|
207
|
+
unless Buildr.application.options.dryrun
|
208
|
+
Java::Commands.java cmd_args
|
209
|
+
end
|
210
|
+
end
|
211
|
+
end
|
212
|
+
class AirCompc < Base
|
213
|
+
specify :language => :actionscript,
|
214
|
+
:sources => [:as3, :mxml], :source_ext => [:as, :mxml],
|
215
|
+
:target => "bin", :target_ext => "swc",
|
216
|
+
:packaging => :swc
|
217
|
+
attr_reader :project
|
218
|
+
def initialize(project, options)
|
219
|
+
super
|
220
|
+
@project = project
|
221
|
+
end
|
222
|
+
include NeededTools
|
223
|
+
def needed?(sources, target, dependencies)
|
224
|
+
output = (options[:output] || "#{target}/#{project.to_s}.swc")
|
225
|
+
sources.each do |source|
|
226
|
+
return true if is_output_outdated?(output,source)
|
227
|
+
end
|
228
|
+
dependencies.each do |dependency|
|
229
|
+
return true if is_output_outdated?(output,dependency)
|
230
|
+
end
|
231
|
+
false
|
232
|
+
end
|
233
|
+
|
234
|
+
def compile(sources, target, dependencies)
|
235
|
+
flex_sdk = options[:flexsdk]
|
236
|
+
output = (options[:output] || "#{target}/#{project.to_s}.swc")
|
237
|
+
cmd_args = []
|
238
|
+
cmd_args << "-jar" << flex_sdk.compc_jar
|
239
|
+
cmd_args << "-output" << output
|
240
|
+
cmd_args << "-load-config" << flex_sdk.air_config
|
241
|
+
cmd_args << "+flexlib" << "#{flex_sdk.home}/frameworks"
|
242
|
+
cmd_args << "-include-sources" << sources.join(" ")
|
243
|
+
cmd_args << "-library-path+=#{dependencies.join(",")}" unless dependencies.empty?
|
244
|
+
reserved = [:flexsdk, :main]
|
245
|
+
options.to_hash.reject { |key, value| reserved.include?(key) }.
|
246
|
+
each do |key, value|
|
247
|
+
cmd_args << "-#{key}=#{value}"
|
248
|
+
end
|
249
|
+
flex_sdk.default_options.each do |key, value|
|
250
|
+
cmd_args << "-#{key}=#{value}"
|
251
|
+
end
|
252
|
+
|
253
|
+
unless Buildr.application.options.dryrun
|
254
|
+
Java::Commands.java cmd_args
|
255
|
+
end
|
256
|
+
end
|
257
|
+
end
|
258
|
+
end
|
259
|
+
end
|
260
|
+
Buildr::Compiler.compilers << Buildr::Compiler::Mxmlc
|
261
|
+
Buildr::Compiler.compilers << Buildr::Compiler::Compc
|
262
|
+
Buildr::Compiler.compilers << Buildr::Compiler::AirMxmlc
|
263
|
+
Buildr::Compiler.compilers << Buildr::Compiler::AirCompc
|
@@ -0,0 +1,61 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2011 by Dominic Graefen / http://devboy.org
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
#
|
22
|
+
require 'buildr/core/doc'
|
23
|
+
|
24
|
+
module Buildr
|
25
|
+
module Doc
|
26
|
+
class Asdoc < Base
|
27
|
+
|
28
|
+
specify :language => :actionscript, :source_ext => :as
|
29
|
+
|
30
|
+
def generate(sources, target, options = {})
|
31
|
+
dependencies = project.compile.dependencies
|
32
|
+
sources = project.compile.sources
|
33
|
+
flex_sdk = options[:flexsdk]
|
34
|
+
output = (options[:output] || "#{target}")
|
35
|
+
cmd_args = []
|
36
|
+
cmd_args << "-classpath" << "#{flex_sdk.home}/lib/xalan.jar"
|
37
|
+
cmd_args << "-classpath" << flex_sdk.asdoc_jar
|
38
|
+
cmd_args << "flex2.tools.ASDoc"
|
39
|
+
cmd_args << "-load-config" << flex_sdk.flex_config
|
40
|
+
cmd_args << "-output" << output
|
41
|
+
cmd_args << "-source-path" << sources.join(" ")
|
42
|
+
cmd_args << "-doc-sources" << sources.join(" ")
|
43
|
+
cmd_args << "-templates-path" << flex_sdk.asdoc_templates
|
44
|
+
cmd_args << "-library-path+=#{dependencies.join(",")}" unless dependencies.empty?
|
45
|
+
reserved = [:flexsdk,:main,:classpath,:sourcepath]
|
46
|
+
options.to_hash.reject { |key, value| reserved.include?(key) }.
|
47
|
+
each do |key, value|
|
48
|
+
cmd_args << "-#{key}=#{value}"
|
49
|
+
end
|
50
|
+
flex_sdk.default_options.each do |key, value|
|
51
|
+
cmd_args << "-#{key}=#{value}"
|
52
|
+
end
|
53
|
+
unless Buildr.application.options.dryrun
|
54
|
+
Java::Commands.java cmd_args
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
Buildr::Doc.engines << Buildr::Doc::Asdoc
|
@@ -0,0 +1,64 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2011 by Dominic Graefen / http://devboy.org
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
#
|
22
|
+
module Buildr
|
23
|
+
module Compiler
|
24
|
+
class Flex4SDK
|
25
|
+
|
26
|
+
attr_reader :home, :mxmlc_jar, :compc_jar, :asdoc_jar, :fcsh_jar, :flex_config, :asdoc_templates, :default_options, :air_config
|
27
|
+
|
28
|
+
attr_writer :flex_config, :air_config, :asdoc_templates
|
29
|
+
|
30
|
+
def initialize(sdk_opts = {})
|
31
|
+
|
32
|
+
@default_options = {}
|
33
|
+
|
34
|
+
generate_url(sdk_opts)
|
35
|
+
|
36
|
+
sdk_zip = Buildr::artifact("com.adobe.flex:sdk:zip:#{sdk_opts[:sdk_version]}").from(Buildr::download(sdk_opts[:sdk_url]))
|
37
|
+
sdk_zip.invoke unless File.exists? sdk_zip.to_s
|
38
|
+
|
39
|
+
sdk_dir = File.join(File.dirname(sdk_zip.to_s), "sdk-#{sdk_opts[:sdk_version]}")
|
40
|
+
|
41
|
+
unless File.exists? sdk_dir
|
42
|
+
puts "Unzipping FlexSDK, this may take a while."
|
43
|
+
Buildr::unzip("#{sdk_dir}"=>sdk_zip.to_s).target.invoke
|
44
|
+
end
|
45
|
+
|
46
|
+
@home = sdk_dir
|
47
|
+
@mxmlc_jar = "#{@home}/lib/mxmlc.jar"
|
48
|
+
@compc_jar = "#{@home}/lib/compc.jar"
|
49
|
+
@asdoc_jar = "#{@home}/lib/asdoc.jar"
|
50
|
+
@asdoc_templates = "#{@home}/asdoc/templates"
|
51
|
+
@fcsh_jar = "#{@home}/lib/fcsh.jar"
|
52
|
+
@flex_config = "#{@home}/frameworks/flex-config.xml"
|
53
|
+
@air_config = "#{@home}/frameworks/air-config.xml"
|
54
|
+
end
|
55
|
+
|
56
|
+
protected
|
57
|
+
|
58
|
+
def generate_url(opts = {})
|
59
|
+
opts[:sdk_url] ||= "http://fpdownload.adobe.com/pub/flex/sdk/builds/flex#{opts[:sdk_version].split(".")[0]}/flex_sdk_#{opts[:sdk_version]}.zip"
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2011 by Dominic Graefen / http://devboy.org
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
#
|
22
|
+
require 'buildr/packaging'
|
23
|
+
require "ftools"
|
24
|
+
module Buildr
|
25
|
+
module Packaging
|
26
|
+
module Actionscript
|
27
|
+
class SwcTask < Rake::FileTask
|
28
|
+
include Extension
|
29
|
+
attr_writer :target_swc, :src_swc
|
30
|
+
attr_reader :target_swc, :src_swc
|
31
|
+
def initialize(*args) #:nodoc:
|
32
|
+
super
|
33
|
+
enhance do
|
34
|
+
fail "File not found: #{src_swc}" unless File.exists? src_swc
|
35
|
+
File.copy( src_swc, target_swc )
|
36
|
+
end
|
37
|
+
end
|
38
|
+
def needed?
|
39
|
+
true
|
40
|
+
end
|
41
|
+
first_time do
|
42
|
+
desc 'create swc package task'
|
43
|
+
Project.local_task('package_swc')
|
44
|
+
end
|
45
|
+
before_define do |project|
|
46
|
+
SwcTask.define_task('package_swc').tap do |package_swc|
|
47
|
+
package_swc
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
class SwfTask < Rake::FileTask
|
52
|
+
include Extension
|
53
|
+
attr_writer :target_swf, :src_swf
|
54
|
+
attr_reader :target_swf, :src_swf
|
55
|
+
def initialize(*args) #:nodoc:
|
56
|
+
super
|
57
|
+
enhance do
|
58
|
+
fail "File not found: #{src_swf}" unless File.exists? src_swf
|
59
|
+
File.copy( src_swf, target_swf )
|
60
|
+
end
|
61
|
+
end
|
62
|
+
def needed?
|
63
|
+
true
|
64
|
+
end
|
65
|
+
first_time do
|
66
|
+
desc 'create swf package task'
|
67
|
+
Project.local_task('package_swf')
|
68
|
+
end
|
69
|
+
before_define do |project|
|
70
|
+
SwfTask.define_task('package_swf').tap do |package_swf|
|
71
|
+
package_swf
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
def package_swc(&block)
|
76
|
+
task("package_swc").enhance &block
|
77
|
+
end
|
78
|
+
def package_swf(&block)
|
79
|
+
task("package_swf").enhance &block
|
80
|
+
end
|
81
|
+
protected
|
82
|
+
def package_as_swc(file_name)
|
83
|
+
SwcTask.define_task(file_name).tap do |swc|
|
84
|
+
swc.src_swc = (compile.options[:output] || "#{compile.target}/#{project.to_s}.swc")
|
85
|
+
swc.target_swc = file_name
|
86
|
+
end
|
87
|
+
end
|
88
|
+
def package_as_swf(file_name)
|
89
|
+
SwfTask.define_task(file_name).tap do |swf|
|
90
|
+
main = compile.options[:main]
|
91
|
+
mainfile = File.basename(main, File.extname(main))
|
92
|
+
swf.src_swf = (compile.options[:output] || "#{compile.target}/#{mainfile}.swf")
|
93
|
+
swf.target_swf = file_name
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
class Buildr::Project
|
100
|
+
include Buildr::Packaging::Actionscript
|
101
|
+
end
|
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: buildr-as3
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 25
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Dominic Graefen
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-01-20 00:00:00 +01:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: buildr
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 15
|
30
|
+
segments:
|
31
|
+
- 1
|
32
|
+
- 4
|
33
|
+
- 4
|
34
|
+
version: 1.4.4
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
37
|
+
description: Buildr extension to allow ActionScript3/Flex development.
|
38
|
+
email: dominic @nospam@ devboy.org
|
39
|
+
executables: []
|
40
|
+
|
41
|
+
extensions: []
|
42
|
+
|
43
|
+
extra_rdoc_files: []
|
44
|
+
|
45
|
+
files:
|
46
|
+
- lib/buildr/as3/compiler.rb
|
47
|
+
- lib/buildr/as3/doc.rb
|
48
|
+
- lib/buildr/as3/flexsdk.rb
|
49
|
+
- lib/buildr/as3/packaging.rb
|
50
|
+
- lib/buildr/as3.rb
|
51
|
+
has_rdoc: true
|
52
|
+
homepage: http://devboy.org
|
53
|
+
licenses: []
|
54
|
+
|
55
|
+
post_install_message:
|
56
|
+
rdoc_options: []
|
57
|
+
|
58
|
+
require_paths:
|
59
|
+
- lib
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
hash: 3
|
66
|
+
segments:
|
67
|
+
- 0
|
68
|
+
version: "0"
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
hash: 3
|
75
|
+
segments:
|
76
|
+
- 0
|
77
|
+
version: "0"
|
78
|
+
requirements: []
|
79
|
+
|
80
|
+
rubyforge_project:
|
81
|
+
rubygems_version: 1.3.7
|
82
|
+
signing_key:
|
83
|
+
specification_version: 3
|
84
|
+
summary: Buildr extension to allow ActionScript3/Flex development.
|
85
|
+
test_files: []
|
86
|
+
|