buildr-as3 0.1.7 → 0.1.8

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.7
1
+ 0.1.8
data/buildr-as3.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{buildr-as3}
8
- s.version = "0.1.7"
8
+ s.version = "0.1.8"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Dominic Graefen"]
12
- s.date = %q{2011-01-27}
12
+ s.date = %q{2011-02-01}
13
13
  s.description = %q{Build like you code - now supporting ActionScript 3 & Flex}
14
14
  s.email = %q{dominic @nospam@ devboy.org}
15
15
  s.extra_rdoc_files = [
@@ -25,7 +25,7 @@ Gem::Specification.new do |s|
25
25
  "VERSION",
26
26
  "buildr-as3.gemspec",
27
27
  "lib/buildr/as3.rb",
28
- "lib/buildr/as3/alchemytk.rb",
28
+ "lib/buildr/as3/alchemy.rb",
29
29
  "lib/buildr/as3/apparat.rb",
30
30
  "lib/buildr/as3/compiler.rb",
31
31
  "lib/buildr/as3/doc.rb",
data/lib/buildr/as3.rb CHANGED
@@ -23,5 +23,5 @@ require "#{File.dirname(__FILE__)}/as3/compiler"
23
23
  require "#{File.dirname(__FILE__)}/as3/packaging"
24
24
  require "#{File.dirname(__FILE__)}/as3/flexsdk"
25
25
  require "#{File.dirname(__FILE__)}/as3/doc"
26
- require "#{File.dirname(__FILE__)}/as3/alchemytk"
26
+ require "#{File.dirname(__FILE__)}/as3/alchemy"
27
27
  require "#{File.dirname(__FILE__)}/as3/apparat"
@@ -20,7 +20,7 @@
20
20
  # THE SOFTWARE.
21
21
  #
22
22
  module Buildr
23
- module Compiler
23
+ module AS3
24
24
  class AlchemyToolkit
25
25
 
26
26
  attr_reader :home, :achacks, :gcc, :flex_sdk, :alchemy_setup, :bin
@@ -60,5 +60,59 @@ module Buildr
60
60
 
61
61
  end
62
62
  end
63
+
64
+ module Compiler
65
+ class AlcGcc < Buildr::Compiler::Base
66
+ specify :language => :c,
67
+ :sources => :c, :source_ext => :c,
68
+ :target => "bin", :target_ext => "swc",
69
+ :packaging => :swc
70
+
71
+ attr_reader :project
72
+
73
+ def initialize(project, options)
74
+ super
75
+ @project = project
76
+ end
77
+
78
+ include CompilerUtils
79
+
80
+ def compile(sources, target, dependencies)
81
+ alchemy_tk = options[:alchemytk]
82
+ flex_sdk = alchemy_tk.flex_sdk
83
+ output = CompilerUtils::get_output(project,target,:swc,options)
84
+
85
+ # gcc stringecho.c -O3 -Wall -swc -o stringecho.swc
86
+ cmd_args = []
87
+ cmd_args << "gcc"
88
+ cmd_args << File.basename(options[:main])
89
+ cmd_args << "-O3 -Wall -swc"
90
+ cmd_args << "-o #{File.basename output}"
91
+
92
+ reserved = [:flexsdk,:main,:alchemytk]
93
+ options.to_hash.reject { |key, value| reserved.include?(key) }.
94
+ each do |key, value|
95
+ cmd_args << "-#{key}=#{value}"
96
+ end
97
+
98
+ unless Buildr.application.options.dryrun
99
+ ENV["ALCHEMY_HOME"]= alchemy_tk.home
100
+ ENV["ALCHEMY_VER"] = "0.4a"
101
+ ENV["PATH"] = "#{alchemy_tk.bin}:#{ENV["PATH"]}"
102
+ ENV["ASC"]="#{alchemy_tk.home}/bin/asc.jar"
103
+ ENV["SWFBRIDGE"]="#{alchemy_tk.home}/bin/swfbridge"
104
+ ENV["PATH"] = "#{alchemy_tk.achacks}:#{ENV["PATH"]}"
105
+ ENV["PATH"] = "#{ENV["PATH"]}:#{flex_sdk.bin}"
106
+ project_dir = Dir.getwd
107
+ Dir.chdir File.dirname options[:main]
108
+ system(cmd_args.join(" "))
109
+ File.copy( File.basename(output), output)
110
+ File.delete File.basename(output)
111
+ Dir.chdir project_dir
112
+ end
113
+ end
114
+ end
115
+ end
63
116
  end
64
117
  end
118
+ Buildr::Compiler.compilers << Buildr::AS3::Compiler::AlcGcc
@@ -20,9 +20,10 @@
20
20
  # THE SOFTWARE.
21
21
  #
22
22
  module Buildr
23
- module BuildrAs3
23
+ module AS3
24
24
  class ApparatToolkit
25
- attr_reader :home, :asmifier, :concrete, :coverage, :dump, :jitb, :reducer, :stripper, :tdsi, :asm_swc,
25
+ attr_reader :home, :asmifier, :concrete, :coverage, :dump,
26
+ :jitb, :reducer, :stripper, :tdsi, :asm_swc,
26
27
  :ersatz_swc, :lzma_decoder_swc
27
28
 
28
29
  def initialize(apparat_version,apparat_url)
@@ -55,7 +56,6 @@ module Buildr
55
56
  include Extension
56
57
 
57
58
  first_time do
58
- # Define task not specific to any projet.
59
59
  Project.local_task('apparat_tdsi')
60
60
  Project.local_task('apparat_reducer')
61
61
  end
@@ -67,10 +67,7 @@ module Buildr
67
67
  end
68
68
 
69
69
  def apparat_tdsi(apparat_tk,options = {})
70
- puts "aparat_tdsi"
71
- main = compile.options[:main]
72
- mainfile = File.basename(main, File.extname(main))
73
- output = (compile.options[:output] || "#{compile.target}/#{mainfile}.swf")
70
+ output = Buildr::AS3::Compiler::CompilerUtils::get_output(project,compile.target,compile.packaging,compile.options)
74
71
  cmd_args = []
75
72
  cmd_args << apparat_tk.tdsi
76
73
  cmd_args << "-i #{output}"
@@ -78,27 +75,24 @@ module Buildr
78
75
  reserved = []
79
76
  options.to_hash.reject { |key, value| reserved.include?(key) }.
80
77
  each do |key, value|
81
- cmd_args << "-#{key}=#{value}"
78
+ cmd_args << "-#{key} #{value}"
82
79
  end
83
80
  system(cmd_args.join " ")
84
81
  end
85
82
 
86
83
  def apparat_reducer(apparat_tk,quality)
87
- puts "aparat_reducer"
88
- main = compile.options[:main]
89
- mainfile = File.basename(main, File.extname(main))
90
- output = (compile.options[:output] || "#{compile.target}/#{mainfile}.swf")
84
+ output = Buildr::AS3::Compiler::CompilerUtils::get_output(project,compile.target,compile.packaging,compile.options)
91
85
  cmd_args = []
92
86
  cmd_args << apparat_tk.reducer
93
87
  cmd_args << "-i #{output}"
94
88
  cmd_args << "-o #{output}"
95
89
  cmd_args << "-q"
96
- cmd_args << quality || 80
90
+ cmd_args << quality || 100
97
91
  system(cmd_args.join " ")
98
92
  end
99
93
  end
100
94
  end
101
95
  class Project
102
- include Buildr::BuildrAs3::Apparat
96
+ include Buildr::AS3::Apparat
103
97
  end
104
98
  end
@@ -20,371 +20,229 @@
20
20
  # THE SOFTWARE.
21
21
  #
22
22
  #TODO: Refactor compiler classes, right now everything is copy&paste
23
- module Buildr
24
- module Compiler
25
- module BuildInfo
26
- def write_build_info_class( source_path, project )
27
- file = File.join source_path, "org/devboy/buildras3/Build.as"
28
- puts "Write Build Info Class:"+file
29
- file_content = "/**
30
- * Created by buildr-as3
31
- */
32
- package org.devboy.buildras3 {
33
- public class Build
34
- {
35
- public static const PROJECT_NAME : String = '#{project.to_s}';
36
- public static const PROJECT_GROUP : String = '#{project.group.to_s}';
37
- public static const PROJECT_VERSION : String = '#{project.version.to_s}';
38
- public static const BUILD_TIME : String = '#{Time.now.to_s}';
39
- }
40
- }"
41
- File.open(file, 'w') {|f| f.write(file_content) }
42
- end
43
- end
44
- module NeededTools
45
- def is_output_outdated?(output,file_to_check)
46
- return true unless File.exists? output
47
- older(output,file_to_check)
48
- end
49
-
50
- def older(a,b) # a older than b
51
- # puts "OLDER"
52
- # puts a, timestamp_from_file(a)
53
- # puts b, timestamp_from_file(b)
54
- timestamp_from_file(a) < timestamp_from_file(b)
55
- end
56
-
57
- def timestamp_from_file(file)
58
- File.directory?(file) ? get_last_modified(file) : File.mtime(file)
59
- end
60
-
61
- def get_last_modified(dir)
62
- file_mtimes = []
63
- dirs = Dir.new(dir).select { |file| file!= '.' && file!='..' && File.directory?(dir+"/"+file)==true }
64
- dirs = dirs.collect { |subdir| dir+"/"+subdir }
65
- dirs.each { |subdir| file_mtimes << get_last_modified(subdir) }
66
- files = Dir.new(dir).select { |file| file!= '.' && file!='..' && File.directory?(dir+"/"+file)==false }
67
- files = files.collect { |file| dir+'/'+file }
68
- files.each { |file|
69
- file_mtimes << File.mtime(file)
70
- # puts "","checkFile:"
71
- # puts File.mtime(file).to_s
72
- # puts file.to_s, ""
73
- }
74
- file_mtimes.sort!
75
- file_mtimes.reverse!
76
- file_mtimes.length > 0 ? file_mtimes.first : Time.at(0)
77
- end
78
-
79
- def applies_to?(project, task) #:nodoc:
80
- trace "applies_to?: false"
81
- false
82
- end
83
- end
84
- class Mxmlc < Base
85
- specify :language => :actionscript,
86
- :sources => [:as3, :mxml], :source_ext => [:as, :mxml],
87
- :target => "bin", :target_ext => "swf",
88
- :packaging => :swf
89
-
90
- attr_reader :project
91
-
92
- def initialize(project, options)
93
- super
94
- @project = project
95
- end
96
-
97
23
 
98
- include NeededTools
99
- def needed?(sources, target, dependencies)
100
- main = options[:main]
101
- mainfile = File.basename(main, File.extname(main))
102
- output = (options[:output] || "#{target}/#{mainfile}.swf")
103
- sources.each do |source|
104
- if is_output_outdated?(output, source)
105
- # puts "checkSource:" + source
106
- puts "Recompile needed: Sources are newer than target"
107
- return true
24
+ module Buildr
25
+ module AS3
26
+ module Compiler
27
+ module CompilerUtils
28
+ def self.get_output( project, target, package, options )
29
+ return options[:output] if options.has_key? :output
30
+ return "#{target}/#{File.basename(options[:main].to_s, File.extname(options[:main].to_s))}.swf" if package == :swf
31
+ return "#{target}/#{project.name.gsub(":", "-")}.swc" if package == :swc
32
+ fail( "Could not guess output file.")
33
+ end
34
+
35
+ def needed?(sources, target, dependencies)
36
+ output = CompilerUtils::get_output(project,target,project.compile.packaging,options)
37
+ sources.each do |source|
38
+ if is_output_outdated?(output, source)
39
+ puts "Recompile of #{project.name} needed: Sources are newer than target"
40
+ return true
41
+ end
108
42
  end
109
- end
110
- dependencies.each do |dependency|
111
- if is_output_outdated?(output, dependency)
112
- puts "Recompile needed: Dependencies are newer than target"
113
- return true
43
+ dependencies.each do |dependency|
44
+ if is_output_outdated?(output, dependency)
45
+ puts "Recompile of #{project.name} needed: Dependencies are newer than target"
46
+ return true
47
+ end
114
48
  end
49
+ puts "Recompile of #{project.name} not needed."
50
+ false
115
51
  end
116
- puts "Recompile not needed"
117
- false
118
- end
119
-
120
52
 
121
- include BuildInfo
122
- def compile(sources, target, dependencies)
123
- # write_build_info_class sources[0], project
124
- flex_sdk = options[:flexsdk]
125
- main = options[:main]
126
- mainfile = File.basename(main, File.extname(main))
127
- output = (options[:output] || "#{target}/#{mainfile}.swf")
53
+ def is_output_outdated?(output,file_to_check)
54
+ return true unless File.exists? output
55
+ older(output,file_to_check)
56
+ end
128
57
 
129
- cmd_args = []
130
- cmd_args << "-jar" << flex_sdk.mxmlc_jar
131
- cmd_args << "+flexlib" << "#{flex_sdk.home}/frameworks"
132
- cmd_args << main
133
- cmd_args << "-output" << output
134
- cmd_args << "-load-config" << flex_sdk.flex_config
135
- cmd_args << "-source-path" << sources.join(" ")
136
- cmd_args << "-library-path+=#{dependencies.join(",")}" unless dependencies.empty?
137
- reserved = [:flexsdk,:main]
138
- options.to_hash.reject { |key, value| reserved.include?(key) }.
139
- each do |key, value|
140
- cmd_args << "-#{key}=#{value}"
58
+ def older(a,b) # a older than b
59
+ timestamp_from_file(a) < timestamp_from_file(b)
141
60
  end
142
- flex_sdk.default_options.each do |key, value|
143
- cmd_args << "-#{key}=#{value}"
61
+
62
+ def timestamp_from_file(file)
63
+ File.directory?(file) ? get_last_modified(file) : File.mtime(file)
144
64
  end
145
65
 
146
- unless Buildr.application.options.dryrun
147
- Java::Commands.java cmd_args
66
+ def get_last_modified(dir)
67
+ file_mtimes = []
68
+ dirs = Dir.new(dir).select { |file| file!= '.' && file!='..' && File.directory?(dir+"/"+file)==true }
69
+ dirs = dirs.collect { |subdir| dir+"/"+subdir }
70
+ dirs.each { |subdir| file_mtimes << get_last_modified(subdir) }
71
+ files = Dir.new(dir).select { |file| file!= '.' && file!='..' && File.directory?(dir+"/"+file)==false }
72
+ files = files.collect { |file| dir+'/'+file }
73
+ files.each { |file| file_mtimes << File.mtime(file) }
74
+ file_mtimes.sort!
75
+ file_mtimes.reverse!
76
+ file_mtimes.length > 0 ? file_mtimes.first : Time.at(0)
148
77
  end
149
78
  end
150
- end
151
- class AirMxmlc < Base
152
- specify :language => :actionscript,
153
- :sources => [:as3, :mxml], :source_ext => [:as, :mxml],
154
- :target => "bin", :target_ext => "swf",
155
- :packaging => :swf
156
79
 
80
+ class Mxmlc < Buildr::Compiler::Base
81
+ specify :language => :actionscript,
82
+ :sources => [:as3, :mxml], :source_ext => [:as, :mxml],
83
+ :target => "bin", :target_ext => "swf",
84
+ :packaging => :swf
157
85
 
158
- def initialize(project, options)
159
- super
160
- end
86
+ attr_reader :project
87
+
88
+ def initialize(project, options)
89
+ super
90
+ @project = project
91
+ end
92
+
93
+ include CompilerUtils
161
94
 
95
+ def compile(sources, target, dependencies)
96
+ flex_sdk = options[:flexsdk]
97
+ output = CompilerUtils::get_output(project,target,:swf,options)
162
98
 
163
- include NeededTools
164
- def needed?(sources, target, dependencies)
165
- main = options[:main]
166
- mainfile = File.basename(main, File.extname(main))
167
- output = (options[:output] || "#{target}/#{mainfile}.swf")
168
- sources.each do |source|
169
- if is_output_outdated?(output, source)
170
- puts "Recompile needed: Sources are newer than target"
171
- return true
99
+ cmd_args = []
100
+ cmd_args << "-jar" << flex_sdk.mxmlc_jar
101
+ cmd_args << "+flexlib" << "#{flex_sdk.home}/frameworks"
102
+ cmd_args << options[:main]
103
+ cmd_args << "-output" << output
104
+ cmd_args << "-load-config" << flex_sdk.flex_config
105
+ cmd_args << "-source-path" << sources.join(" ")
106
+ cmd_args << "-library-path+=#{dependencies.join(",")}" unless dependencies.empty?
107
+ reserved = [:flexsdk,:main]
108
+ options.to_hash.reject { |key, value| reserved.include?(key) }.
109
+ each do |key, value|
110
+ cmd_args << "-#{key}=#{value}"
172
111
  end
173
- end
174
- dependencies.each do |dependency|
175
- if is_output_outdated?(output, dependency)
176
- puts "Recompile needed: Dependencies are newer than target"
177
- return true
112
+ flex_sdk.default_options.each do |key, value|
113
+ cmd_args << "-#{key}=#{value}"
114
+ end
115
+
116
+ unless Buildr.application.options.dryrun
117
+ Java::Commands.java cmd_args
178
118
  end
179
119
  end
180
- puts "Recompile not needed"
181
- false
182
120
  end
183
121
 
184
- def compile(sources, target, dependencies)
185
- flex_sdk = options[:flexsdk]
186
- main = options[:main]
187
- mainfile = File.basename(main, File.extname(main))
188
- output = (options[:output] || "#{target}/#{mainfile}.swf")
122
+ class AirMxmlc < Buildr::Compiler::Base
189
123
 
190
- cmd_args = []
191
- cmd_args << "-jar" << flex_sdk.mxmlc_jar
192
- cmd_args << "+flexlib" << "#{flex_sdk.home}/frameworks"
193
- cmd_args << main
194
- cmd_args << "-output" << output
195
- cmd_args << "-load-config" << flex_sdk.air_config
196
- cmd_args << "-source-path" << 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
124
+ specify :language => :actionscript,
125
+ :sources => [:as3, :mxml], :source_ext => [:as, :mxml],
126
+ :target => "bin", :target_ext => "swf",
127
+ :packaging => :swf
206
128
 
207
- unless Buildr.application.options.dryrun
208
- Java::Commands.java cmd_args
209
- end
210
- end
211
- end
212
- class Compc < 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.name.gsub(":", "-")}.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
- puts "Recompile not needed"
232
- false
233
- end
129
+ attr_reader :project
234
130
 
