buildr-as3 0.1.16 → 0.1.17

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/README.rdoc CHANGED
@@ -4,17 +4,25 @@
4
4
 
5
5
  = Changelog
6
6
 
7
+ == 0.1.17
8
+
9
+ * [FXIED]
10
+ Actually no files were updated in version 0.1.16 because of a git hick-up,
11
+ now the changes meant for 0.1.16 are applied in 0.1.17.
12
+
7
13
  == 0.1.16
8
14
 
9
15
  * [FEATURE]
10
- API for Framworks and Toolkits integration has been refactored and updated.
16
+ API for Framworks and Toolkits integration has been refactored and updated.
11
17
 
12
18
  * [FIXED] Issue 15
13
- Zip file extraction is now handled with gnuwin32 unzip on Windows, and the equivalent on *nix platforms as a fallback for rubyzip.
14
- On Windows gnuwin32 unzip needs to be installed and added to the PATH variable.
19
+ Zip file extraction is now handled with gnuwin32 unzip on Windows, and the equivalent
20
+ on *nix platforms as a fallback for rubyzip.
21
+ On Windows gnuwin32 unzip needs to be installed and added to the PATH variable.
15
22
 
16
23
  * [FIXED] Issue 16
17
- Binarymode was not set on target-file, which caused the downloaded archive to be corrupt. This is an issue of buildr and was reported.
24
+ Binarymode was not set on target-file, which caused the downloaded archive to be corrupt.
25
+ This is an issue of buildr and was reported.
18
26
 
19
27
  == 0.1.13
20
28
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.16
1
+ 0.1.17
data/buildr-as3.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{buildr-as3}
8
- s.version = "0.1.16"
8
+ s.version = "0.1.17"
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"]
@@ -26,7 +26,9 @@ module Buildr
26
26
 
27
27
  attr_reader :home, :achacks, :gcc, :flex_sdk, :alchemy_setup, :bin
28
28
 
29
- def initialize( flex_sdk )
29
+ def initialize(flex_sdk)
30
+
31
+ fail("Alchemy support currently only on *nix based systems.") if Buildr::Util.win_os?
30
32
 
31
33
  @flex_sdk = flex_sdk
32
34
 
@@ -64,55 +66,55 @@ module Buildr
64
66
 
65
67
  module Compiler
66
68
  class AlcGcc < Buildr::Compiler::Base
67
- specify :language => :c,
68
- :sources => :c, :source_ext => :c,
69
- :target => "bin", :target_ext => "swc",
70
- :packaging => :swc
71
-
72
- attr_reader :project
73
-
74
- def initialize(project, options)
75
- super
76
- @project = project
77
- end
78
-
79
- include Buildr::AS3::Compiler::CompilerUtils
69
+ specify :language => :c,
70
+ :sources => :c, :source_ext => :c,
71
+ :target => "bin", :target_ext => "swc",
72
+ :packaging => :swc
80
73
 
81
- def compile(sources, target, dependencies)
82
- alchemy_tk = options[:alchemy]
83
- flex_sdk = alchemy_tk.flex_sdk
84
- output = Buildr::AS3::Compiler::CompilerUtils::get_output(project,target,:swc,options)
74
+ attr_reader :project
85
75
 
86
- # gcc stringecho.c -O3 -Wall -swc -o stringecho.swc
87
- cmd_args = []
88
- cmd_args << "gcc"
89
- cmd_args << File.basename(options[:main])
90
- cmd_args << "-O3 -Wall -swc"
91
- cmd_args << "-o #{File.basename output}"
92
-
93
- reserved = [:flexsdk,:main,:alchemy]
94
- options.to_hash.reject { |key, value| reserved.include?(key) }.
95
- each do |key, value|
96
- cmd_args << "-#{key}=#{value}"
76
+ def initialize(project, options)
77
+ super
78
+ @project = project
97
79
  end
98
80
 
