forked from rhomobile/rhodes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
1163 lines (941 loc) · 34.8 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
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#------------------------------------------------------------------------
# (The MIT License)
#
# Copyright (c) 2008-2011 Rhomobile, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
# http://rhomobile.com
#------------------------------------------------------------------------
require 'find'
require 'erb'
require 'rdoc/task'
require 'digest/sha2'
require 'rexml/document'
#Look, another big fat hack. Make it so we can remove tasks from rake -T by setting comment to nil
module Rake
class Task
attr_accessor :comment
end
end
$app_basedir = pwd
chdir File.dirname(__FILE__)
require File.join(pwd, 'lib/build/jake.rb')
load File.join(pwd, 'platform/bb/build/bb.rake')
load File.join(pwd, 'platform/android/build/android.rake')
load File.join(pwd, 'platform/iphone/rbuild/iphone.rake')
load File.join(pwd, 'platform/wm/build/wm.rake')
load File.join(pwd, 'platform/linux/tasks/linux.rake')
load File.join(pwd, 'platform/wp7/build/wp.rake')
load File.join(pwd, 'platform/symbian/build/symbian.rake')
load File.join(pwd, 'platform/osx/build/osx.rake')
def get_dir_hash(dir, init = nil)
hash = init
hash = Digest::SHA2.new if hash.nil?
Dir.glob(dir + "/**/*").each do |f|
hash << f
hash.file(f) if File.file? f
end
hash
end
namespace "framework" do
task :spec do
loadpath = $LOAD_PATH.inject("") { |load_path,pe| load_path += " -I" + pe }
rhoruby = ""
if RUBY_PLATFORM =~ /(win|w)32$/
rhoruby = 'res\\build-tools\\RhoRuby'
elsif RUBY_PLATFORM =~ /darwin/
rhoruby = 'res/build-tools/RubyMac'
else
rhoruby = 'res/build-tools/rubylinux'
end
puts `#{rhoruby} -I#{File.expand_path('spec/framework_spec/app/')} -I#{File.expand_path('lib/framework')} -I#{File.expand_path('lib/test')} -Clib/test framework_test.rb`
end
end
$application_build_configs_keys = ['security_token', 'encrypt_database', 'android_title']
def make_application_build_config_header_file
f = StringIO.new("", "w+")
f.puts "// WARNING! THIS FILE IS GENERATED AUTOMATICALLY! DO NOT EDIT IT MANUALLY!"
#f.puts "// Generated #{Time.now.to_s}"
f.puts ""
f.puts "#include <string.h>"
f.puts ""
f.puts '#include "app_build_configs.h"'
f.puts ""
f.puts 'static const char* keys[] = { ""'
$application_build_configs.keys.each do |key|
f.puts ',"'+key+'"'
end
f.puts '};'
f.puts ''
count = 1
f.puts 'static const char* values[] = { ""'
$application_build_configs.keys.each do |key|
f.puts ',"'+$application_build_configs[key].to_s+'"'
count = count + 1
end
f.puts '};'
f.puts ''
f.puts '#define APP_BUILD_CONFIG_COUNT '+count.to_s
f.puts ''
f.puts 'const char* get_app_build_config_item(const char* key) {'
f.puts ' int i;'
f.puts ' for (i = 1; i < APP_BUILD_CONFIG_COUNT; i++) {'
f.puts ' if (strcmp(key, keys[i]) == 0) {'
f.puts ' return values[i];'
f.puts ' }'
f.puts ' }'
f.puts ' return 0;'
f.puts '}'
f.puts ''
Jake.modify_file_if_content_changed(File.join($startdir, "platform", "shared", "common", "app_build_configs.c"), f)
end
def make_application_build_capabilities_header_file
f = StringIO.new("", "w+")
f.puts "// WARNING! THIS FILE IS GENERATED AUTOMATICALLY! DO NOT EDIT IT MANUALLY!"
#f.puts "// Generated #{Time.now.to_s}"
f.puts ""
caps = []
capabilities = $app_config["capabilities"]
if capabilities != nil && capabilities.is_a?(Array)
capabilities.each do |cap|
caps << cap
end
end
caps.sort.each do |cap|
f.puts '#define APP_BUILD_CAPABILITY_'+cap.upcase
end
f.puts ''
Jake.modify_file_if_content_changed(File.join($startdir, "platform", "shared", "common", "app_build_capabilities.h"), f)
end
def make_application_build_config_java_file
f = StringIO.new("", "w+")
f.puts "// WARNING! THIS FILE IS GENERATED AUTOMATICALLY! DO NOT EDIT IT MANUALLY!"
#f.puts "// Generated #{Time.now.to_s}"
f.puts "package com.rho;"
f.puts ""
f.puts "public class AppBuildConfig {"
f.puts 'static final String keys[] = { ""'
$application_build_configs.keys.each do |key|
f.puts ',"'+key+'"'
end
f.puts '};'
f.puts ''
count = 1
f.puts 'static final String values[] = { ""'
$application_build_configs.keys.each do |key|
f.puts ',"'+$application_build_configs[key]+'"'
count = count + 1
end
f.puts '};'
f.puts ''
f.puts 'static final int APP_BUILD_CONFIG_COUNT = '+count.to_s + ';'
f.puts ''
f.puts 'public static String getItem(String key){'
f.puts ' for (int i = 1; i < APP_BUILD_CONFIG_COUNT; i++) {'
f.puts ' if ( key.compareTo( keys[i]) == 0) {'
f.puts ' return values[i];'
f.puts ' }'
f.puts ' }'
f.puts ' return null;'
f.puts '}'
f.puts "}"
Jake.modify_file_if_content_changed( File.join( $startdir, "platform/bb/RubyVM/src/com/rho/AppBuildConfig.java" ), f )
end
namespace "config" do
task :common do
$startdir = File.dirname(__FILE__)
$startdir.gsub!('\\', '/')
$binextensions = []
buildyml = 'rhobuild.yml'
buildyml = ENV["RHOBUILD"] unless ENV["RHOBUILD"].nil?
$config = Jake.config(File.open(buildyml))
$config["platform"] = $current_platform if $current_platform
if RUBY_PLATFORM =~ /(win|w)32$/
$all_files_mask = "*.*"
$rubypath = "res/build-tools/RhoRuby.exe"
else
$all_files_mask = "*"
if RUBY_PLATFORM =~ /darwin/
$rubypath = "res/build-tools/RubyMac"
else
$rubypath = "res/build-tools/rubylinux"
end
end
if $app_path.nil? #if we are called from the rakefile directly, this wont be set
#load the apps path and config
$app_path = $config["env"]["app"]
unless File.exists? $app_path
puts "Could not find rhodes application. Please verify your application setting in #{File.dirname(__FILE__)}/rhobuild.yml"
exit 1
end
end
ENV["ROOT_PATH"] = $app_path.to_s + '/app/'
ENV["APP_TYPE"] = "rhodes"
$app_config = Jake.config(File.open(File.join($app_path, "build.yml")))
Jake.set_bbver($app_config["bbver"].to_s)
extpaths = []
extpaths << $app_config["paths"]["extensions"] if $app_config["paths"] and $app_config["paths"]["extensions"]
extpaths << $config["env"]["paths"]["extensions"] if $config["env"]["paths"]["extensions"]
extpaths << File.join($app_path, "extensions")
extpaths << File.join($startdir, "lib","extensions")
$app_config["extpaths"] = extpaths
if $app_config["build"] and $app_config["build"] == "release"
$debug = false
else
$debug = true
end
extensions = []
extensions += $app_config["extensions"] if $app_config["extensions"] and
$app_config["extensions"].is_a? Array
extensions += $app_config[$config["platform"]]["extensions"] if $app_config[$config["platform"]] and
$app_config[$config["platform"]]["extensions"] and $app_config[$config["platform"]]["extensions"].is_a? Array
$app_config["extensions"] = extensions
$hidden_app = $app_config["hidden_app"].nil?() ? "0" : $app_config["hidden_app"]
#application build configs
application_build_configs = {}
$application_build_configs_keys.each do |key|
value = $app_config[key]
if $app_config[$config["platform"]] != nil
if $app_config[$config["platform"]][key] != nil
value = $app_config[$config["platform"]][key]
end
end
if value != nil
application_build_configs[key] = value
end
end
$application_build_configs = application_build_configs
if $current_platform == "bb"
make_application_build_config_java_file
else
make_application_build_config_header_file
make_application_build_capabilities_header_file
end
end
out = `javac -version 2>&1`
puts "\n\nYour java bin folder does not appear to be on your path.\nThis is required to use rhodes.\n\n" unless $? == 0
end
def copy_assets(asset)
dest = File.join($srcdir,'apps/public')
cp_r asset + "/.", dest, :preserve => true, :remove_destination => true
end
def clear_linker_settings
if $config["platform"] == "iphone"
# outfile = ""
# IO.read($startdir + "/platform/iphone/rhorunner.xcodeproj/project.pbxproj").each_line do |line|
# if line =~ /EXTENSIONS_LDFLAGS = /
# outfile << line.gsub(/EXTENSIONS_LDFLAGS = ".*"/, 'EXTENSIONS_LDFLAGS = ""')
# else
# outfile << line
# end
# end
# File.open($startdir + "/platform/iphone/rhorunner.xcodeproj/project.pbxproj","w") {|f| f.write outfile}
# ENV["EXTENSIONS_LDFLAGS"] = ""
$ldflags = ""
end
end
def add_linker_library(libraryname)
# if $config["platform"] == "iphone"
# outfile = ""
# IO.read($startdir + "/platform/iphone/rhorunner.xcodeproj/project.pbxproj").each_line do |line|
# if line =~ /EXTENSIONS_LDFLAGS = /
# outfile << line.gsub(/";/, " $(TARGET_TEMP_DIR)/#{libraryname}\";")
# else
# outfile << line
# end
# end
# File.open($startdir + "/platform/iphone/rhorunner.xcodeproj/project.pbxproj","w") {|f| f.write outfile}
# end
simulator = $sdk =~ /iphonesimulator/
if ENV["TARGET_TEMP_DIR"] and ENV["TARGET_TEMP_DIR"] != ""
tmpdir = ENV["TARGET_TEMP_DIR"]
else
tmpdir = $startdir + "/platform/iphone/build/rhorunner.build/#{$configuration}-" +
( simulator ? "iphonesimulator" : "iphoneos") + "/rhorunner.build"
end
$ldflags << "#{tmpdir}/#{libraryname}\n" unless $ldflags.nil?
end
def set_linker_flags
if $config["platform"] == "iphone"
simulator = $sdk =~ /iphonesimulator/
if ENV["TARGET_TEMP_DIR"] and ENV["TARGET_TEMP_DIR"] != ""
tmpdir = ENV["TARGET_TEMP_DIR"]
else
tmpdir = $startdir + "/platform/iphone/build/rhorunner.build/#{$configuration}-" +
( simulator ? "iphonesimulator" : "iphoneos") + "/rhorunner.build"
end
mkdir_p tmpdir unless File.exist? tmpdir
File.open(tmpdir + "/rhodeslibs.txt","w") { |f| f.write $ldflags }
# ENV["EXTENSIONS_LDFLAGS"] = $ldflags
# puts `export $EXTENSIONS_LDFLAGS`
end
end
def add_extension(path,dest)
start = pwd
chdir path if File.directory?(path)
Dir.glob("*").each { |f| cp_r f,dest unless f =~ /^ext(\/|(\.yml)?$)/ }
chdir start
end
def init_extensions(startdir, dest)
extentries = []
extlibs = []
extpaths = $app_config["extpaths"]
$app_config["extensions"].each do |extname|
extpath = nil
extpaths.each do |p|
ep = File.join(p, extname)
if File.exists? ep
extpath = ep
break
end
end
if extpath.nil?
begin
$rhodes_extensions = nil
require extname
extpath = $rhodes_extensions[0] unless $rhodes_extensions.nil?
rescue Exception => e
end
end
unless extpath.nil?
add_extension(extpath, dest)
if $config["platform"] != "bb"
extyml = File.join(extpath, "ext.yml")
if File.file? extyml
extconf = Jake.config(File.open(extyml))
entry = extconf["entry"]
extentries << entry unless entry.nil?
libs = extconf["libraries"]
libs = [] unless libs.is_a? Array
if $config["platform"] == "wm" || $config["platform"] == "win32"
libs.map! { |lib| lib + ".lib" }
else
libs.map! { |lib| "lib" + lib + ".a" }
end
extlibs += libs
end
end
end
end
exts = File.join($startdir, "platform", "shared", "ruby", "ext", "rho", "extensions.c")
if $config["platform"] != "bb"
exists = []
if ( File.exists?(exts) )
File.new(exts, "r").read.split("\n").each do |line|
next if line !~ /^\s*extern\s+void\s+([A-Za-z_][A-Za-z0-9_]*)/
exists << $1
end
end
if (exists.sort! != extentries.sort! ) || (!File.exists?(exts))
File.open(exts, "w") do |f|
puts "MODIFY : #{exts}"
f.puts "// WARNING! THIS FILE IS GENERATED AUTOMATICALLY! DO NOT EDIT IT MANUALLY!"
#f.puts "// Generated #{Time.now.to_s}"
if $config["platform"] == "wm" || $config["platform"] == "win32"
# Add libraries through pragma
extlibs.each do |lib|
f.puts "#pragma comment(lib, \"#{lib}\")"
end
end
extentries.each do |entry|
f.puts "extern void #{entry}(void);"
end
f.puts "void Init_Extensions(void) {"
extentries.each do |entry|
f.puts " #{entry}();"
end
f.puts "}"
end
end
extlibs.each { |lib| add_linker_library(lib) }
set_linker_flags
end
unless $app_config["constants"].nil?
File.open("rhobuild.rb","w") do |file|
file << "module RhoBuild\n"
$app_config["constants"].each do |key,value|
value.gsub!(/"/,"\\\"")
file << " #{key.upcase} = \"#{value}\"\n"
end
file << "end\n"
end
end
if $excludeextlib
chdir dest
$excludeextlib.each {|e| Dir.glob(e).each {|f| rm f}}
end
end
def common_bundle_start(startdir, dest)
app = $app_path
rhodeslib = "lib/framework"
rm_rf $srcdir
mkdir_p $srcdir
mkdir_p dest if not File.exists? dest
mkdir_p File.join($srcdir,'apps')
start = pwd
chdir rhodeslib
Dir.glob("*").each { |f| cp_r f,dest, :preserve => true }
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 start
clear_linker_settings
init_extensions(startdir, dest)
chdir startdir
#throw "ME"
cp_r app + '/app',File.join($srcdir,'apps'), :preserve => true
cp_r app + '/public', File.join($srcdir,'apps'), :preserve => true if File.exists? app + '/public'
cp app + '/rhoconfig.txt', File.join($srcdir,'apps'), :preserve => true
app_version = "\r\napp_version='#{$app_config["version"]}'"
File.open(File.join($srcdir,'apps/rhoconfig.txt'), "a"){ |f| f.write(app_version) }
File.open(File.join($srcdir,'apps/rhoconfig.txt.timestamp'), "w"){ |f| f.write(Time.now.to_f().to_s()) }
unless $debug
rm_rf $srcdir + "/apps/app/test"
rm_rf $srcdir + "/apps/app/SpecRunner"
rm_rf $srcdir + "/apps/app/mspec"
rm_rf $srcdir + "/apps/app/mspec.rb"
rm_rf $srcdir + "/apps/app/spec_runner.rb"
end
copy_assets($assetfolder) if ($assetfolder and File.exists? $assetfolder)
replace_platform = $config['platform']
replace_platform = "bb6" if $bb6
replace_platform = "wm" if replace_platform == 'win32'
[File.join($srcdir,'apps'), ($current_platform == "bb" ? File.join($srcdir,'res') : File.join($srcdir,'lib/res'))].each do |folder|
chdir folder
Dir.glob("**/*.#{replace_platform}.*").each do |file|
oldfile = file.gsub(Regexp.new(Regexp.escape('.') + replace_platform + Regexp.escape('.')),'.')
rm oldfile if File.exists? oldfile
mv file,oldfile
end
Dir.glob("**/*.wm.*").each { |f| rm f }
Dir.glob("**/*.wp7.*").each { |f| rm f }
Dir.glob("**/*.iphone.*").each { |f| rm f }
Dir.glob("**/*.bb.*").each { |f| rm f }
Dir.glob("**/*.bb6.*").each { |f| rm f }
Dir.glob("**/*.android.*").each { |f| rm f }
Dir.glob("**/.svn").each { |f| rm_rf f }
Dir.glob("**/CVS").each { |f| rm_rf f }
end
end
def create_manifest
require File.dirname(__FILE__) + '/lib/framework/rhoappmanifest'
fappManifest = Rho::AppManifest.enumerate_models(File.join($srcdir, 'apps/app'))
content = fappManifest.read();
File.open( File.join($srcdir,'apps/app_manifest.txt'), "w"){|file| file.write(content)}
end
def process_exclude_folders
excl = []
exclude_platform = $config['platform']
exclude_platform = "bb6" if $bb6
exclude_platform = "wm" if exclude_platform == 'win32'
if $app_config["excludedirs"]
excl << $app_config["excludedirs"]['all'] if $app_config["excludedirs"]['all']
excl << $app_config["excludedirs"][exclude_platform] if $app_config["excludedirs"][exclude_platform]
end
if $config["excludedirs"]
excl << $config["excludedirs"]['all'] if $config["excludedirs"]['all']
excl << $config["excludedirs"][exclude_platform] if $config["excludedirs"][exclude_platform]
end
if excl
chdir File.join($srcdir, 'apps')
excl.each do |mask|
Dir.glob(mask).each {|f| rm_rf f}
end
end
end
namespace "build" do
namespace "bundle" do
task :xruby do
#needs $config, $srcdir, $excludelib, $bindir
app = $app_path
jpath = $config["env"]["paths"]["java"]
startdir = pwd
dest = $srcdir
xruby = File.dirname(__FILE__) + '/res/build-tools/xruby-0.3.3.jar'
compileERB = "lib/build/compileERB/bb.rb"
rhodeslib = File.dirname(__FILE__) + "/lib/framework"
common_bundle_start(startdir,dest)
process_exclude_folders()
cp_r File.join(startdir, "platform/shared/db/res/db"), File.join($srcdir, 'apps')
chdir startdir
#create manifest
create_manifest
#"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
cp compileERB, $srcdir
puts "Running bb.rb"
puts `#{$rubypath} -I#{rhodeslib} "#{$srcdir}/bb.rb"`
unless $? == 0
puts "Error interpreting erb code"
exit 1
end
rm "#{$srcdir}/bb.rb"
chdir $bindir
# -n#{$bundleClassName}
output = `java -jar "#{xruby}" -v -c RhoBundle 2>&1`
output.each_line { |x| puts ">>> " + x }
unless $? == 0
puts "Error interpreting ruby code"
exit 1
end
chdir startdir
chdir $srcdir
Dir.glob("**/*.rb") { |f| rm f }
Dir.glob("**/*.erb") { |f| rm f }
=begin
# RubyIDContainer.* files takes half space of jar why we need it?
Jake.unjar("../RhoBundle.jar", $tmpdir)
Dir.glob($tmpdir + "/**/RubyIDContainer.class") { |f| rm f }
rm "#{$bindir}/RhoBundle.jar"
chdir $tmpdir
puts `jar cf #{$bindir}/RhoBundle.jar #{$all_files_mask}`
rm_rf $tmpdir
mkdir_p $tmpdir
chdir $srcdir
=end
puts `"#{File.join(jpath,'jar')}" uf ../RhoBundle.jar apps/#{$all_files_mask}`
unless $? == 0
puts "Error creating Rhobundle.jar"
exit 1
end
chdir startdir
end
task :noxruby do
app = $app_path
rhodeslib = File.dirname(__FILE__) + "/lib/framework"
compileERB = "lib/build/compileERB/default.rb"
compileRB = "lib/build/compileRB/compileRB.rb"
startdir = pwd
dest = $srcdir + "/lib"
common_bundle_start(startdir,dest)
process_exclude_folders
chdir startdir
create_manifest
cp compileERB, $srcdir
puts "Running default.rb"
puts `#{$rubypath} -I#{rhodeslib} "#{$srcdir}/default.rb"`
unless $? == 0
puts "Error interpreting erb code"
exit 1
end
rm "#{$srcdir}/default.rb"
cp compileRB, $srcdir
puts "Running compileRB"
puts `#{$rubypath} -I#{rhodeslib} "#{$srcdir}/compileRB.rb"`
unless $? == 0
puts "Error interpreting ruby code"
exit 1
end
chdir $srcdir
Dir.glob("**/*.rb") { |f| rm f }
Dir.glob("**/*.erb") { |f| rm f }
chdir startdir
cp_r "platform/shared/db/res/db", $srcdir
end
task :noiseq do
app = $app_path
rhodeslib = File.dirname(__FILE__) + "/lib/framework"
compileERB = "lib/build/compileERB/bb.rb"
startdir = pwd
dest = $srcdir + "/lib"
common_bundle_start(startdir,dest)
process_exclude_folders
chdir startdir
create_manifest
cp compileERB, $srcdir
puts "Running bb.rb"
puts `#{$rubypath} -I#{rhodeslib} "#{$srcdir}/bb.rb"`
unless $? == 0
puts "Error interpreting erb code"
exit 1
end
rm "#{$srcdir}/bb.rb"
chdir $srcdir
Dir.glob("**/*.erb") { |f| rm f }
chdir startdir
cp_r "platform/shared/db/res/db", $srcdir
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
#genver = "unknown"
iphonever = "unknown"
#symver = "unknown"
wmver = "unknown"
androidver = "unknown"
# File.open("res/generators/templates/application/build.yml","r") do |f|
# file = f.read
# if file.match(/version: (\d+\.\d+\.\d+)/)
# genver = $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
gemver = "unknown"
rhodesver = "unknown"
frameworkver = "unknown"
File.open("lib/rhodes.rb","r") do |f|
file = f.read
if file.match(/VERSION = '(\d+\.\d+\.*\d*)'/)
gemver = $1
end
end
File.open("lib/framework/rhodes.rb","r") do |f|
file = f.read
if file.match(/VERSION = '(\d+\.\d+\.*\d*)'/)
rhodesver = $1
end
end
File.open("lib/framework/version.rb","r") do |f|
file = f.read
if file.match(/VERSION = '(\d+\.\d+\.*\d*)'/)
frameworkver = $1
end
end
puts "Versions:"
#puts " Generator: " + genver
puts " iPhone: " + iphonever
#puts " Symbian: " + symver
#puts " WinMo: " + wmver
puts " Android: " + androidver
puts " Gem: " + gemver
puts " Rhodes: " + rhodesver
puts " Framework: " + frameworkver
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("res/generators/templates/application/build.yml","r") { |f| origfile = f.read }
# File.open("res/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\t<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
["lib/rhodes.rb","lib/framework/rhodes.rb","lib/framework/version.rb"].each do |versionfile|
File.open(versionfile,"r") { |f| origfile = f.read }
File.open(versionfile,"w") do |f|
origfile.gsub!(/^(\s*VERSION) = '(\d+\.\d+\.*\d*)'/, '\1 = \''+ verstring + "'")
f.write origfile
end
end
Rake::Task[:get_version].invoke
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}"
$app_config["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
task :gem do
puts "Removing old gem"
rm_rf Dir.glob("rhodes*.gem")
puts "Copying Rakefile"
cp "Rakefile", "rakefile.rb"
puts "Building manifest"
out = ""
Dir.glob("**/*") do |fname|
# TODO: create exclusion list
out << fname + "\n" if File.file? fname and not fname =~ /rhoconnect-client/
end
File.open("Manifest.txt",'w') {|f| f.write(out)}
puts "Loading gemspec"
spec = Gem::Specification.load('rhodes.gemspec')
puts "Building gem"
gemfile = Gem::Builder.new(spec).build
end
namespace "rhomobile-debug" do
task :gem do
puts "Removing old gem"
rm_rf Dir.glob("rhomobile-debug*.gem")
rm_rf "rhomobile-debug"
mkdir_p "rhomobile-debug"
mkdir_p "rhomobile-debug/lib"
cp 'lib/extensions/debugger/debugger.rb', "rhomobile-debug/lib", :preserve => true
cp 'lib/extensions/debugger/README.md', "rhomobile-debug", :preserve => true
cp 'lib/extensions/debugger/LICENSE', "rhomobile-debug", :preserve => true
cp 'lib/extensions/debugger/CHANGELOG', "rhomobile-debug", :preserve => true
cp 'rhomobile-debug.gemspec', "rhomobile-debug", :preserve => true
startdir = pwd
chdir 'rhomobile-debug'
puts "Loading gemspec"
spec = Gem::Specification.load('rhomobile-debug.gemspec')
puts "Building gem"
gemfile = Gem::Builder.new(spec).build
Dir.glob("rhomobile-debug*.gem").each do |f|
cp f, startdir, :preserve => true
end
chdir startdir
rm_rf "rhomobile-debug"
end
end
task :tasks do
Rake::Task.tasks.each {|t| puts t.to_s.ljust(27) + "# " + t.comment.to_s}
end
task :switch_app => "config:common" do
rhobuildyml = File.dirname(__FILE__) + "/rhobuild.yml"
if File.exists? rhobuildyml
config = YAML::load_file(rhobuildyml)
else
puts "Cant find rhobuild.yml"
exit 1
end
config["env"]["app"] = $app_path.gsub(/\\/,"/")
File.open( rhobuildyml, 'w' ) do |out|
YAML.dump( config, out )
end
end
Rake::RDocTask.new do |rd|
#RDoc::Task.new do |rd|
rd.main = "README.textile"
rd.rdoc_files.include("README.textile", "lib/framework/**/*.rb")
end
Rake::Task["rdoc"].comment=nil
Rake::Task["rerdoc"].comment=nil
task :rdocpush => :rdoc do
puts "Pushing RDOC. This may take a while"
`scp -r html/* [email protected]:dev.rhomobile.com/rhodes/`
end