235
- def compile(sources, target, dependencies)
236
- # write_build_info_class sources[0], project
237
- flex_sdk = options[:flexsdk]
238
- output = (options[:output] || "#{target}/#{project.name.gsub(":", "-")}.swc")
239
- cmd_args = []
240
- cmd_args << "-jar" << flex_sdk.compc_jar
241
- cmd_args << "-output" << output
242
- cmd_args << "+flexlib" << "#{flex_sdk.home}/frameworks"
243
- cmd_args << "-load-config" << flex_sdk.flex_config
244
- cmd_args << "-include-sources" << sources.join(" ")
245
- cmd_args << "-library-path+=#{dependencies.join(",")}" unless dependencies.empty?
246
- reserved = [:flexsdk, :main]
247
- options.to_hash.reject { |key, value| reserved.include?(key) }.
248
- each do |key, value|
249
- cmd_args << "-#{key}=#{value}"
250
- end
251
- flex_sdk.default_options.each do |key, value|
252
- cmd_args << "-#{key}=#{value}"
131
+ def initialize(project, options)
132
+ super
133
+ @project = project
253
134
  end
254
135
 
255
- unless Buildr.application.options.dryrun
256
- Java::Commands.java cmd_args
257
- end
258
- end
259
- end
260
- class AirCompc < Base
261
- specify :language => :actionscript,
262
- :sources => [:as3, :mxml], :source_ext => [:as, :mxml],
263
- :target => "bin", :target_ext => "swc",
264
- :packaging => :swc
265
- attr_reader :project
266
- def initialize(project, options)
267
- super
268
- @project = project
269
- end
270
- include NeededTools
271
- def needed?(sources, target, dependencies)
272
- output = (options[:output] || "#{target}/#{project.name.gsub(":", "-")}.swc")
273
- sources.each do |source|
274
- if is_output_outdated?(output, source)
275
- puts "Recompile needed: Sources are newer than target"
276
- return true
136
+ include CompilerUtils
137
+
138
+ def compile(sources, target, dependencies)
139
+ flex_sdk = options[:flexsdk]
140
+ output = CompilerUtils::get_output(project,target,:swf,options)
141
+
142
+ cmd_args = []
143
+ cmd_args << "-jar" << flex_sdk.mxmlc_jar
144
+ cmd_args << "+flexlib" << "#{flex_sdk.home}/frameworks"
145
+ cmd_args << "+configname" << "air"
146
+ cmd_args << options[:main]
147
+ cmd_args << "-output" << output
148
+ cmd_args << "-load-config" << flex_sdk.air_config
149
+ cmd_args << "-source-path" << sources.join(" ")
150
+ cmd_args << "-library-path+=#{dependencies.join(",")}" unless dependencies.empty?
151
+ reserved = [:flexsdk,:main]
152
+ options.to_hash.reject { |key, value| reserved.include?(key) }.
153
+ each do |key, value|
154
+ cmd_args << "-#{key}=#{value}"
277
155
  end
