/
Rakefile
430 lines (357 loc) · 13.1 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
require 'find'
require 'erb'
require 'rhodes/rhodes-build/lib/jake.rb'
load 'platform/bb/build/bb.rake'
load 'platform/android/build/android.rake'
load 'platform/iphone/rbuild/iphone.rake'
load 'platform/wm/build/wm.rake'
namespace "config" do
task :common do
$startdir = File.dirname(__FILE__)
buildyml = 'rhobuild.yml'
buildyml = ENV["RHOBUILD"] unless ENV["RHOBUILD"].nil?
$config = Jake.config(File.open(buildyml))
if RUBY_PLATFORM =~ /(win|w)32$/
$all_files_mask = "*.*"
else
$all_files_mask = "*"
end
end
end
namespace "build" do
namespace "bundle" do
task :xruby do
#needs $config, $srcdir, $excludelib, $bindir
app = $config["env"]["app"]
startdir = pwd
rhodeslib = "rhodes/rhodes-framework/lib"
rm_rf $srcdir
mkdir_p $srcdir
mkdir_p File.join($srcdir,'apps')
xruby = File.dirname(__FILE__) + '/rhodes/rhodes-build/res/xruby-0.3.3.jar'
dest = startdir + "/" + $srcdir
chdir rhodeslib
Dir.glob("*").each { |f|
src = f
cp_r src,dest
}
chdir dest
Dir.glob("**/rhodes-framework.rb").each {|f| rm f}
Dir.glob("**/erb.rb").each {|f| rm f}
Dir.glob("**/find.rb").each {|f| rm f}
$excludelib.each {|e| Dir.glob(e).each {|f| rm f}}
chdir startdir
#throw "ME"
cp_r app + '/app',File.join($srcdir,'apps')
cp_r app + '/public', File.join($srcdir,'apps')
cp app + '/rhoconfig.txt', File.join($srcdir,'apps')
chdir File.join($srcdir,'apps/public')
rm_rf 'js/iui'
Dir.glob("js/jquery*").each {|f| rm_rf f}
Dir.glob("js/prototype*").each {|f| rm f}
chdir startdir
#create manifest
dir = File.join($srcdir, 'apps')
fname = "config.rb"
fappManifest = File.new( File.join(dir,'app_manifest.txt'), "w")
Find.find(dir) do |path|
if File.basename(path) == fname
relPath = path[dir.length+1, File.dirname(path).length-1] #relative path
relPath = relPath[0, relPath.length-3] #remove .rb extension
fappManifest.puts( relPath )
end
end
fappManifest.close()
#"compile ERB"
ext = ".erb"
Find.find($srcdir) do |path|
if File.extname(path) == ext
rbText = ERB.new( IO.read(path) ).src
newName = File.basename(path).sub('.erb','_erb.rb')
fName = File.join(File.dirname(path), newName)
frb = File.new(fName, "w")
frb.write( rbText )
frb.close()
end
end
chdir $bindir
puts `java -jar "#{xruby}" -v -c RhoBundle 2>&1`
chdir startdir
chdir $srcdir
Dir.glob("**/*.rb") { |f| rm f }
Dir.glob("**/*.erb") { |f| rm f }
puts `jar uf ../RhoBundle.jar apps/#{$all_files_mask}`
chdir startdir
end
task :noxruby do
end
end
end
# Simple rakefile that loads subdirectory 'rhodes' Rakefile
# run "rake -T" to see list of available tasks
desc "Get versions"
task :get_version do
bbver = "unknown"
iphonever = "unknown"
#symver = "unknown"
wmver = "unknown"
androidver = "unknown"
File.open("rhobuild.yml","r") do |f|
file = f.read
if file.match(/version: (\d+\.\d+\.\d+)/)
bbver = $1
end
end
File.open("platform/iphone/Info.plist","r") do |f|
file = f.read
if file.match(/CFBundleVersion<\/key>\s+<string>(\d+\.\d+\.*\d*)<\/string>/)
iphonever = $1
end
end
# File.open("platform/symbian/build/release.properties","r") do |f|
# file = f.read
# major = ""
# minor = ""
# build = ""
#
# if file.match(/release\.major=(\d+)/)
# major = $1
# end
# if file.match(/release\.minor=(\d+)/)
# minor = $1
# end
# if file.match(/build\.number=(\d+)/)
# build = $1
# end
#
# symver = major + "." + minor + "." + build
# end
File.open("platform/android/Rhodes/AndroidManifest.xml","r") do |f|
file = f.read
if file.match(/versionName="(\d+\.\d+\.*\d*)"/)
androidver = $1
end
end
rhodesver = "unknown"
rbuildver = "unknown"
rframever = "unknown"
rgenver = "unknown"
File.open("rhodes/rhodes/lib/rhodes.rb","r") do |f|
file = f.read
if file.match(/VERSION = '(\d+\.\d+\.*\d*)'/)
rhodesver = $1
end
end
File.open("rhodes/rhodes-build/lib/version.rb","r") do |f|
file = f.read
if file.match(/VERSION = '(\d+\.\d+\.*\d*)'/)
rbuildver = $1
end
end
File.open("rhodes/rhodes-framework/lib/version.rb","r") do |f|
file = f.read
if file.match(/VERSION = '(\d+\.\d+\.*\d*)'/)
rframever = $1
end
end
File.open("rhodes/rhodes-generator/lib/version.rb","r") do |f|
file = f.read
if file.match(/VERSION = '(\d+\.\d+\.*\d*)'/)
rgenver = $1
end
end
puts "Versions:"
puts " Blackberry: " + bbver
puts " iPhone: " + iphonever
#puts " Symbian: " + symver
puts " WinMo: " + wmver
puts " Android: " + androidver
puts " Rhodes: " + rhodesver
puts " Rhodes Build: " + rbuildver
puts " Rhodes Framework: " + rframever
puts " Rhodes Generator: " + rgenver
end
desc "Set version"
task :set_version, [:version] do |t,args|
throw "You must pass in version" if args.version.nil?
ver = args.version.split(/\./)
major = ver[0]
minor = ver[1]
build = ver[2]
throw "Invalid version format. Must be in the format of: major.minor.build" if major.nil? or minor.nil? or build.nil?
verstring = major+"."+minor+"."+build
origfile = ""
File.open("rhobuild.yml","r") { |f| origfile = f.read }
File.open("rhobuild.yml","w") do |f|
f.write origfile.gsub(/version: (\d+\.\d+\.\d+)/, "version: #{verstring}")
end
File.open("rhodes/rhodes-generator/generators/templates/application/build.yml","r") { |f| origfile = f.read }
File.open("rhodes/rhodes-generator/generators/templates/application/build.yml","w") do |f|
f.write origfile.gsub(/version: (\d+\.\d+\.\d+)/, "version: #{verstring}")
end
File.open("platform/iphone/Info.plist","r") { |f| origfile = f.read }
File.open("platform/iphone/Info.plist","w") do |f|
f.write origfile.gsub(/CFBundleVersion<\/key>(\s+)<string>(\d+\.\d+\.*\d*)<\/string>/, "CFBundleVersion</key>\n <string>#{verstring}</string>")
end
# File.open("platform/symbian/build/release.properties","r") { |f| origfile = f.read }
# File.open("platform/symbian/build/release.properties","w") do |f|
# origfile.gsub!(/release\.major=(\d+)/,"release.major=#{major}")
# origfile.gsub!(/release\.minor=(\d+)/,"release.minor=#{minor}")
# origfile.gsub!(/build\.number=(\d+)/,"build.number=#{build}")
# f.write origfile
# end
File.open("platform/android/Rhodes/AndroidManifest.xml","r") { |f| origfile = f.read }
File.open("platform/android/Rhodes/AndroidManifest.xml","w") do |f|
origfile.match(/versionCode="(\d+)"/)
vercode = $1.to_i + 1
origfile.gsub!(/versionCode="(\d+)"/,"versionCode=\"#{vercode}\"")
origfile.gsub!(/versionName="(\d+\.\d+\.*\d*)"/,"versionName=\"#{verstring}\"")
f.write origfile
end
["rhodes/rhodes/lib/rhodes.rb",
"rhodes/rhodes-build/lib/version.rb",
"rhodes/rhodes-framework/lib/version.rb",
"rhodes/rhodes-framework/lib/rhodes.rb",
"rhodes/rhodes-generator/lib/version.rb"].each do |versionfile|
File.open(versionfile,"r") { |f| origfile = f.read }
File.open(versionfile,"w") do |f|
origfile.gsub!(/VERSION = '(\d+\.\d+\.*\d*)'/, "VERSION = '#{verstring}'")
origfile.gsub!(/DBVERSION = '(\d+\.\d+\.*\d*)'/, "DBVERSION = '#{verstring}'")
f.write origfile
end
end
Rake::Task[:get_version].invoke
end
namespace "prebuild" do
desc "Prebuild binaries for WM gems"
task :wm do
basedir = pwd
if RUBY_PLATFORM =~ /(win|w)32$/
rake = "cmd.exe /c rake"
ant = "ant.bat"
else
rake = "rake"
ant = "ant"
end
chdir 'platform/wm/build'
zip = File.join(basedir,'rhodes/rhodes-build/res/7z.exe')
puts `#{rake} compile`
chdir '../bin'
throw "windows build missing" if not File.exists? 'Windows Mobile 6 Professional SDK (ARMV4I)'
puts `#{zip} a -mx=9 -r wm6.7z "Windows Mobile 6 Professional SDK (ARMV4I)"`
throw "windows zip missing" if not File.exists? 'wm6.7z'
cp "wm6.7z", "../../../rhodes/rhodes-build/res/prebuilt/wm"
chdir basedir
# chdir "platform/symbian/build"
# filecontents = ""
# File.open("build.properties","r") { |f| filecontents = f.read }
# File.open("build.properties","w") do |f|
# filecontents.gsub!(/build\.target=[A-Z ]+/,"build.target=GCCE UREL")
# f.write filecontents
# end
# if filecontents.match(/S60_3rd_FP1=(.+)/)
# epoc32 = $1
# else
# epoc32 = "\\Symbian\\9.2\\S60_3rd_FP1\\"
# end
#
# epoc32.gsub!(/\\\\/,"\\")
#
# puts `#{ant} build-prebuilt -DSDK=S60_3rd_FP1`
# puts "Looking for: " + File.join(epoc32,"Epoc32\\release\\gcce\\urel\\rhodes.exe")
# throw "symbian rhodes.exe missing" if not File.exists?(File.join(epoc32,"Epoc32\\release\\gcce\\urel\\rhodes.exe"))
#
# prebuilt = "../../../rhodes/rhodes-build/res/prebuilt/symbian/"
#
# rm_rf prebuilt + "Epoc32"
#
# mkdir_p prebuilt + "Epoc32/data/z/private/10003a3f"
# mkdir_p prebuilt + "Epoc32/data/z/resource"
# mkdir_p prebuilt + "Epoc32/data/z/system"
# mkdir_p prebuilt + "Epoc32/release/gcce/urel"
#
# cp_r epoc32 + "Epoc32\\data\\z\\private\\10003a3f\\apps\\", prebuilt + "Epoc32/data/z/private/10003a3f/", :verbose => true
# cp_r epoc32 + "Epoc32\\data\\z\\resource\\apps\\", prebuilt + "Epoc32/data/z/resource/"
# cp_r epoc32 + "Epoc32\\data\\z\\system\\data\\", prebuilt + "Epoc32/data/z/system/"
# cp_r epoc32 + "Epoc32\\release\\gcce\\urel\\rhodes.exe", prebuilt + "Epoc32/release/gcce/urel/"
#
#
#
# File.open("build.properties","w") do |f|
# filecontents.gsub!(/build\.target=[A-Z ]+/,"build.target=WINSCW UDEB")
# f.write filecontents
# end
#
#
#
# puts `#{ant} build-prebuilt -DSDK=S60_3rd_FP1`
# puts "Looking for: " + File.join(epoc32,"Epoc32\\release\\winscw\\deb\\rhodes.exe")
# throw "symbian rhodes.exe missing" if not File.exists?(File.join(epoc32,"Epoc32\\release\\winscw\\udeb\\rhodes.exe"))
#
# mkdir_p prebuilt + "Epoc32/winscw/c/Data/Rho"
# mkdir_p prebuilt + "Epoc32/release/winscw/udeb"
#
# cp_r epoc32 + "Epoc32\\winscw\\c\\Data\\Rho\\rhologpath.txt", prebuilt + "Epoc32/winscw/c/data/Rho"
# cp_r epoc32 + "Epoc32\\release\\winscw\\udeb\\rhodes.exe", prebuilt + "Epoc32/release/winscw/udeb/"
end
desc "Prebuild iPhone binaries for gems"
task :iphone do
basedir = pwd
rake = "rake"
ant = "ant"
prebuilt = "../../../rhodes/rhodes-build/res/prebuilt/iphone/"
chdir 'platform/iphone/rbuild'
# Simulator
puts `#{ant} clean -Diphone.sdk=iphonesimulator2.2.1 -Diphone.config=Debug`
puts `#{ant} buildapp -Diphone.sdk=iphonesimulator2.2.1 -Diphone.config=Debug`
throw "cant find rhorunner.app!" if not File.exists? "../build/Debug-iphonesimulator/rhorunner.app"
mkdir_p prebuilt + "sim"
rm_rf prebuilt + "sim/rhorunner.app"
cp_r "../build/Debug-iphonesimulator/rhorunner.app", prebuilt + "sim/"
rm_rf prebuilt + "sim/rhorunner.app/apps"
rm_rf prebuilt + "sim/rhorunner.app/lib"
chdir basedir
# Device
#chdir 'platform/iphone/rbuild'
#puts `#{ant} clean -Diphone.sdk=iphoneos2.2.1 -Diphone.config=Release`
#puts `#{ant} buildapp -Diphone.sdk=iphoneos2.2.1 -Diphone.config=Release`
#throw "cant find rhorunner.app!" if not File.exists? "../build/Release-iphoneos/rhorunner.app"
#mkdir_p prebuilt + "device"
#rm_rf prebuilt + "device/rhorunner.app"
#cp_r "../build/Release-iphoneos/rhorunner.app", prebuilt + "device/"
#rm_rf prebuilt + "device/rhorunner.app/apps"
#rm_rf prebuilt + "device/rhorunner.app/lib"
#chdir basedir
end
end
namespace "buildall" do
namespace "bb" do
desc "Build all jdk versions for blackberry"
task :production => "config:common" do
$config["env"]["paths"].each do |k,v|
if k.to_s =~ /^4/
puts "BUILDING VERSION: #{k}"
$config["env"]["bbver"] = k
Jake.reconfig($config)
#reset all tasks used for building
Rake::Task["config:bb"].reenable
Rake::Task["build:bb:rhobundle"].reenable
Rake::Task["build:bb:rhodes"].reenable
Rake::Task["build:bb:rubyvm"].reenable
Rake::Task["device:bb:dev"].reenable
Rake::Task["device:bb:production"].reenable
Rake::Task["device:bb:rhobundle"].reenable
Rake::Task["package:bb:dev"].reenable
Rake::Task["package:bb:production"].reenable
Rake::Task["package:bb:rhobundle"].reenable
Rake::Task["package:bb:rhodes"].reenable
Rake::Task["package:bb:rubyvm"].reenable
Rake::Task["device:bb:production"].reenable
Rake::Task["clean:bb:preverified"].reenable
Rake::Task["clean:bb:preverified"].invoke
Rake::Task["device:bb:production"].invoke
end
end
end
end
end