99
- unless Buildr.application.options.dryrun
100
- ENV["ALCHEMY_HOME"]= alchemy_tk.home
101
- ENV["ALCHEMY_VER"] = "0.4a"
102
- ENV["PATH"] = "#{alchemy_tk.bin}:#{ENV["PATH"]}"
103
- ENV["ASC"]="#{alchemy_tk.home}/bin/asc.jar"
104
- ENV["SWFBRIDGE"]="#{alchemy_tk.home}/bin/swfbridge"
105
- ENV["PATH"] = "#{alchemy_tk.achacks}:#{ENV["PATH"]}"
106
- ENV["PATH"] = "#{ENV["PATH"]}:#{flex_sdk.bin}"
107
- project_dir = Dir.getwd
108
- Dir.chdir File.dirname options[:main]
109
- system(cmd_args.join(" "))
110
- File.copy( File.basename(output), output)
111
- File.delete File.basename(output)
112
- Dir.chdir project_dir
81
+ include Buildr::AS3::Compiler::CompilerUtils
82
+
83
+ def compile(sources, target, dependencies)
84
+ alchemy_tk = options[:alchemy]
85
+ flex_sdk = alchemy_tk.flex_sdk
86
+ output = Buildr::AS3::Compiler::CompilerUtils::get_output(project, target, :swc, options)
87
+
88
+ # gcc stringecho.c -O3 -Wall -swc -o stringecho.swc
89
+ cmd_args = []
90
+ cmd_args << "gcc"
91
+ cmd_args << File.basename(options[:main])
92
+ cmd_args << "-O3 -Wall -swc"
93
+ cmd_args << "-o #{File.basename output}"
94
+
95
+ reserved = [:flexsdk, :main, :alchemy]
96
+ options.to_hash.reject { |key, value| reserved.include?(key) }.
97
+ each do |key, value|
98
+ cmd_args << "-#{key}=#{value}"
99
+ end
100
+
101
+ unless Buildr.application.options.dryrun
102
+ ENV["ALCHEMY_HOME"]= alchemy_tk.home
103
+ ENV["ALCHEMY_VER"] = "0.4a"
104
+ ENV["PATH"] = "#{alchemy_tk.bin}:#{ENV["PATH"]}"
105
+ ENV["ASC"]="#{alchemy_tk.home}/bin/asc.jar"
106
+ ENV["SWFBRIDGE"]="#{alchemy_tk.home}/bin/swfbridge"
107
+ ENV["PATH"] = "#{alchemy_tk.achacks}:#{ENV["PATH"]}"
108
+ ENV["PATH"] = "#{ENV["PATH"]}:#{flex_sdk.bin}"
109
+ project_dir = Dir.getwd
110
+ Dir.chdir File.dirname options[:main]
111
+ system(cmd_args.join(" "))
112
+ File.copy(File.basename(output), output)
113
+ File.delete File.basename(output)
114
+ Dir.chdir project_dir
115
+ end
113
116
  end
114
117
  end
115
- end
116
118
  end
117
119
  end
118
120
  end
@@ -21,80 +21,131 @@
21
21
  #
22
22
  module Buildr
23
23
  module AS3
24
- module Apparat
25
- class ApparatToolkit
26
- attr_reader :home, :asmifier, :concrete, :coverage, :dump,
27
- :jitb, :reducer, :stripper, :tdsi, :asm_swc,
28
- :ersatz_swc, :lzma_decoder_swc
29
-
30
- def initialize(apparat_version,apparat_url)
31
-
32
- apparat_zip = Buildr::artifact("com.googlecode:apparat-bin:zip:#{apparat_version}").from(Buildr::download(apparat_url))
33
- apparat_zip.invoke unless File.exists? apparat_zip.to_s
34
- apparat_dir = File.join(File.dirname(apparat_zip.to_s), "apparat-bin-#{apparat_version}")
35
- unless File.exists? apparat_dir
36
- puts "Unzipping Apparat, this may take a while."
37
- Buildr::unzip(apparat_dir=>apparat_zip.to_s).target.invoke
38
- end
24
+ module Apparat
25
+ class ApparatToolkit
26
+ attr_reader :home, :asmifier, :concrete, :coverage, :dump,
27
+ :jitb, :reducer, :stripper, :tdsi, :asm_swc,
28
+ :ersatz_swc, :lzma_decoder_swc, :scala_home
39
29
 
40
- @home = apparat_dir
41
- bat_ext = Buildr::Util.win_os? ? ".bat" : ""
42
- @apparat = "#{@home}/apparat#{bat_ext}"
43
- @asmifier = "#{@home}/asmifier#{bat_ext}"
44
- @concrete = "#{@home}/concrete#{bat_ext}"
45
- @coverage = "#{@home}/coverage#{bat_ext}"
46
- @dump = "#{@home}/dump#{bat_ext}"
47
- @jitb = "#{@home}/jitb#{bat_ext}"
48
- @reducer = "#{@home}/reducer#{bat_ext}"
49
- @stripper = "#{@home}/stripper#{bat_ext}"
50
- @tdsi = "#{@home}/tdsi#{bat_ext}"
51
- @asm_swc = "#{@home}/apparat-asm-#{apparat_version}.swc"
52
- @ersatz_swc = "#{@home}/apparat-ersatz-#{apparat_version}.swc"
53
- @lzma_decoder_swc = "#{@home}/apparat-lzma-decoder-#{apparat_version}.swc"
54
- end
30
+ def initialize(version)
31
+ @version = version
32
+ @spec = "com.googlecode:apparat-bin:zip:#{@version}"
33
+ @apparat_zip = Buildr.artifact(@spec)
34
+ @apparat_dir = File.join(File.dirname(@apparat_zip.to_s), "apparat-bin-#{@version}", "apparat-#{@version}")
35
+ generate_paths @apparat_dir, @version
55
36
  end
56
- module Tasks
57
- include Extension
58
37
 
59
- first_time do
60
- Project.local_task('apparat_tdsi')
61
- Project.local_task('apparat_reducer')
62
- end
38
+ def invoke
63
39
 