278
- end
279
- dependencies.each do |dependency|
280
- if is_output_outdated?(output, dependency)
281
- puts "Recompile needed: Dependencies are newer than target"
282
- return true
156
+ flex_sdk.default_options.each do |key, value|
157
+ cmd_args << "-#{key}=#{value}"
283
158
  end
284
- end
285
- false
286
- end
287
159
 
288
- def compile(sources, target, dependencies)
289
- flex_sdk = options[:flexsdk]
290
- output = (options[:output] || "#{target}/#{project.to_s}.swc")
291
- cmd_args = []
292
- cmd_args << "-jar" << flex_sdk.compc_jar
293
- cmd_args << "-output" << output
294
- cmd_args << "-load-config" << flex_sdk.air_config
295
- cmd_args << "+flexlib" << "#{flex_sdk.home}/frameworks"
296
- cmd_args << "-include-sources" << sources.join(" ")
297
- cmd_args << "-library-path+=#{dependencies.join(",")}" unless dependencies.empty?
298
- reserved = [:flexsdk, :main]
299
- options.to_hash.reject { |key, value| reserved.include?(key) }.
300
- each do |key, value|
301
- cmd_args << "-#{key}=#{value}"
302
- end
303
- flex_sdk.default_options.each do |key, value|
304
- cmd_args << "-#{key}=#{value}"
305
- end
306
-
307
- unless Buildr.application.options.dryrun
308
- Java::Commands.java cmd_args
160
+ unless Buildr.application.options.dryrun
161
+ Java::Commands.java cmd_args
162
+ end
309
163
  end
