forked from rhomobile/rhodes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
2636 lines (2126 loc) · 87.5 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'
require 'pathname'
#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
# Restore process error mode on Windows.
# Error mode controls wether system error message boxes will be shown to user.
# Java disables message boxes and we enable them back.
#if RUBY_PLATFORM =~ /(win|w)32$/
# require 'win32/process'
# class WindowsError
# include Windows::Error
# end
# WindowsError.new.SetErrorMode(0)
#end
$app_basedir = pwd
$startdir = File.dirname(__FILE__)
$startdir.gsub!('\\', '/')
chdir File.dirname(__FILE__), :verbose => Rake.application.options.trace
require File.join(pwd, 'lib/build/jake.rb')
require File.join(pwd, 'lib/build/GeneratorTimeChecker.rb')
require File.join(pwd, 'lib/build/CheckSumCalculator.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/wp8/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', 'iphone_db_in_approot', 'iphone_set_approot', 'iphone_userpath_in_approot', "motorola_license", "motorola_license_company","name", "iphone_use_new_ios7_status_bar_style", "iphone_full_screen"]
$winxpe_build = false
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"'
if $rhosimulator_build
f.puts '#include "common/RhoSimConf.h"'
end
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|
value = $application_build_configs[key].to_s().gsub('\\', "\\\\\\")
value = value.gsub('"', "\\\"")
f.puts ',"'+ value +'"'
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;'
if $rhosimulator_build
f.puts ' if (strcmp(key, "security_token") == 0) {'
f.puts ' return rho_simconf_getString("security_token");'
f.puts ' }'
end
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 ''
if $js_application
f.puts '#define RHO_NO_RUBY'
f.puts '#define RHO_NO_RUBY_API'
end
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
def update_rhoprofiler_java_file
use_profiler = $app_config['profiler'] || ($app_config[$current_platform] && $app_config[$current_platform]['profiler'])
use_profiler = use_profiler && use_profiler.to_i() != 0 ? true : false
content = ""
File.open( File.join( $startdir, "platform/bb/RubyVM/src/com/rho/RhoProfiler.java" ), 'rb' ){ |f| content = f.read() }
is_find = nil
if use_profiler
is_find = content.sub!( 'RHO_STRIP_PROFILER = true;', 'RHO_STRIP_PROFILER = false;' )
else
is_find = content.sub!( 'RHO_STRIP_PROFILER = false;', 'RHO_STRIP_PROFILER = true;' )
end
if is_find
puts "RhoProfiler.java has been modified: RhoProfiler is " + (use_profiler ? "enabled!" : "disabled!")
File.open( File.join( $startdir, "platform/bb/RubyVM/src/com/rho/RhoProfiler.java" ), 'wb' ){ |f| f.write(content) }
end
end
def update_rhodefs_header_file
use_profiler = $app_config['profiler'] || ($app_config[$current_platform] && $app_config[$current_platform]['profiler'])
use_profiler = use_profiler && use_profiler.to_i() != 0 ? true : false
content = ""
File.open( File.join( $startdir, "platform/shared/common/RhoDefs.h" ), 'rb' ){ |f| content = f.read() }
is_find = nil
if use_profiler
is_find = content.sub!( '#define RHO_STRIP_PROFILER 1', '#define RHO_STRIP_PROFILER 0' )
else
is_find = content.sub!( '#define RHO_STRIP_PROFILER 0', '#define RHO_STRIP_PROFILER 1' )
end
if is_find
puts "RhoDefs.h has been modified: RhoProfiler is " + (use_profiler ? "enabled!" : "disabled!")
File.open( File.join( $startdir, "platform/shared/common/RhoDefs.h" ), 'wb' ){ |f| f.write(content) }
end
end
#TODO: call clean from all platfroms scripts
namespace "clean" do
task :common => "config:common" do
if $config["platform"] == "bb"
return
end
rm_rf File.join($app_path, "bin/tmp") if File.exists? File.join($app_path, "bin/tmp")
end
task :generated => "config:common" do
if $config["platform"] == "bb"
return
end
rm_rf File.join($app_path, "bin/tmp") if File.exists? File.join($app_path, "bin/tmp")
rm_rf File.join($app_path, "bin/RhoBundle") if File.exists? File.join($app_path, "bin/RhoBundle")
extpaths = $app_config["extpaths"]
$app_config["extensions"].each do |extname|
puts 'ext - ' + extname
extpath = nil
extpaths.each do |p|
ep = File.join(p, extname)
if File.exists?( ep ) && is_ext_supported(ep)
extpath = ep
break
end
end
if extpath.nil?
extpath = find_ext_ingems(extname)
if extpath
extpath = nil unless is_ext_supported(extpath)
end
end
if (extpath.nil?) && (extname != 'rhoelements-license') && (extname != 'motoapi')
raise "Can't find extension '#{extname}'. Aborting build.\nExtensions search paths are:\n#{extpaths}"
end
unless extpath.nil?
extyml = File.join(extpath, "ext.yml")
#puts "extyml " + extyml
if File.file? extyml
extconf = Jake.config(File.open(extyml))
type = Jake.getBuildProp( "exttype", extconf )
#wm_type = extconf["wm"]["exttype"] if extconf["wm"]
if type != "prebuilt" #&& wm_type != "prebuilt"
rm_rf File.join(extpath, "ext", "shared", "generated")
rm_rf File.join(extpath, "ext", "platform", "android", "generated")
rm_rf File.join(extpath, "ext", "platform", "iphone", "generated")
rm_rf File.join(extpath, "ext", "platform", "osx", "generated")
rm_rf File.join(extpath, "ext", "platform", "wm", "generated")
rm_rf File.join(extpath, "ext", "platform", "wp8", "generated")
rm_rf File.join(extpath, "ext", "public", "api", "generated")
end
end
end
end
end
end
namespace "config" do
task :common do
puts RUBY_VERSION
$binextensions = []
$app_extensions_list = {}
buildyml = 'rhobuild.yml'
$current_platform_bridge = $current_platform unless $current_platform_bridge
buildyml = ENV["RHOBUILD"] unless ENV["RHOBUILD"].nil?
$config = Jake.config(File.open(buildyml))
$config["platform"] = $current_platform if $current_platform
$config["env"]["app"] = "spec/framework_spec" if $rhosimulator_build
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
$app_path = ENV["RHO_APP_PATH"] if ENV["RHO_APP_PATH"] && $app_path.nil?
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["RHO_APP_PATH"] = $app_path.to_s
ENV["ROOT_PATH"] = $app_path.to_s + '/app/'
ENV["APP_TYPE"] = "rhodes"
$app_config = Jake.config(File.open(File.join($app_path, "build.yml")))
if File.exists?(File.join($app_path, "app_rakefile"))
load File.join($app_path, "app_rakefile")
$app_rakefile_exist = true
Rake::Task["app:config"].invoke
end
Jake.set_bbver($app_config["bbver"].to_s)
extpaths = []
if $app_config["paths"] and $app_config["paths"]["extensions"]
if $app_config["paths"]["extensions"].is_a? String
p = $app_config["paths"]["extensions"]
unless Pathname.new(p).absolute?
p = File.expand_path(File.join($app_path,p))
end
extpaths << p
elsif $app_config["paths"]["extensions"].is_a? Array
$app_config["paths"]["extensions"].each do |p|
unless Pathname.new(p).absolute?
p = File.expand_path(File.join($app_path,p))
end
extpaths << p
end
#extpaths += $app_config["paths"]["extensions"]
end
end
if $config["env"]["paths"]["extensions"]
#extpaths << $config["env"]["paths"]["extensions"]
env_path_exts = $config["env"]["paths"]["extensions"]
if env_path_exts.is_a? String
extpaths << p
elsif env_path_exts.is_a? Array
env_path_exts.each do |p|
extpaths << p
end
end
end
extpaths << File.join($app_path, "extensions")
extpaths << File.join($startdir, "lib","commonAPI")
extpaths << File.join($startdir, "lib","extensions")
$app_config["extpaths"] = extpaths
if $app_config["build"] and $app_config["build"].casecmp("release") == 0
$debug = false
else
$debug = true
end
# merge extensions from platform list to global one
$app_config['extensions'] = [] unless $app_config['extensions'] and $app_config['extensions'].is_a? Array
if $app_config[$config['platform']] and $app_config[$config['platform']]['extensions'] and $app_config[$config['platform']]['extensions'].is_a? Array
$app_config['extensions'] = $app_config['extensions'] | $app_config[$config['platform']]['extensions']
end
# gather main extensions
extensions = []
extensions << "coreapi" #unless $app_config['re_buildstub']
extensions += get_extensions
extensions << "rhoconnect-client" if $rhosimulator_build
extensions << "json"
# filter list of extensions with main extensions list (regardless of case!)
downcased = extensions.map(&:downcase)
$app_config['extensions'].reject! { |ext| downcased.include?(ext.downcase) }
$app_config['extensions'] = extensions + $app_config['extensions']
$app_config['extensions'].uniq!
capabilities = []
capabilities += $app_config["capabilities"] if $app_config["capabilities"] and
$app_config["capabilities"].is_a? Array
capabilities += $app_config[$config["platform"]]["capabilities"] if $app_config[$config["platform"]] and
$app_config[$config["platform"]]["capabilities"] and $app_config[$config["platform"]]["capabilities"].is_a? Array
$app_config["capabilities"] = capabilities
application_build_configs = {}
#Process rhoelements settings
if $current_platform == "wm" || $current_platform == "android"
if $app_config["app_type"] == 'rhoelements'
if !$app_config["capabilities"].index('non_motorola_device')
$app_config["capabilities"] += ["motorola"] unless $app_config["capabilities"].index("motorola")
$app_config["extensions"] += ["rhoelementsext"]
$app_config["extensions"] += ["motoapi"] #extension with plug-ins
#check for RE2 plugins
plugins = ""
$app_config["extensions"].each do |ext|
if ( ext.start_with?('moto-') )
plugins += ',' if plugins.length() > 0
plugins += ext[5, ext.length()-5]
end
end
if plugins.length() == 0
plugins = "ALL"
end
application_build_configs['moto-plugins'] = plugins if plugins.length() > 0
end
if !$app_config["capabilities"].index('native_browser') && $current_platform != "android"
$app_config["capabilities"] += ["motorola_browser"] unless $app_config["capabilities"].index('motorola_browser')
end
end
application_build_configs['shared-runtime'] = '1' if $app_config["capabilities"].index('shared_runtime')
if $app_config["capabilities"].index("motorola_browser")
$app_config['extensions'] += ['webkit-browser'] unless $app_config['extensions'].index('webkit-browser')
end
if $app_config["extensions"].index("webkit-browser")
$app_config["capabilities"] += ["webkit_browser"]
$app_config["extensions"].delete("webkit-browser")
end
if $app_config["capabilities"].index("webkit_browser") || ($app_config["capabilities"].index("motorola") && $current_platform != "android")
#contains wm and android libs for webkit browser
$app_config["extensions"] += ["rhoelements"] unless $app_config['extensions'].index('rhoelements')
end
end
if $app_config["app_type"] == 'rhoelements'
# add audiocapture extensions for rhoelements app
if !$app_config['extensions'].index('rhoelementsext')
if $current_platform == "iphone" || $current_platform == "android"
$app_config['extensions'] = $app_config['extensions'] | ['audiocapture']
end
end
if $current_platform == "wm"
$app_config['extensions'] = $app_config['extensions'] | ['barcode']
$app_config['extensions'] = $app_config['extensions'] | ['indicators']
$app_config['extensions'] = $app_config['extensions'] | ['cardreader']
#$app_config['extensions'] = $app_config['extensions'] | ['signature']
$app_config['extensions'] = $app_config['extensions'] | ['hardwarekeys']
$app_config['extensions'] = $app_config['extensions'] | ['sensor']
end
if $current_platform == "iphone"
$app_config['extensions'] = $app_config['extensions'] | ['barcode']
#$app_config['extensions'] = $app_config['extensions'] | ['signature']
$app_config['extensions'] = $app_config['extensions'] | ['indicators']
$app_config['extensions'] = $app_config['extensions'] | ['hardwarekeys']
$app_config['extensions'] = $app_config['extensions'] | ['sensor']
end
if $current_platform == "android"
$app_config['extensions'] = $app_config['extensions'] | ['barcode']
#$app_config['extensions'] = $app_config['extensions'] | ['signature']
$app_config['extensions'] = $app_config['extensions'] | ['cardreader']
$app_config['extensions'] = $app_config['extensions'] | ['indicators']
$app_config['extensions'] = $app_config['extensions'] | ['hardwarekeys']
$app_config['extensions'] = $app_config['extensions'] | ['sensor']
end
end
#if $app_config['extensions'].index('rhoelementsext')
# #$app_config["extensions"].delete("rawsensors")
# $app_config["extensions"].delete("audiocapture")
#end
$hidden_app = $app_config["hidden_app"].nil?() ? "0" : $app_config["hidden_app"]
#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
#check for rhoelements gem
$rhoelements_features = ""
if $app_config['extensions'].index('barcode')
#$app_config['extensions'].delete('barcode')
$rhoelements_features += "- Barcode extension\n"
end
if $app_config['extensions'].index('indicators')
$rhoelements_features += "- Indicators extension\n"
end
if $app_config['extensions'].index('hardwarekeys')
$rhoelements_features += "- HardwareKeys extension\n"
end
if $app_config['extensions'].index('cardreader')
$rhoelements_features += "- CardReader extension\n"
end
if $app_config['extensions'].index('nfc')
#$app_config['extensions'].delete('nfc')
$rhoelements_features += "- NFC extension\n"
end
#if $app_config['extensions'].index('audiocapture')
# #$app_config['extensions'].delete('audiocapture')
# $rhoelements_features += "- Audio Capture\n"
#end
if ($app_config['extensions'].index('signature') || $app_config['capabilities'].index('signature')) && (($current_platform == "iphone") || ($current_platform == "android"))
$rhoelements_features += "- Signature Capture\n"
end
if $current_platform == "wm"
$rhoelements_features += "- Windows Mobile/Windows CE platform support\n"
end
if $application_build_configs['encrypt_database'] && $application_build_configs['encrypt_database'].to_s == '1'
#$application_build_configs.delete('encrypt_database')
$rhoelements_features += "- Database encryption\n"
end
if $app_config["capabilities"].index("motorola")
$rhoelements_features += "- Motorola device capabilities\n"
end
if $app_config['extensions'].index('webkit-browser') || $app_config['capabilities'].index('webkit_browser')
$rhoelements_features += "- Motorola WebKit Browser\n"
end
if $app_config['extensions'].index('rho-javascript')
$rhoelements_features += "- Javascript API for device capabilities\n"
end
if File.exist?(File.join($app_path, "license.yml"))
license_config = Jake.config(File.open(File.join($app_path, "license.yml")))
if ( license_config )
$application_build_configs["motorola_license"] = license_config["motorola_license"] if license_config["motorola_license"]
$application_build_configs["motorola_license_company"] = license_config["motorola_license_company"] if license_config["motorola_license_company"]
end
end
$invalid_license = false
if $rhoelements_features.length() > 0
$app_config['extensions'] << 'rhoelements-license' if $current_platform == "android"
#check for RhoElements gem and license
if !$app_config['re_buildstub']
begin
require "rhoelements"
$rhoelements_features = ""
# check license
is_ET1 = (($current_platform == "android") and ($app_config["capabilities"].index("motorola")))
is_win_platform = (($current_platform == "wm") or ($current_platform == "win32") or $is_rho_simulator )
if (!is_ET1) and (!is_win_platform)
# check the license parameter
if (!$application_build_configs["motorola_license"]) or (!$application_build_configs["motorola_license_company"])
$invalid_license = true
end
end
rescue Exception => e
if $app_config['extensions'].index('nfc')
$app_config['extensions'].delete('nfc')
end
#if $app_config['extensions'].index('audiocapture')
# $app_config['extensions'].delete('audiocapture')
#end
if $app_config['extensions'].index('rho-javascript')
$app_config['extensions'].delete('rho-javascript')
end
if $application_build_configs['encrypt_database'] && $application_build_configs['encrypt_database'].to_s == '1'
$application_build_configs.delete('encrypt_database')
end
if $app_config['extensions'].index('signature')
$app_config['extensions'].delete('signature')
end
end
end
end
if $app_config['extensions'].index('signature') && (($current_platform == 'iphone') || ($current_platform == 'android'))
$app_config['capabilities'] << 'signature'
$app_config['extensions'].delete('signature')
end
if $current_platform == "win32" && $winxpe_build == true
$app_config['capabilities'] << 'winxpe'
end
$app_config['extensions'].uniq!() if $app_config['extensions']
$app_config['capabilities'].uniq!() if $app_config['capabilities']
$app_config['extensions'].delete("mspec") if !$debug && $app_config['extensions'].index('mspec')
$app_config['extensions'].delete("rhospec") if !$debug && $app_config['extensions'].index('rhospec')
if $invalid_license
$application_build_configs["motorola_license"] = '123' if !$application_build_configs["motorola_license"]
$application_build_configs["motorola_license_company"] = 'WRONG' if !$application_build_configs["motorola_license_company"]
end
$rhologhostport = $config["log_host_port"]
$rhologhostport = 52363 unless $rhologhostport
begin
$rhologhostaddr = Jake.localip()
rescue Exception => e
puts "Jake.localip() error : #{e}"
end
$file_map_name = "RhoBundleMap.txt"
obfuscate_js = Jake.getBuildBoolProp2("obfuscate", "js", $app_config, nil)
obfuscate_css = Jake.getBuildBoolProp2("obfuscate", "css", $app_config, nil)
$obfuscate_exclude = Jake.getBuildProp2("obfuscate", "exclude_dirs" )
minify_js = Jake.getBuildBoolProp2("minify", "js", $app_config, nil)
minify_css = Jake.getBuildBoolProp2("minify", "css", $app_config, nil)
$minify_exclude = Jake.getBuildProp2("minify", "exclude_dirs" )
$minify_types = []
if !$debug
minify_js = true if minify_js == nil
minify_css = true if minify_css == nil
end
$minify_types << "js" if minify_js or obfuscate_js
$minify_types << "css" if minify_css or obfuscate_css
$minifier = File.join(File.dirname(__FILE__),'res/build-tools/yuicompressor-2.4.7.jar')
$js_application = Jake.getBuildBoolProp("javascript_application")
if !$js_application && !Dir.exists?(File.join($app_path, "app"))
puts '********* ERROR ************************************************************************'
puts "Add javascript_application:true to build.yml, since application does not contain app folder."
puts "See: http://docs.rhomobile.com/guide/api_js#javascript-rhomobile-application-structure"
puts '****************************************************************************************'
exit(1)
end
puts "$app_config['extensions'] : #{$app_config['extensions'].inspect}"
puts "$app_config['capabilities'] : #{$app_config['capabilities'].inspect}"
if $current_platform == "bb"
make_application_build_config_java_file()
update_rhoprofiler_java_file()
elsif $current_platform == "wp"
else
make_application_build_config_header_file
make_application_build_capabilities_header_file
update_rhodefs_header_file
end
$remote_debug = false
$remote_debug = Jake.getBool(ENV['rho_remote_debug']) if ENV['rho_remote_debug']
if $remote_debug
$app_config['extensions'] = $app_config['extensions'] | ['debugger']
$app_config['extensions'] = $app_config['extensions'] | ['uri']
$app_config['extensions'] = $app_config['extensions'] | ['timeout']
end
# it`s should be in the end of common:config task
platform_task = "config:#{$current_platform}:app_config"
Rake::Task[platform_task].invoke if Rake::Task.task_defined? platform_task
end # end of common:config
task :qt do
$qtdir = ENV['QTDIR']
unless (!$qtdir.nil?) and ($qtdir !~/^\s*$/) and File.directory?($qtdir)
puts "\nPlease, set QTDIR environment variable to Qt root directory path"
exit 1
end
$qmake = File.join($qtdir, 'bin/qmake')
$macdeployqt = File.join($qtdir, 'bin/macdeployqt')
end
task :rhosimulator do
$rhosimulator_build = true
end
end
def copy_assets(asset, file_map)
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 = File.join($app_path, 'project/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_RHODESLIBS_DIR"] and ENV["TARGET_RHODESLIBS_DIR"] != ""
tmpdir = ENV["TARGET_RHODESLIBS_DIR"]
else
if ENV["TARGET_TEMP_DIR"] and ENV["TARGET_TEMP_DIR"] != ""
tmpdir = ENV["TARGET_TEMP_DIR"]
else
tmpdir = File.join($app_path, 'project/iphone') + "/build/rhorunner.build/#{$configuration}-" +
( simulator ? "iphonesimulator" : "iphoneos") + "/rhorunner.build"
end
end
mkdir_p tmpdir unless File.exist? tmpdir
tmpdir = File.join($app_path.to_s, "project/iphone")
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)
puts 'add_extension - ' + path.to_s + " - " + dest.to_s
start = pwd
chdir path if File.directory?(path)
puts 'chdir path=' + path.to_s
if !$js_application
Dir.glob("*").each do |f|
cp_r f,dest unless f =~ /^ext(\/|(\.yml)?$)/ || f =~ /^app/ || f =~ /^public/
end
end
if $current_platform == "bb"
FileUtils.cp_r 'app', File.join( dest, "apps/app" ) if File.exist? 'app'
FileUtils.cp_r 'public', File.join( dest, "apps/public" ) if File.exist? 'public'
else
FileUtils.cp_r('app', File.join( File.dirname(dest), "apps/app" ).to_s) if File.exist? 'app'
FileUtils.cp_r('public', File.join( File.dirname(dest), "apps").to_s) if File.exist? 'public'
end
chdir start
end
def find_ext_ingems(extname)
extpath = nil
begin
$rhodes_extensions = nil
$rhodes_join_ext_name = false
require extname
if $rhodes_extensions
extpath = $rhodes_extensions[0]
$app_config["extpaths"] << extpath
if $rhodes_join_ext_name
extpath = File.join(extpath,extname)
end
end
rescue Exception => e
puts "exception: #{e}"
end
extpath
end
def write_modules_js(filename, modules)
f = StringIO.new("", "w+")
f.puts "// WARNING! THIS FILE IS GENERATED AUTOMATICALLY! DO NOT EDIT IT MANUALLY!"
if modules
modules.each do |m|
modulename = m.gsub(/^(|.*[\\\/])([^\\\/]+)\.js$/, '\2')
f.puts( "// Module #{modulename}\n\n" )
f.write(File.read(m))
end
end
Jake.modify_file_if_content_changed(filename, f)
end
def is_ext_supported(extpath)
extyml = File.join(extpath, "ext.yml")
res = true
if File.file? extyml
extconf = Jake.config(File.open(extyml))
if extconf["platforms"]
res = extconf["platforms"].index($current_platform) != nil
end
end
res
end
def init_extensions(dest, mode = "")
extentries = []
extentries_init = []
nativelib = []
extlibs = []
extjsmodulefiles = []
extjsmodulefiles_opt = []
startJSModules = []
startJSModules_opt = []
endJSModules = []
extcsharplibs = []
extcsharpentries = []
extcsharppaths = []
extcsharpprojects = []
extscsharp = nil
ext_xmls_paths = []
extpaths = $app_config["extpaths"]
rhoapi_js_folder = nil
if !dest.nil?
rhoapi_js_folder = File.join( File.dirname(dest), "apps/public/api" )
elsif mode == "update_rho_modules_js"
rhoapi_js_folder = File.join( $app_path, "public/api" )
end
puts "rhoapi_js_folder: #{rhoapi_js_folder}"
puts 'init extensions'
# TODO: checker init
gen_checker = GeneratorTimeChecker.new
gen_checker.init($startdir, $app_path)
$app_config["extensions"].each do |extname|
puts 'ext - ' + extname
extpath = nil
extpaths.each do |p|
ep = File.join(p, extname)
if File.exists?( ep ) && is_ext_supported(ep)
extpath = ep
break
end
end
if extpath.nil?
extpath = find_ext_ingems(extname)
if extpath
extpath = nil unless is_ext_supported(extpath)
end
end
if (extpath.nil?) && (extname != 'rhoelements-license') && (extname != 'motoapi')
raise "Can't find extension '#{extname}'. Aborting build.\nExtensions search paths are:\n#{extpaths}"
end
$app_extensions_list[extname] = extpath
unless extpath.nil?
puts 'iter=' + extpath.to_s
if $config["platform"] != "bb"
extyml = File.join(extpath, "ext.yml")
puts "extyml " + extyml
if File.file? extyml
extconf = Jake.config(File.open(extyml))
entry = extconf["entry"]
nlib = extconf["nativelibs"]
type = Jake.getBuildProp( "exttype", extconf )
#wm_type = extconf["wm"]["exttype"] if extconf["wm"]
xml_api_paths = extconf["xml_api_paths"]
extconf_wp8 = $config["platform"] == "wp8" && (!extconf['wp8'].nil?) ? extconf['wp8'] : Hash.new
csharp_impl_all = (!extconf_wp8['csharp_impl'].nil?) ? true : false
if nlib != nil
nlib.each do |libname|
nativelib << libname
end
end
if entry && entry.length() > 0
if xml_api_paths.nil? #&& !("rhoelementsext" == extname && ($config["platform"] == "wm"||$config["platform"] == "android"))