64
- before_define do |project|
40
+ if @url
41
+ Buildr.artifact(@spec).from(Buildr.download(@url)).invoke unless File.exists? @apparat_zip.to_s
42
+ else
43
+ Buildr.artifact(@spec).invoke unless File.exists? @apparat_zip.to_s
65
44
  end
66
45
 
67
- after_define do |project|
46
+ unless File.exists? @apparat_dir
47
+ puts "Unzipping Apparat, this might take a while."
48
+ unzip_dir = File.dirname @apparat_dir
49
+ if Buildr::Util.win_os?
50
+ puts "Please make sure unzip is installed and in your PATH variable!"
51
+ unzip @apparat_zip, unzip_dir
52
+ else
53
+ begin
54
+ Buildr.unzip(unzip_dir.to_s=>@apparat_zip.to_s).target.invoke
55
+ rescue TypeError
56
+ puts "RubyZip extract failed, trying system unzip now."
57
+ unzip @apparat_zip, unzip_dir
58
+ end
59
+ end
68
60
  end
61
+ self
62
+ end
63
+
64
+ def from(url)
65
+ @url = url
66
+ self
67
+ end
69
68
 
70
- def apparat_tdsi(options = {})
71
- output = Buildr::AS3::Compiler::CompilerUtils::get_output(project,compile.target,compile.packaging,compile.options)
72
- apparat_tk = compile.options[:apparat]
73
- cmd_args = []
74
- cmd_args << apparat_tk.tdsi
75
- cmd_args << "-i #{output}"
76
- cmd_args << "-o #{output}"
77
- reserved = []
78
- options.to_hash.reject { |key, value| reserved.include?(key) }.
69
+ def scala(scala_home)
70
+ @scala_home = scala_home
71
+ self
72
+ end
73
+
74
+
75
+ protected
76
+
77
+ def unzip(zip, destination)
78
+ project_dir = Dir.getwd
79
+ Dir.chdir File.dirname(zip.to_s)
80
+ system("unzip #{File.basename(zip.to_s).to_s} -d #{File.basename(destination).to_s}")
81
+ Dir.chdir project_dir
82
+ end
83
+
84
+ def generate_paths(home_dir, version)
85
+ @home = home_dir
86
+ bat_ext = Buildr::Util.win_os? ? "" : ""
87
+ @apparat = "#{@home}/apparat#{bat_ext}"
88
+ @asmifier = "#{@home}/asmifier#{bat_ext}"
89
+ @concrete = "#{@home}/concrete#{bat_ext}"
90
+ @coverage = "#{@home}/coverage#{bat_ext}"
91
+ @dump = "#{@home}/dump#{bat_ext}"
92
+ @jitb = "#{@home}/jitb#{bat_ext}"
93
+ @reducer = "#{@home}/reducer#{bat_ext}"
94
+ @stripper = "#{@home}/stripper#{bat_ext}"
95
+ @tdsi = "#{@home}/tdsi#{bat_ext}"
96
+ @asm_swc = "#{@home}/apparat-asm-#{version}.swc"
97
+ @ersatz_swc = "#{@home}/apparat-ersatz-#{version}.swc"
98
+ @lzma_decoder_swc = "#{@home}/apparat-lzma-decoder-#{version}.swc"
99
+ self
100
+ end
101
+ end
102
+
103
+
104
+ module Tasks
105
+ include Extension
106
+
107
+ first_time do
108
+ Project.local_task('apparat_tdsi')
109
+ Project.local_task('apparat_reducer')
110
+ end
111
+
112
+ before_define do |project|
113
+ end
114
+
115
+ after_define do |project|
116
+ end
117
+
118
+ def apparat_tdsi(options = {})
119
+ output = Buildr::AS3::Compiler::CompilerUtils::get_output(project, compile.target, compile.packaging, compile.options)
120
+ apparat_tk = compile.options[:apparat].invoke
121
+ cmd_args = []
122
+ cmd_args << "\"#{apparat_tk.tdsi}\""
123
+ cmd_args << "-i #{output}"
124
+ cmd_args << "-o #{output}"
125
+ reserved = []
126
+ options.to_hash.reject { |key, value| reserved.include?(key) }.
79
127
  each do |key, value|
80
- cmd_args << "-#{key} #{value}"
81
- end
82
- system(cmd_args.join " ")
128
+ cmd_args << "-#{key} #{value}"
83
129
  end
130
+ ENV["PATH"] = "#{apparat_tk.scala_home}/bin#{File::PATH_SEPARATOR}#{ENV["PATH"]}" if apparat_tk.scala_home && !ENV["PATH"].include?("#{apparat_tk.scala_home}/bin")
131
+ puts "path:", ENV["PATH"]
132
+ puts "tdsi:",cmd_args.join(" "), system(cmd_args.join " ")
133
+ end
84
134
 