310
164
  end
311
- end
312
- class AlcGcc < Base
313
- specify :language => :c,
314
- :sources => :c, :source_ext => :c,
315
- :target => "bin", :target_ext => "swc",
316
- :packaging => :swc
317
-
318
- attr_reader :project
319
-
320
- def initialize(project, options)
321
- super
322
- @project = project
323
- end
324
165
 
166
+ class Compc < Buildr::Compiler::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
+
177
+ include CompilerUtils
178
+
179
+ def compile(sources, target, dependencies)
180
+ flex_sdk = options[:flexsdk]
181
+ output = CompilerUtils::get_output(project,target,:swc,options)
182
+ cmd_args = []
183
+ cmd_args << "-jar" << flex_sdk.compc_jar
184
+ cmd_args << "-output" << output
185
+ cmd_args << "+flexlib" << "#{flex_sdk.home}/frameworks"
186
+ cmd_args << "-load-config" << flex_sdk.flex_config
187
+ cmd_args << "-include-sources" << sources.join(" ")
188
+ cmd_args << "-library-path+=#{dependencies.join(",")}" unless dependencies.empty?
189
+ reserved = [:flexsdk, :main]
190
+ options.to_hash.reject { |key, value| reserved.include?(key) }.
191
+ each do |key, value|
192
+ cmd_args << "-#{key}=#{value}"
193
+ end
194
+ flex_sdk.default_options.each do |key, value|
195
+ cmd_args << "-#{key}=#{value}"
196
+ end
325
197
 