85
- def apparat_reducer(quality)
86
- output = Buildr::AS3::Compiler::CompilerUtils::get_output(project,compile.target,compile.packaging,compile.options)
87
- apparat_tk = compile.options[:apparat]
88
- cmd_args = []
89
- cmd_args << apparat_tk.reducer
90
- cmd_args << "-i #{output}"
91
- cmd_args << "-o #{output}"
92
- cmd_args << "-q"
93
- cmd_args << quality || 100
94
- system(cmd_args.join " ")
95
- end
135
+ def apparat_reducer(quality)
136
+ output = Buildr::AS3::Compiler::CompilerUtils::get_output(project, compile.target, compile.packaging, compile.options)
137
+ apparat_tk = compile.options[:apparat].invoke
138
+ cmd_args = []
139
+ cmd_args << "\"#{apparat_tk.reducer}\""
140
+ cmd_args << "-i #{output}"
141
+ cmd_args << "-o #{output}"
142
+ cmd_args << "-q"
143
+ cmd_args << quality || 100
144
+ ENV["PATH"] = "#{apparat_tk.scala_home}#{File::Separator}bin#{File::PATH_SEPARATOR}#{ENV["PATH"]}" if apparat_tk.scala_home && !ENV["PATH"].include?("#{apparat_tk.scala_home}/bin")
145
+ system(cmd_args.join " ")
96
146
  end
97
147
  end
148
+ end
98
149
  end
99
150
  class Project
100
151
  include Buildr::AS3::Apparat::Tasks
@@ -25,15 +25,15 @@ module Buildr
25
25
  module AS3
26
26
  module Compiler
27
27
  module CompilerUtils
28
- def self.get_output( project, target, package, options )
28
+ def self.get_output(project, target, package, options)
29
29
  return options[:output] if options.has_key? :output
30
30
  return "#{target}/#{File.basename(options[:main].to_s, File.extname(options[:main].to_s))}.swf" if package == :swf
31
31
  return "#{target}/#{project.name.gsub(":", "-")}.swc" if package == :swc
32
- fail( "Could not guess output file.")
32
+ fail("Could not guess output file.")
33
33
  end
34
34
 
35
35
  def needed?(sources, target, dependencies)
36
- output = CompilerUtils::get_output(project,target,project.compile.packaging,options)
36
+ output = CompilerUtils::get_output(project, target, project.compile.packaging, options)
37
37
  sources.each do |source|
38
38
  if is_output_outdated?(output, source)
39
39
  puts "Recompile of #{project.name} needed: Sources are newer than target"
@@ -50,12 +50,12 @@ module Buildr
50
50
  false
51
51
  end
52
52
 
53
- def is_output_outdated?(output,file_to_check)
53
+ def is_output_outdated?(output, file_to_check)
54
54
  return true unless File.exists? output
55
- older(output,file_to_check)
55
+ older(output, file_to_check)
56
56
  end
57
57
 
58
- def older(a,b) # a older than b
58
+ def older(a, b) # a older than b
59
59
  timestamp_from_file(a) < timestamp_from_file(b)
60
60
  end
61
61
 
@@ -93,8 +93,8 @@ module Buildr
93
93
  include CompilerUtils
94
94
 
95
95
  def compile(sources, target, dependencies)
96
- flex_sdk = options[:flexsdk]
97
- output = CompilerUtils::get_output(project,target,:swf,options)
96
+ flex_sdk = options[:flexsdk].invoke
97
+ output = CompilerUtils::get_output(project, target, :swf, options)
98
98
 
99
99
  cmd_args = []
100
100
  cmd_args << "-jar" << flex_sdk.mxmlc_jar
@@ -105,13 +105,13 @@ module Buildr
105
105
  cmd_args << "-source-path" << sources.join(" ")
106
106
  cmd_args << "-library-path+=#{dependencies.join(",")}" unless dependencies.empty?
107
107
  options[:debug] = Buildr.options.debug.to_s
108
- reserved = [:flexsdk,:main,:apparat]
108
+ reserved = [:flexsdk, :main, :apparat]
109
109
  options.to_hash.reject { |key, value| reserved.include?(key) }.
110
110
  each do |key, value|
111
- cmd_args << "-#{key}=#{value}"
111
+ cmd_args << "-#{key}=#{value}"
112
112
  end
113
113
  flex_sdk.default_options.each do |key, value|
114
- cmd_args << "-#{key}=#{value}"
114
+ cmd_args << "-#{key}=#{value}"
115
115
  end
116
116
 
117
117
  unless Buildr.application.options.dryrun
@@ -137,8 +137,8 @@ module Buildr
137
137
  include CompilerUtils
138
138
 
139
139
  def compile(sources, target, dependencies)
140
- flex_sdk = options[:flexsdk]
141
- output = CompilerUtils::get_output(project,target,:swf,options)
140
+ flex_sdk = options[:flexsdk].invoke
141
+ output = CompilerUtils::get_output(project, target, :swf, options)
142
142
 
143
143
  cmd_args = []
144
144
  cmd_args << "-jar" << flex_sdk.mxmlc_jar
@@ -150,13 +150,13 @@ module Buildr
150
150
  cmd_args << "-source-path" << sources.join(" ")
151
151
  cmd_args << "-library-path+=#{dependencies.join(",")}" unless dependencies.empty?
152
152
  options[:debug] = Buildr.options.debug.to_s
153
- reserved = [:flexsdk,:main,:apparat]
153
+ reserved = [:flexsdk, :main, :apparat]
154
154
  options.to_hash.reject { |key, value| reserved.include?(key) }.
155
155
  each do |key, value|
156
- cmd_args << "-#{key}=#{value}"
156
+ cmd_args << "-#{key}=#{value}"
157
157
  end
158
158
  flex_sdk.default_options.each do |key, value|
159
- cmd_args << "-#{key}=#{value}"
159
+ cmd_args << "-#{key}=#{value}"
160
160
  end
161
161
 
162
162
  unless Buildr.application.options.dryrun
@@ -171,6 +171,7 @@ module Buildr
171
171
  :target => "bin", :target_ext => "swc",
172
172
  :packaging => :swc
173
173
  attr_reader :project
174
+
174
175
  def initialize(project, options)
175
176
  super
176
177
  @project = project
@@ -179,8 +180,8 @@ module Buildr
179
180
  include CompilerUtils
180
181
 
181
182
  def compile(sources, target, dependencies)
182
- flex_sdk = options[:flexsdk]
183
- output = CompilerUtils::get_output(project,target,:swc,options)
183
+ flex_sdk = options[:flexsdk].invoke
184
+ output = CompilerUtils::get_output(project, target, :swc, options)
184
185
  cmd_args = []
185
186
  cmd_args << "-jar" << flex_sdk.compc_jar
186
187
  cmd_args << "-output" << output
@@ -188,14 +189,14 @@ module Buildr
188
189
  cmd_args << "-load-config" << flex_sdk.flex_config
189
190
  cmd_args << "-include-sources" << sources.join(" ")
190
191
  cmd_args << "-library-path+=#{dependencies.join(",")}" unless dependencies.empty?
191
- reserved = [:flexsdk,:main,:apparat]
192
+ reserved = [:flexsdk, :main, :apparat]
192
193
  options[:debug] = Buildr.options.debug.to_s
193
194
  options.to_hash.reject { |key, value| reserved.include?(key) }.
194
195
  each do |key, value|
195
- cmd_args << "-#{key}=#{value}"
196
- end
196
+ cmd_args << "-#{key}=#{value}"
197
+ end
197
198
  flex_sdk.default_options.each do |key, value|
198
- cmd_args << "-#{key}=#{value}"
199
+ cmd_args << "-#{key}=#{value}"
199
200
  end
200
201
 
201
202
  unless Buildr.application.options.dryrun
@@ -210,6 +211,7 @@ module Buildr
210
211
  :target => "bin", :target_ext => "swc",
211
212
  :packaging => :swc
212
213
  attr_reader :project
214
+
213
215
  def initialize(project, options)
214
216
  super
215
217
  @project = project
@@ -218,8 +220,8 @@ module Buildr
218
220
  include CompilerUtils
219
221
 
220
222
  def compile(sources, target, dependencies)
221
- flex_sdk = options[:flexsdk]
222
- output = CompilerUtils::get_output(project,target,:swc,options)
223
+ flex_sdk = options[:flexsdk].invoke
224
+ output = CompilerUtils::get_output(project, target, :swc, options)
223
225
  cmd_args = []
224
226
  cmd_args << "-jar" << flex_sdk.compc_jar
225
227
  cmd_args << "-output" << output
@@ -229,13 +231,13 @@ module Buildr
229
231
  cmd_args << "-include-sources" << sources.join(" ")
230
232
  cmd_args << "-library-path+=#{dependencies.join(",")}" unless dependencies.empty?
231
233
  options[:debug] = Buildr.options.debug.to_s
232
- reserved = [:flexsdk,:main,:apparat]
234
+ reserved = [:flexsdk, :main, :apparat]
233
235
  options.to_hash.reject { |key, value| reserved.include?(key) }.
234
236
  each do |key, value|
235
- cmd_args << "-#{key}=#{value}"
236
- end
237
+ cmd_args << "-#{key}=#{value}"
238
+ end
237
239
  flex_sdk.default_options.each do |key, value|
238
- cmd_args << "-#{key}=#{value}"
240
+ cmd_args << "-#{key}=#{value}"
239
241
  end
240
242
 
241
243
  unless Buildr.application.options.dryrun
@@ -33,7 +33,7 @@ module Buildr
33
33
  dependencies = project.compile.dependencies
34
34
  sources = project.compile.sources
35
35
  flex_sdk = options[:flexsdk]
36
- output = (options[:output] || "#{target}")
36
+ output = (options[:output] || "#{target}")
37
37
  cmd_args = []
38
38
  cmd_args << "-classpath" << "#{flex_sdk.home}/lib/xalan.jar"
39
39
  cmd_args << "-classpath" << flex_sdk.asdoc_jar