326
- include NeededTools
327
- def needed?(sources, target, dependencies)
328
- true
329
- # main = options[:main]
330
- # mainfile = File.basename(main, File.extname(main))
331
- # output = (options[:output] || "#{target}/#{mainfile}.swf")
332
- # sources.each do |source|
333
- # if is_output_outdated?(output, source)
334
- # puts "Recompile needed: Sources are newer than target"
335
- # return true
336
- # end
337
- # end
338
- # dependencies.each do |dependency|
339
- # if is_output_outdated?(output, dependency)
340
- # puts "Recompile needed: Dependencies are newer than target"
341
- # return true
342
- # end
343
- # end
344
- # puts "Recompile not needed"
345
- # false
198
+ unless Buildr.application.options.dryrun
199
+ Java::Commands.java cmd_args
200
+ end
201
+ end
346
202
  end
347
203
 
204
+ class AirCompc < Buildr::Compiler::Base
205
+ specify :language => :actionscript,
206
+ :sources => [:as3, :mxml], :source_ext => [:as, :mxml],
207
+ :target => "bin", :target_ext => "swc",
208
+ :packaging => :swc
209
+ attr_reader :project
210
+ def initialize(project, options)
211
+ super
212
+ @project = project
213
+ end
214
+
215
+ include CompilerUtils
216
+
217
+ def compile(sources, target, dependencies)
218
+ flex_sdk = options[:flexsdk]
219
+ output = CompilerUtils::get_output(project,target,:swc,options)
220
+ cmd_args = []
221
+ cmd_args << "-jar" << flex_sdk.compc_jar
222
+ cmd_args << "-output" << output
223
+ cmd_args << "-load-config" << flex_sdk.air_config
224
+ cmd_args << "+flexlib" << "#{flex_sdk.home}/frameworks"
225
+ cmd_args << "+configname" << "air"
226
+ cmd_args << "-include-sources" << sources.join(" ")
227
+ cmd_args << "-library-path+=#{dependencies.join(",")}" unless dependencies.empty?
228
+ reserved = [:flexsdk, :main]
229
+ options.to_hash.reject { |key, value| reserved.include?(key) }.
230
+ each do |key, value|
231
+ cmd_args << "-#{key}=#{value}"
232
+ end
233
+ flex_sdk.default_options.each do |key, value|
234
+ cmd_args << "-#{key}=#{value}"
235
+ end
348
236
 
349
- include BuildInfo
350
- def compile(sources, target, dependencies)
351
- alchemy_tk = options[:alchemytk]
352
- flex_sdk = alchemy_tk.flex_sdk
353
- output = (options[:output] || "#{target}/#{project.name.gsub(":", "-")}.swc")
354
-
355
- # gcc stringecho.c -O3 -Wall -swc -o stringecho.swc
356
- cmd_args = []
357
- cmd_args << "gcc"
358
- cmd_args << File.basename(options[:main])
359
- cmd_args << "-O3 -Wall -swc"
360
- cmd_args << "-o #{File.basename output}"
361
-
362
- reserved = [:flexsdk,:main,:alchemytk]
363
- options.to_hash.reject { |key, value| reserved.include?(key) }.
364
- each do |key, value|
365
- cmd_args << "-#{key}=#{value}"
366
- end
367
-
368
- unless Buildr.application.options.dryrun
369
- ENV["ALCHEMY_HOME"]= alchemy_tk.home
370
- ENV["ALCHEMY_VER"] = "0.4a"
371
- ENV["PATH"] = "#{alchemy_tk.bin}:#{ENV["PATH"]}"
372
- ENV["ASC"]="#{alchemy_tk.home}/bin/asc.jar"
373
- ENV["SWFBRIDGE"]="#{alchemy_tk.home}/bin/swfbridge"
374
- ENV["PATH"] = "#{alchemy_tk.achacks}:#{ENV["PATH"]}"
375
- ENV["PATH"] = "#{ENV["PATH"]}:#{flex_sdk.bin}"
376
- project_dir = Dir.getwd
377
- Dir.chdir File.dirname options[:main]
378
- system(cmd_args.join(" "))
379
- File.copy( File.basename(output), output)
380
- Dir.chdir project_dir
237
+ unless Buildr.application.options.dryrun
238
+ Java::Commands.java cmd_args
239
+ end
381
240
  end
382
241
  end
383
242
  end
384
243
  end
385
244
  end