@@ -45,13 +45,13 @@ module Buildr
45
45
  cmd_args << "-doc-sources" << sources.join(" ")
46
46
  cmd_args << "-templates-path" << flex_sdk.asdoc_templates
47
47
  cmd_args << "-library-path+=#{dependencies.join(",")}" unless dependencies.empty?
48
- reserved = [:flexsdk,:main,:classpath,:sourcepath]
48
+ reserved = [:flexsdk, :main, :classpath, :sourcepath]
49
49
  options.to_hash.reject { |key, value| reserved.include?(key) }.
50
50
  each do |key, value|
51
- cmd_args << "-#{key}=#{value}"
52
- end
51
+ cmd_args << "-#{key}=#{value}"
52
+ end
53
53
  flex_sdk.default_options.each do |key, value|
54
- cmd_args << "-#{key}=#{value}"
54
+ cmd_args << "-#{key}=#{value}"
55
55
  end
56
56
  unless Buildr.application.options.dryrun
57
57
  Java::Commands.java cmd_args
@@ -19,6 +19,10 @@
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 'tmpdir'
23
+ require "open-uri"
24
+ require "fileutils"
25
+
22
26
  module Buildr
23
27
  module AS3
24
28
  module Flex
@@ -29,22 +33,69 @@ module Buildr
29
33
 
30
34
  attr_writer :flex_config, :air_config, :asdoc_templates
31
35
 
32
- def initialize(sdk_opts = {})
33
-
36
+ def initialize(version)
37
+ @version = version
34
38
  @default_options = {}
39
+ @spec = "com.adobe.flex:sdk:zip:#{@version}"
40
+ @sdk_zip = Buildr.artifact(@spec)
41
+ @sdk_dir = File.join(File.dirname(@sdk_zip.to_s), "sdk-#{@version}")
42
+ generate_paths @sdk_dir
43
+ self
44
+ end
35
45
 
36
- generate_url(sdk_opts)
46
+ def invoke
47
+ @url ||= generate_url_from_version @version
48
+
49
+ if Buildr::Util.win_os?
50
+ unless File.exists? @sdk_zip.to_s
51
+ FileUtils.mkdir_p File.dirname(@sdk_zip.to_s) unless File.directory? File.dirname(@sdk_zip.to_s)
52
+ File.open @sdk_zip.to_s, 'w' do |file|
53
+ file.binmode()
54
+ URI.read(@url, {:progress=>true}) { |chunk| file.write chunk }
55
+ end
56
+ end
57
+ else
58
+ Buildr.artifact(@spec).from(Buildr.download(@url)).invoke unless File.exists? @sdk_zip.to_s
59
+ end
37
60
 
38
- sdk_zip = Buildr::artifact("com.adobe.flex:sdk:zip:#{sdk_opts[:sdk_version]}").from(Buildr::download(sdk_opts[:sdk_url]))
39
- sdk_zip.invoke unless File.exists? sdk_zip.to_s
40
- sdk_dir = File.join(File.dirname(sdk_zip.to_s), "sdk-#{sdk_opts[:sdk_version]}")
41
61
 
42
- unless File.exists? sdk_dir
43
- puts "Unzipping FlexSDK, this may take a while."
44
- Buildr::unzip("#{sdk_dir}"=>sdk_zip.to_s).target.invoke
62
+ unless File.exists? @sdk_dir
63
+ puts "Unzipping FlexSDK, this might take a while."
64
+ if Buildr::Util.win_os?
65
+ puts "Please make sure unzip is installed and in your PATH variable!"
66
+ unzip @sdk_zip, @sdk_dir
67
+ else
68
+ begin
69
+ Buildr.unzip(@sdk_dir.to_s=>@sdk_zip.to_s).target.invoke
70
+ rescue TypeError
71
+ puts "RubyZip extract failed, trying system unzip now."
72
+ unzip @sdk_zip, @sdk_dir
73
+ end
74
+ end
45
75
  end
76
+ self
77
+ end
78
+
79
+ def from(url)
80
+ @url = url
81
+ self
82
+ end
83
+
84
+ protected
46
85
 
47
- @home = sdk_dir
86
+ def unzip(zip, destination)
87
+ project_dir = Dir.getwd
88
+ Dir.chdir File.dirname(zip.to_s)
89
+ system("unzip #{File.basename(zip.to_s).to_s} -d #{File.basename(destination).to_s}")
90
+ Dir.chdir project_dir
91
+ end
92
+
93
+ def generate_url_from_version(version)
94
+ "http://fpdownload.adobe.com/pub/flex/sdk/builds/flex#{version.split(".")[0]}/flex_sdk_#{version}.zip"
95
+ end
96
+
97
+ def generate_paths(home_dir)
98
+ @home = home_dir
48
99
  @mxmlc_jar = "#{@home}/lib/mxmlc.jar"
49
100
  @compc_jar = "#{@home}/lib/compc.jar"
50
101
  @asdoc_jar = "#{@home}/lib/asdoc.jar"