386
- Buildr::Compiler.compilers << Buildr::Compiler::Mxmlc
387
- Buildr::Compiler.compilers << Buildr::Compiler::Compc
388
- Buildr::Compiler.compilers << Buildr::Compiler::AirMxmlc
389
- Buildr::Compiler.compilers << Buildr::Compiler::AirCompc
390
- Buildr::Compiler.compilers << Buildr::Compiler::AlcGcc
245
+ Buildr::Compiler.compilers << Buildr::AS3::Compiler::Mxmlc
246
+ Buildr::Compiler.compilers << Buildr::AS3::Compiler::Compc
247
+ Buildr::Compiler.compilers << Buildr::AS3::Compiler::AirMxmlc
248
+ Buildr::Compiler.compilers << Buildr::AS3::Compiler::AirCompc
@@ -22,41 +22,44 @@
22
22
  require 'buildr/core/doc'
23
23
 
24
24
  module Buildr
25
- module Doc
26
- class Asdoc < Base
25
+ module AS3
26
+ module Doc
27
+ class Asdoc < Buildr::Doc::Base
27
28
 
28
- specify :language => :actionscript, :source_ext => :as
29
+ specify :language => :actionscript,
30
+ :source_ext => :as
29
31
 
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 << "+flexlib" << "#{flex_sdk.home}/frameworks"
40
- cmd_args << "-load-config" << flex_sdk.flex_config
41
- cmd_args << "-output" << output
42
- cmd_args << "-source-path" << sources.join(" ")
43
- cmd_args << "-doc-sources" << sources.join(" ")
44
- cmd_args << "-templates-path" << flex_sdk.asdoc_templates
45
- cmd_args << "-library-path+=#{dependencies.join(",")}" unless dependencies.empty?
46
- reserved = [:flexsdk,:main,:classpath,:sourcepath]
47
- options.to_hash.reject { |key, value| reserved.include?(key) }.
48
- each do |key, value|
49
- cmd_args << "-#{key}=#{value}"
50
- end
51
- flex_sdk.default_options.each do |key, value|
52
- cmd_args << "-#{key}=#{value}"
53
- end
54
- unless Buildr.application.options.dryrun
55
- Java::Commands.java cmd_args
32
+ def generate(sources, target, options = {})
33
+ dependencies = project.compile.dependencies
34
+ sources = project.compile.sources
35
+ flex_sdk = options[:flexsdk]
36
+ output = (options[:output] || "#{target}")
37
+ cmd_args = []
38
+ cmd_args << "-classpath" << "#{flex_sdk.home}/lib/xalan.jar"
39
+ cmd_args << "-classpath" << flex_sdk.asdoc_jar
40
+ cmd_args << "flex2.tools.ASDoc"
41
+ cmd_args << "+flexlib" << "#{flex_sdk.home}/frameworks"
42
+ cmd_args << "-load-config" << flex_sdk.flex_config
43
+ cmd_args << "-output" << output
44
+ cmd_args << "-source-path" << sources.join(" ")
45
+ cmd_args << "-doc-sources" << sources.join(" ")
46
+ cmd_args << "-templates-path" << flex_sdk.asdoc_templates
47
+ cmd_args << "-library-path+=#{dependencies.join(",")}" unless dependencies.empty?
48
+ reserved = [:flexsdk,:main,:classpath,:sourcepath]
49
+ options.to_hash.reject { |key, value| reserved.include?(key) }.
50
+ each do |key, value|
51
+ cmd_args << "-#{key}=#{value}"
52
+ end
53
+ flex_sdk.default_options.each do |key, value|
54
+ cmd_args << "-#{key}=#{value}"
55
+ end
56
+ unless Buildr.application.options.dryrun
57
+ Java::Commands.java cmd_args
58
+ end
56
59
  end
57
60
  end
58
61
  end
59
62
  end
60
63
  end
61
64
 
62
- Buildr::Doc.engines << Buildr::Doc::Asdoc
65
+ Buildr::Doc.engines << Buildr::AS3::Doc::Asdoc
@@ -20,10 +20,11 @@
20
20
  # THE SOFTWARE.
21
21
  #
22
22
  module Buildr
23
- module Compiler
23
+ module AS3
24
24
  class Flex4SDK
25
25
 
26
- attr_reader :home, :mxmlc_jar, :compc_jar, :asdoc_jar, :fcsh_jar, :flex_config, :asdoc_templates, :default_options, :air_config, :bin
26
+ attr_reader :home, :mxmlc_jar, :compc_jar, :asdoc_jar, :fcsh_jar, :flex_config,
27
+ :asdoc_templates, :default_options, :air_config, :bin
27
28
 
28
29
  attr_writer :flex_config, :air_config, :asdoc_templates
29
30
 
@@ -35,7 +36,6 @@ module Buildr
35
36
 
36
37
  sdk_zip = Buildr::artifact("com.adobe.flex:sdk:zip:#{sdk_opts[:sdk_version]}").from(Buildr::download(sdk_opts[:sdk_url]))
37
38
  sdk_zip.invoke unless File.exists? sdk_zip.to_s
38
-
39
39
  sdk_dir = File.join(File.dirname(sdk_zip.to_s), "sdk-#{sdk_opts[:sdk_version]}")
40
40
 
41
41
  unless File.exists? sdk_dir
@@ -53,7 +53,7 @@ module Buildr
53
53
  @air_config = "#{@home}/frameworks/air-config.xml"
54
54
  @bin = "#{@home}/bin"
55
55
  end
56
-
56
+
57
57
  protected
58
58
 
59
59
  def generate_url(opts = {})
@@ -19,15 +19,20 @@
19
19
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
20
  # THE SOFTWARE.
21
21
  #
22
- require 'buildr/packaging'
22
+ require File.dirname(__FILE__)+"/compiler"
23
+ require "buildr/packaging"
23
24
  require "ftools"
24
25
  module Buildr
25
- module Packaging
26
- module AS3
26
+ module AS3
27
+ module Packaging
27
28
  class SwcTask < Rake::FileTask
29
+
28
30
  include Extension
31
+ include Buildr::AS3::Compiler::CompilerUtils
32
+
29
33
  attr_writer :target_swc, :src_swc
30
34
  attr_reader :target_swc, :src_swc
35
+
31
36
  def initialize(*args) #:nodoc:
32
37
  super
33
38
  enhance do
@@ -35,23 +40,32 @@ module Buildr
35
40
  File.copy( src_swc, target_swc )
36
41
  end
37
42
  end
43
+
38
44
  def needed?
39
- true
45
+ is_output_outdated? target_swc, src_swc
40
46
  end
47
+
41
48
  first_time do
42
49
  desc 'create swc package task'
43
50
  Project.local_task('package_swc')
44
51
  end
52
+
45
53
  before_define do |project|
46
54
  SwcTask.define_task('package_swc').tap do |package_swc|
47
55
  package_swc
48
56
  end
49
57
  end
58
+
50
59
  end
60
+
51
61
  class SwfTask < Rake::FileTask
62
+
52
63
  include Extension
64
+ include Buildr::AS3::Compiler::CompilerUtils
65
+
53
66
  attr_writer :target_swf, :src_swf
54
67
  attr_reader :target_swf, :src_swf
68
+
55
69
  def initialize(*args) #:nodoc:
56
70
  super
57
71
  enhance do
@@ -59,43 +73,53 @@ module Buildr
59
73
  File.copy( src_swf, target_swf )
60
74
  end
61
75
  end
76
+
62
77
  def needed?
63
- true
78
+ is_output_outdated? target_swf, src_swf
64
79
  end
80
+
65
81
  first_time do
66
82
  desc 'create swf package task'
67
83
  Project.local_task('package_swf')
68
84
  end
85
+
69
86
  before_define do |project|
70
87
  SwfTask.define_task('package_swf').tap do |package_swf|
71
88
  package_swf
72
89
  end
73
90
  end
91
+
74
92
  end
93
+
75
94
  def package_swc(&block)
76
95
  task("package_swc").enhance &block
77
96
  end
97
+
78
98
  def package_swf(&block)
79
99
  task("package_swf").enhance &block
80
100
  end
101
+
81
102
  protected
103
+
82
104
  def package_as_swc(file_name)
105
+ fail("Package types don't match! :swc vs. :#{compile.packaging.to_s}") unless compile.packaging == :swc
83
106
  SwcTask.define_task(file_name).tap do |swc|
84
- swc.src_swc = (compile.options[:output] || "#{compile.target}/#{project.name.gsub(":", "-")}.swc")
107
+ swc.src_swc = Buildr::AS3::Compiler::CompilerUtils::get_output(project,compile.target,:swc,compile.options)
85
108
  swc.target_swc = file_name
86
109
  end
87
110
  end
111
+
88
112
  def package_as_swf(file_name)
113
+ fail("Package types don't match! :swf vs. :#{compile.packaging.to_s}") unless compile.packaging == :swf
89
114
  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")
115
+ swf.src_swf = Buildr::AS3::Compiler::CompilerUtils::get_output(project,compile.target,:swf,compile.options)
93
116
  swf.target_swf = file_name
94
117
  end
95
118
  end
119
+
96
120
  end
97
121
  end
98
122
  end
99
123
  class Buildr::Project
100
- include Buildr::Packaging::AS3
124
+ include Buildr::AS3::Packaging
101
125
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: buildr-as3
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 11
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 7
10
- version: 0.1.7
9
+ - 8
10
+ version: 0.1.8
11
11
  platform: ruby
12
12
  authors:
13
13
  - Dominic Graefen
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-27 00:00:00 +01:00
18
+ date: 2011-02-01 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -112,7 +112,7 @@ files:
112
112
  - VERSION
113
113
  - buildr-as3.gemspec
114
114
  - lib/buildr/as3.rb
115
- - lib/buildr/as3/alchemytk.rb
115
+ - lib/buildr/as3/alchemy.rb
116
116
  - lib/buildr/as3/apparat.rb
117
117
  - lib/buildr/as3/compiler.rb
118
118
  - lib/buildr/as3/doc.rb