@@ -55,14 +106,8 @@ module Buildr
55
106
  @flex_config = "#{@home}/frameworks/flex-config.xml"
56
107
  @air_config = "#{@home}/frameworks/air-config.xml"
57
108
  @bin = "#{@home}/bin"
109
+ true
58
110
  end
59
-
60
- protected
61
-
62
- def generate_url(opts = {})
63
- opts[:sdk_url] ||= "http://fpdownload.adobe.com/pub/flex/sdk/builds/flex#{opts[:sdk_version].split(".")[0]}/flex_sdk_#{opts[:sdk_version]}.zip"
64
- end
65
-
66
111
  end
67
112
  end
68
113
  end
@@ -40,10 +40,10 @@ module Buildr
40
40
  after_define("as3:fdt4:generate" => :package) do |project|
41
41
  project.task("as3:fdt4:generate") do
42
42
  fail("Cannot create fdt4 projects on Windows machines, no support for symlinks.") unless !Buildr::Util.win_os?
43
- if [:mxmlc,:compc,:airmxmlc,:aircompc].include? project.compile.compiler
43
+ if [:mxmlc, :compc, :airmxmlc, :aircompc].include? project.compile.compiler
44
44
  output = project.base_dir + "/.settings/com.powerflasher.fdt.classpath"
45
45
  puts "Writing FDT4 classpath file: #{output}"
46
- puts "WARNING: This will create symlinks in #{project.path_to(:lib,:main,:as3)} as FDT4 doesn't support referencing files outside of the project folder."
46
+ puts "WARNING: This will create symlinks in #{project.path_to(:lib, :main, :as3)} as FDT4 doesn't support referencing files outside of the project folder."
47
47
  sdk_based_libs = []
48
48
  sdk_based_libs << "frameworks/libs/player/{playerVersion}/playerglobal.swc"
49
49
  sdk_based_libs << "frameworks/libs/flex.swc"
@@ -55,7 +55,7 @@ module Buildr
55
55
  sdk_based_libs << "frameworks/libs/sparkskins.swc"
56
56
  sdk_based_libs << "frameworks/libs/datavisualization.swc"
57
57
 
58
- if [:airmxmlc,:aircompc].include? project.compile.compiler
58
+ if [:airmxmlc, :aircompc].include? project.compile.compiler
59
59
  sdk_based_libs << "frameworks/libs/air/airglobal.swc"
60
60
  sdk_based_libs << "frameworks/libs/air/airframework.swc"
61
61
  sdk_based_libs << "frameworks/libs/air/airspark.swc"
@@ -69,37 +69,37 @@ module Buildr
69
69
  classpath_xml.instruct!
70
70
  classpath_xml.AS3Classpath do
71
71
  sdk_based_libs.each do |sdk_lib|
72
- classpath_xml.AS3Classpath( sdk_lib, :generateProblems => false, :sdkBased => true, :type => "lib", :useAsSharedCode => "false" )
72
+ classpath_xml.AS3Classpath(sdk_lib, :generateProblems => false, :sdkBased => true, :type => "lib", :useAsSharedCode => "false")
73
73
  end
74
74
  project.compile.sources.each do |source|
75
- classpath_xml.AS3Classpath( project.get_eclipse_relative_path(project,source), :generateProblems => true, :sdkBased => false, :type => project.get_fdt4_classpath_type(source), :useAsSharedCode => "false" )
75
+ classpath_xml.AS3Classpath(project.get_eclipse_relative_path(project, source), :generateProblems => true, :sdkBased => false, :type => project.get_fdt4_classpath_type(source), :useAsSharedCode => "false")
76
76
  end
77
- unless File.directory? project.path_to(:lib,:main,:as3)
77
+ unless File.directory? project.path_to(:lib, :main, :as3)
78
78
  #:dummy is just a bogus thing, it somehow stops creating the folders a layer to early
79
- FileUtils.mkdir_p File.dirname(project.path_to(:lib,:main,:as3,:dummy))
79
+ FileUtils.mkdir_p File.dirname(project.path_to(:lib, :main, :as3, :dummy))
80
80
  end
81
81
  project.compile.dependencies.each do |dependency|
82
- dependency = project.create_fdt4_dependency_symlink( project, dependency )
83
- classpath_xml.AS3Classpath( project.get_eclipse_relative_path(project,dependency), :generateProblems => false, :sdkBased => false, :type => project.get_fdt4_classpath_type(dependency), :useAsSharedCode => "false" )
82
+ dependency = project.create_fdt4_dependency_symlink(project, dependency)
83
+ classpath_xml.AS3Classpath(project.get_eclipse_relative_path(project, dependency), :generateProblems => false, :sdkBased => false, :type => project.get_fdt4_classpath_type(dependency), :useAsSharedCode => "false")
84
84
  end
85
85
  end
86
86
 
87
87
  unless File.directory? File.dirname(output)
88
88
  Dir.mkdir File.dirname(output)
89
89
  end
90
- File.open(output, 'w') {|f| f.write(contents) }
90
+ File.open(output, 'w') { |f| f.write(contents) }
91
91
  end
92
92
  end
93
93
  end
94
94
 
95
- def create_fdt4_dependency_symlink( project, dependency )
95
+ def create_fdt4_dependency_symlink(project, dependency)
96
96
  case source
97
97
  when Buildr::Artifact then
98
98
  path = dependency.name
99
99
  else
100
100
  path = dependency.to_s
101
101
  end
102
- target = project.path_to(:lib,:main,:as3) + "/" + File.basename(path)
102
+ target = project.path_to(:lib, :main, :as3) + "/" + File.basename(path)
103
103
  unless target != path
104
104
  File.delete(target) if File.exists?(target)
105
105
  File.symlink path, target
@@ -107,7 +107,7 @@ module Buildr
107
107
  target
108
108
  end
109
109
 
110
- def get_eclipse_relative_path( project, source )
110
+ def get_eclipse_relative_path(project, source)
111
111
  case source
112
112
  when Buildr::Artifact then
113
113
  path = source.name
@@ -117,14 +117,14 @@ module Buildr
117
117
  Util.relative_path(File.expand_path(path), project.base_dir)
118
118
  end
119
119
 
120
- def get_fdt4_classpath_type( source )
120
+ def get_fdt4_classpath_type(source)
121
121
  case source
122
122
  when Buildr::Artifact then
123
- return "source" if File.directory?( source.name )
123
+ return "source" if File.directory?(source.name)
124
124
  return "lib" if File.extname(source.name) == ".swc"
125
125
  else
126
126
 
127
- return "source" if File.directory?( source.to_s )
127
+ return "source" if File.directory?(source.to_s)
128
128
  return "lib" if File.extname(source.to_s) == ".swc"
129
129
  end
130
130
  "Could not guess type!"
@@ -37,7 +37,7 @@ module Buildr
37
37
  super
38
38
  enhance do
39
39
  fail "File not found: #{src_swc}" unless File.exists? src_swc
40
- File.copy( src_swc, target_swc )
40
+ File.copy(src_swc, target_swc)
41
41
  end
42
42
  end
43
43
 
@@ -70,7 +70,7 @@ module Buildr
70
70
  super
71
71
  enhance do
72
72
  fail "File not found: #{src_swf}" unless File.exists? src_swf
73
- File.copy( src_swf, target_swf )
73
+ File.copy(src_swf, target_swf)
74
74
  end
75
75
  end
76
76
 
@@ -156,7 +156,7 @@ module Buildr
156
156
  args.each do |arg|
157
157
  case arg
158
158
  when Hash
159
- arg.each do |key,value|
159
+ arg.each do |key, value|
160
160
  @libs[key] = value
161
161
  end
162
162
  end
@@ -183,15 +183,15 @@ module Buildr
183
183
  def package_as_swc(file_name)
184
184
  fail("Package types don't match! :swc vs. :#{compile.packaging.to_s}") unless compile.packaging == :swc
185
185
  SwcTask.define_task(file_name).tap do |swc|
186
- swc.src_swc = Buildr::AS3::Compiler::CompilerUtils::get_output(project,compile.target,:swc,compile.options)
186
+ swc.src_swc = Buildr::AS3::Compiler::CompilerUtils::get_output(project, compile.target, :swc, compile.options)
187
187
  swc.target_swc = file_name
188
188
  end
189
189
  end
190
190
 
191
191
  def package_as_swf(file_name)
192
- fail("Package types don't match! :swf vs. :#{compile.packaging.to_s}") unless compile.packaging == :swf
192
+ fail("Package types don't match! :swf vs. :#{compile.packaging.to_s}") unless compile.packaging == :swf
193
193
  SwfTask.define_task(file_name).tap do |swf|
194
- swf.src_swf = Buildr::AS3::Compiler::CompilerUtils::get_output(project,compile.target,:swf,compile.options)
194
+ swf.src_swf = Buildr::AS3::Compiler::CompilerUtils::get_output(project, compile.target, :swf, compile.options)
195
195
  swf.target_swf = file_name
196
196
  end
197
197
  end
@@ -199,7 +199,7 @@ module Buildr
199
199
  def package_as_air(file_name)
200
200
  fail("Package types don't match! :swf vs. :#{compile.packaging.to_s}") unless compile.packaging == :swf
201
201
  AirTask.define_task(file_name).tap do |swf|
202
- swf.src_swf = Buildr::AS3::Compiler::CompilerUtils::get_output(project,compile.target,:swf,compile.options)
202
+ swf.src_swf = Buildr::AS3::Compiler::CompilerUtils::get_output(project, compile.target, :swf, compile.options)
203
203
  swf.target_air = file_name
204
204
  swf.flexsdk = compile.options[:flexsdk]
205
205
  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: 59
4
+ hash: 57
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 16
10
- version: 0.1.16
9
+ - 17
10
+ version: 0.1.17
11
11
  platform: ruby
12
12
  authors:
13
13
  - Dominic Graefen