Class: Jake
Overview
Class with around building things
Class Method Summary collapse
- .ant(dir, target) ⇒ Object
- .before_run_spec ⇒ Object
- .build_file_map(dir, file_name, in_memory = false) ⇒ Object
- .clean_vsprops(file) ⇒ Object
- .config(configfile) ⇒ Object
- .config_parse(conf) ⇒ Object
- .copy_rhoconfig(source, target) ⇒ Object
- .copyIfNeeded(src, dst) ⇒ Object
- .decorate_spec ⇒ Object
- .edit_lines(file, out_file = nil) ⇒ Object
- .edit_xml(file, out_file = nil) {|doc| ... } ⇒ Object
- .edit_yml(file, out_file = nil) {|yml| ... } ⇒ Object
- .get_absolute(path) ⇒ Object
- .get_absolute_ex(path, currentdir) ⇒ Object
- .get_config_override_params ⇒ Object
- .get_process_list ⇒ Object
- .getBool(propObject, def_value = false) ⇒ Object
- .getBuildBoolProp(propName, config_yml = $app_config, def_value = false) ⇒ Object
- .getBuildBoolProp2(propName, propName2, config_yml = $app_config, def_value = false) ⇒ Object
- .getBuildProp(propName, config_yml = $app_config) ⇒ Object
- .getBuildProp2(propName, propName2, config_yml = $app_config) ⇒ Object
- .jar(target, manifest, files, isfolder = false) ⇒ Object
- .jarfilelist(target) ⇒ Object
- .localip ⇒ Object
- .make_rhoconfig_txt ⇒ Object
- .modify_file_if_content_changed(file_name, f) ⇒ Object
- .modify_rhoconfig_for_debug ⇒ Object
- .normalize_build_yml(yml = $app_config) ⇒ Object
- .process_spec_output(line) ⇒ Object
- .process_spec_results(start) ⇒ Object
- .rapc(output, destdir, imports, files, title = nil, vendor = nil, version = nil, icon = nil, library = true, cldc = false, quiet = true, nowarn = true) ⇒ Object
- .reset_bulk_server ⇒ Object
- .reset_spec_server(platform) ⇒ Object
- .run(command, args, wd = nil, system = false, hideerrors = false) ⇒ Object
- .run2(command, args, options = {}, &block) ⇒ Object
- .run3(command, cd = nil, env = {}) ⇒ Object
- .run3_dont_fail(command, cd = nil, env = {}) ⇒ Object
- .run4(command) ⇒ Object
- .run_local_server(port = 0) ⇒ Object
- .run_local_server_with_logger(port, log_file) ⇒ Object
- .run_rho_log_server(app_path) ⇒ Object
- .set_bbver(bbver) ⇒ Object
- .setBuildProp(propName, propValue, config_yml = $app_config) ⇒ Object
- .unjar(src, targetdir) ⇒ Object
-
.unzip(src_zip, dest_dir) ⇒ Object
Unzips archive to specified directory.
-
.zip(where, what, dest) ⇒ Object
Zips specified files from directory.
- .zip_upgrade_bundle(folder_path, zip_file_path) ⇒ Object
Class Method Details
.ant(dir, target) ⇒ Object
637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 |
# File 'lib/build/jake.rb', line 637 def self.ant(dir,target) srcdir = $config["build"]["srcdir"] rubypath = $config["build"]["rubypath"] excludelib = $config["build"]["excludelib"] excludeapps = $config["build"]["excludeapps"] compileERB = $config["build"]["compileERB"] args = [] args << "-buildfile" args << dir + "/build.xml" args << '-Dsrc.dir=' + get_absolute(srcdir) # args << '-Druby.path=' + get_absolute(rubypath) args << '-Dexclude.lib=' + excludelib args << '-Dexclude.apps=' + excludeapps args << '-DcompileERB.path=' + get_absolute(compileERB) args << '-Dsrclib.dir=' + get_absolute(srcdir) args << target #puts args.to_s puts run("ant.bat",args,dir) end |
.before_run_spec ⇒ Object
227 228 229 230 231 232 233 234 235 236 |
# File 'lib/build/jake.rb', line 227 def self.before_run_spec() $total ||= 0 $passed ||= 0 $failed ||= 0 $faillog = [] @default_file_name = "junit.xml" $junitname = '' $junitlogs = {@default_file_name => []} $getdump = false end |
.build_file_map(dir, file_name, in_memory = false) ⇒ Object
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 |
# File 'lib/build/jake.rb', line 675 def self.build_file_map(dir, file_name, in_memory = false) require 'digest/md5' psize = dir.size + 1 file_map = Array.new file_map_name = File.join(dir, file_name) dat = nil if in_memory == false dat = File.open(file_map_name, 'w') end Dir.glob(File.join(dir, '**/*')).sort.each do |f| relpath = f[psize..-1] if File.directory?(f) type = 'dir' elsif File.file?(f) type = 'file' else next end if File.basename(f) == file_name next end md5 = (type == 'file' ? (Digest::MD5.file(f)).to_s : '') size = File.stat(f).size tm = File.stat(f).mtime.to_i if in_memory == true map_item = { :path => relpath, :size => size, :time => tm, :hash => md5} file_map << map_item else dat.puts "#{relpath}|#{type}|#{size.to_s}|#{tm.to_s}|#{md5}" end end if in_memory == false dat.close end return file_map end |
.clean_vsprops(file) ⇒ Object
483 484 485 486 487 488 489 490 491 492 493 494 |
# File 'lib/build/jake.rb', line 483 def self.clean_vsprops(file) changed = false edit_xml(file) do |doc| ['RHO_ROOT', 'TEMP_FILES_DIR'].each do |var| REXML::XPath.each(doc, "//UserMacro[@Name='#{var}']") do |node| changed = true node.remove end end end puts "CLEAN_VSPROPS [#{file}, #{changed}]. TODO: remove this output." end |
.config(configfile) ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/build/jake.rb', line 64 def self.config(configfile) require 'yaml' conf = YAML::load(configfile) res = self.config_parse(conf) res end |
.config_parse(conf) ⇒ Object
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 |
# File 'lib/build/jake.rb', line 106 def self.config_parse(conf) if conf.is_a?(Array) conf.collect! do |x| if x.is_a?(Hash) or x.is_a?(Array) x = config_parse(x) x else if x =~ /%(.*?)%/ x.gsub!(/%.*?%/, conf.fetch_r($1).to_s) end s = x.to_s if File.exists? s s.gsub!(/\\/, '/') end s end end elsif conf.is_a?(Hash) newhash = Hash.new conf.each do |k,x| if x.is_a?(Hash) or x.is_a?(Array) newhash[k.to_s] = config_parse(x) else s = x.to_s if File.exists? s s.gsub!(/\\/, '/') end newhash[k.to_s] = s end end conf = newhash conf end conf end |
.copy_rhoconfig(source, target) ⇒ Object
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 |
# File 'lib/build/jake.rb', line 831 def self.copy_rhoconfig(source, target) override = get_config_override_params mentioned = Set.new lines = [] # read file and edit overriden parameters File.open(source, 'r') do |file| while line = file.gets match = line.match(/^(\s*)(\w+)(\s*=\s*)/) if match name = match[2] if override.has_key?(name) lines << "#{match[1]}#{name}#{match[3]}#{override[name]}" mentioned << name next end end lines << line end end # append rest of overriden parameters to text override.each do |key, value| if !mentioned.include?(key) lines << '' lines << "#{key} = #{value}" end end # write text to target file File.open(target, 'w') do |file| lines.each { |l| file.puts l } end end |
.copyIfNeeded(src, dst) ⇒ Object
1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 |
# File 'lib/build/jake.rb', line 1005 def self.copyIfNeeded src, dst if File.directory? dst and !File.directory? src dst_path = File.join dst, File.basename(src) else dst_path = dst end unless File.exists? dst_path and FileUtils.identical? src, dst_path FileUtils.rm dst_path if File.exists? dst_path FileUtils.cp src, dst end end |
.decorate_spec ⇒ Object
218 219 220 221 222 223 224 225 |
# File 'lib/build/jake.rb', line 218 def self.decorate_spec $app_spec_decorator.before_spec unless $app_spec_decorator.nil? begin yield ensure $app_spec_decorator.after_spec unless $app_spec_decorator.nil? end end |
.edit_lines(file, out_file = nil) ⇒ Object
474 475 476 477 478 479 480 481 |
# File 'lib/build/jake.rb', line 474 def self.edit_lines(file, out_file = nil) out_file = file if out_file.nil? lines = File.readlines(file) File.open(out_file, 'w') do |f| lines.each { |line| f.puts(yield line) } end end |
.edit_xml(file, out_file = nil) {|doc| ... } ⇒ Object
466 467 468 469 470 471 472 |
# File 'lib/build/jake.rb', line 466 def self.edit_xml(file, out_file = nil) out_file = file if out_file.nil? doc = REXML::Document.new(File.new(file).read) yield doc File.open(out_file, 'w') {|f| f << doc} end |
.edit_yml(file, out_file = nil) {|yml| ... } ⇒ Object
456 457 458 459 460 461 462 463 464 |
# File 'lib/build/jake.rb', line 456 def self.edit_yml(file, out_file = nil) out_file = file if out_file.nil? require 'yaml' yml = YAML::load_file(file) yield yml File.open(out_file, 'w') {|f| f.write yml.to_yaml} end |
.get_absolute(path) ⇒ Object
81 82 83 |
# File 'lib/build/jake.rb', line 81 def self.get_absolute(path) get_absolute_ex(path, Dir.pwd()) end |
.get_absolute_ex(path, currentdir) ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/build/jake.rb', line 85 def self.get_absolute_ex(path, currentdir) ret_path = File.(path, currentdir) return ret_path if File.exists?(ret_path) path = currentdir + "/" + path patharray = path.split(/\//) while idx = patharray.index("..") do if idx == 0 raise "error getting absolute" end if patharray[idx-1] != ".." patharray.delete_at(idx) patharray.delete_at(idx-1) end end return patharray.join("/") end |
.get_config_override_params ⇒ Object
821 822 823 824 825 826 827 828 829 |
# File 'lib/build/jake.rb', line 821 def self.get_config_override_params override = {} ENV.each do |key, value| key.match(/^rho_override_(.+)$/) do |match| override[match[1]] = value end end return override end |
.get_process_list ⇒ Object
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 |
# File 'lib/build/jake.rb', line 919 def self.get_process_list cmd = nil args = nil proc_list = [] if RUBY_PLATFORM =~ /(win|w)32$/ cmd = 'WMIC' args = ['path', 'win32_process', 'get', 'Processid,Parentprocessid,Commandline'] else cmd = 'ps' args = ['axww', '-o', 'pid', '-o', 'ppid', '-o', 'command'] end output = run2 cmd, args, {:hide_output=>true} output.each_line do |line| #puts "[[#{line}]]" if RUBY_PLATFORM =~ /(win|w)32$/ match_data = /^(.*)\s+(\d+)\s+(\d+)\s*$/.match line proc_list << {:pid=>match_data[3], :ppid=>match_data[2], :cmd=>match_data[1]} if match_data else match_data = /(\d+)\s+(\d+)\s+(.*)/.match line proc_list << {:pid=>match_data[1], :ppid=>match_data[2], :cmd=>match_data[3]} if match_data end end proc_list end |
.getBool(propObject, def_value = false) ⇒ Object
960 961 962 963 964 965 966 967 968 |
# File 'lib/build/jake.rb', line 960 def self.getBool(propObject, def_value=false) res = propObject return def_value unless res return true if res && (res.to_i() != 0 || res.casecmp("true") == 0 || res.casecmp("yes") == 0 ) false end |
.getBuildBoolProp(propName, config_yml = $app_config, def_value = false) ⇒ Object
970 971 972 973 974 975 976 977 978 |
# File 'lib/build/jake.rb', line 970 def self.getBuildBoolProp(propName, config_yml=$app_config, def_value=false) res = getBuildProp(propName) return def_value unless res return true if res && (res.to_i() != 0 || res.casecmp("true") == 0 || res.casecmp("yes") == 0 ) false end |
.getBuildBoolProp2(propName, propName2, config_yml = $app_config, def_value = false) ⇒ Object
995 996 997 998 999 1000 1001 1002 1003 |
# File 'lib/build/jake.rb', line 995 def self.getBuildBoolProp2(propName, propName2, config_yml=$app_config, def_value=false) res = getBuildProp2(propName, propName2) return def_value unless res return true if res && (res.to_i() != 0 || res.casecmp("true") == 0 || res.casecmp("yes") == 0 ) false end |
.getBuildProp(propName, config_yml = $app_config) ⇒ Object
951 952 953 954 955 956 957 958 |
# File 'lib/build/jake.rb', line 951 def self.getBuildProp(propName, config_yml=$app_config) res = nil res = config_yml[propName] if config_yml[propName] res = config_yml[$current_platform][propName] if config_yml[$current_platform] && config_yml[$current_platform][propName] res end |
.getBuildProp2(propName, propName2, config_yml = $app_config) ⇒ Object
980 981 982 983 984 985 986 987 988 989 990 991 992 993 |
# File 'lib/build/jake.rb', line 980 def self.getBuildProp2(propName, propName2, config_yml=$app_config) res = nil if config_yml[propName] res1 = config_yml[propName] res = res1[propName2] if res1 && res1[propName2] end if config_yml[$current_platform] res1 = config_yml[$current_platform][propName] res = res1[propName2] if res1 && res1[propName2] end res end |
.jar(target, manifest, files, isfolder = false) ⇒ Object
542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 |
# File 'lib/build/jake.rb', line 542 def self.jar(target,manifest,files,isfolder=false) jpath = $config["env"]["paths"]["java"] cmd = jpath && jpath.length()>0 ? File.join(jpath, "jar" ) : "jar" #cmd += ".exe" if RUBY_PLATFORM =~ /(win|w)32$/ target.gsub!(/"/,"") args = [] args << "cfm" args << target args << manifest if isfolder args << "-C" args << files args << "." else args << files end puts run(cmd,args) end |
.jarfilelist(target) ⇒ Object
521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 |
# File 'lib/build/jake.rb', line 521 def self.jarfilelist(target) jpath = $config["env"]["paths"]["java"] cmd = jpath && jpath.length()>0 ? File.join(jpath, "jar" ) : "jar" # if RUBY_PLATFORM =~ /(win|w)32$/ # cmd = $config["env"]["paths"]["java"] + "/jar.exe" # else # cmd = $config["env"]["paths"]["java"] + "/jar" # end target.gsub!(/"/,"") args = [] args << "tf" args << target filelist = [] run(cmd,args).each { |file| filelist << file if not file =~ /\/$/ } filelist end |
.localip ⇒ Object
145 146 147 148 149 150 151 152 153 |
# File 'lib/build/jake.rb', line 145 def self.localip orig, Socket.do_not_reverse_lookup = Socket.do_not_reverse_lookup, true # turn off reverse DNS resolution temporarily UDPSocket.open do |s| s.connect '174.142.8.58', 1 s.addr.last end ensure Socket.do_not_reverse_lookup = orig end |
.make_rhoconfig_txt ⇒ Object
867 868 869 870 871 872 873 874 875 876 877 878 879 |
# File 'lib/build/jake.rb', line 867 def self.make_rhoconfig_txt copy_rhoconfig(File.join($app_path, 'rhoconfig.txt'), File.join($srcdir, 'apps', 'rhoconfig.txt')) modify_rhoconfig_for_debug if $remote_debug app_version = "\r\napp_version='#{$app_config["version"]}'" app_version += "\r\napp_name='#{$app_config["name"]}'" app_version += "\r\ntitle_text='#{$app_config["name"]}'" if $current_platform == "win32" app_version += "\r\norg_name='#{$app_config["vendor"]}'" if $current_platform == "win32" 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()) } end |
.modify_file_if_content_changed(file_name, f) ⇒ Object
662 663 664 665 666 667 668 669 670 671 672 673 |
# File 'lib/build/jake.rb', line 662 def self.modify_file_if_content_changed(file_name, f) f.rewind content = f.read() old_content = File.exists?(file_name) ? File.read(file_name) : "" if old_content != content puts "!!!MODIFY #{file_name}" File.open(file_name, "w"){|file| file.write(content)} end f.close end |
.modify_rhoconfig_for_debug ⇒ Object
808 809 810 811 812 813 814 815 816 817 818 819 |
# File 'lib/build/jake.rb', line 808 def self.modify_rhoconfig_for_debug confpath_content = File.read($srcdir + "/apps/rhoconfig.txt") if File.exists?($srcdir + "/apps/rhoconfig.txt") puts "confpath_content=" + confpath_content.to_s confpath_content += "\r\n" + "remotedebug=1" if !confpath_content.include?("remotedebug=") confpath_content += "\r\n" + "debughosturl=" + $rhologhostaddr if !confpath_content.include?("debughosturl=") # puts "confpath_content=" + confpath_content.to_s # puts "$srcdir=" + $srcdir.to_s File.open($srcdir + "/apps/rhoconfig.txt", "w") { |f| f.write(confpath_content) } if confpath_content && confpath_content.length()>0 end |
.normalize_build_yml(yml = $app_config) ⇒ Object
72 73 74 75 |
# File 'lib/build/jake.rb', line 72 def self.normalize_build_yml(yml = $app_config) yml['wm'] = {} unless yml['wm'].is_a?(Hash) yml['wm']['webkit_outprocess'] = '0' if yml['wm']['webkit_outprocess'].nil? end |
.process_spec_output(line) ⇒ Object
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 |
# File 'lib/build/jake.rb', line 238 def self.process_spec_output(line) # Print MSpec example description puts line if line =~ /\| - it/ or line =~ /\| describe/ or line =~ /\| - / line = $1 if line =~ /^I\/APP\s+\(\s+[0-9]+\)\:\s+(.*)/ if $getdump if line =~ /^I/ $getdump = false else if !$faillog.include?(line) $faillog << line end end end if line =~ /JUNIT\| (.*)/ # JUNIT| XML $junitlogs[@default_file_name] << $1 elsif line =~ /JUNITNAME\|\s+(.*)/ # JUNITNAME| name $junitname = File.basename($1.strip,'.xml') $junitlogs[$junitname] = [] elsif line =~ /JUNITBLOB\| (.*)/ if $junitname && $1 $junitlogs[$junitname] << $1 end end ### # Here we are looking for the following pattern of spec stats: # ... APP| ***Total: ... # ... APP| ***Passed: ... # ... APP| ***Failed: ... # ... # ... APP| ***Terminated # Bail out as soon as prev. line is found ### if line =~ /\| \*\*\*Total:\s+(.*)/ # | ***Total: $total += $1.to_i elsif line =~ /\| \*\*\*Passed:\s+(.*)/ # | ***Passed: $passed += $1.to_i elsif line =~ /\| \*\*\*Failed:\s+(.*)/ # | ***Failed: $failed += $1.to_i elsif line =~ /\| \*\*\*Terminated\s+(.*)/ # | ***Terminated return false end # Faillog for MSpec if line =~ /\| FAIL:/ line = line.gsub(/I.*APP\|/,"\n\n***") if !$faillog.include?(line) $faillog << line end $getdump = true end # Faillog for Jusmine if line =~ /I.* Jasmine specRunner\| .*Failed\./ line = line.gsub(/I.*Jasmine specRunner\|/,"\n\n***") if !$faillog.include?(line) $faillog << line end $getdump = true end return true end |
.process_spec_results(start) ⇒ Object
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 |
# File 'lib/build/jake.rb', line 300 def self.process_spec_results(start) finish = Time.now jpath = File.join($app_path,'junitrep') # remove old spec results test_patterns = ['Test*.xml', '*_spec_results.xml'] base_path = File.join($app_path,'**') Dir.glob( test_patterns.map{ |pat| File.join(base_path, pat) } ).each { |file_name| File.delete(file_name) } FileUtils.rm_rf jpath FileUtils.mkdir_p jpath $junitlogs.each do |name, log| if log.length > 0 File.open(File.join(jpath,"#{name}.xml"), "w") { |io| io << log.join().gsub('~~',$/) } end end FileUtils.rm_rf $app_path + "/faillog.txt" if $failed.to_i > 0 puts "************************" puts "\n\n" $faillog.each {|x| puts x } File.open($app_path + "/faillog.txt", "w") { |io| $faillog.each {|x| io << x } } end puts "\n" puts "************************" puts "Tests completed in #{"%.1f" % (finish - start)} seconds" puts "Total: #{$total}" puts "Passed: #{$passed}" puts "Failed: #{$failed}" puts "Failures stored in faillog.txt" if $failed.to_i > 0 puts "************************" puts "\n" end |
.rapc(output, destdir, imports, files, title = nil, vendor = nil, version = nil, icon = nil, library = true, cldc = false, quiet = true, nowarn = true) ⇒ Object
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 |
# File 'lib/build/jake.rb', line 566 def self.rapc(output,destdir,imports,files,title=nil,vendor=nil,version=nil,icon=nil,library=true,cldc=false,quiet=true, nowarn=true) #cmd = $config["env"]["paths"][$config["env"]["bbver"]]["java"] + "/java.exe" # cmd = "java.exe" jdehome = $config["env"]["paths"][@@bbver]["jde"] javabin = $config["env"]["paths"]["java"] cmd = jdehome + "/bin/rapc.exe" currentdir = Dir.pwd() Dir.chdir destdir if output and title and version and vendor f = File.new(output + ".rapc", "w") f.write "MicroEdition-Profile: MIDP-2.0\n" f.write "MicroEdition-Configuration: CLDC-1.1\n" f.write "MIDlet-Name: " + title + "\n" f.write "MIDlet-Version: " + version.to_s + "\n" f.write "MIDlet-Vendor: " + vendor.to_s + "\n" f.write "MIDlet-Jar-URL: " + output + ".jar\n" f.write "MIDlet-Jar-Size: 0\n" f.write "RIM-Library-Flags: 2\n" if library if cldc and icon f.write "MIDlet-1: " + title + "," + icon + ",\n" puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! service_enabled: #{$service_enabled}" $stdout.flush if $service_enabled if $hidden_app == "0" f.write "RIM-MIDlet-Flags-1: 1\n" else f.write "RIM-MIDlet-Flags-1: 3\n" end else if $hidden_app == "0" f.write "RIM-MIDlet-Flags-1: 0\n" else f.write "RIM-MIDlet-Flags-1: 2\n" end end end f.close end args = [] #args << "-classpath" # args << "-jar" #args << jdehome + "/bin/rapc.jar" #args << "net.rim.tools.compiler.Compiler" args << "-javacompiler=" + javabin + "/javac.exe" args << "-quiet" if quiet args << "-nowarn" if nowarn args << 'import=' + imports args << 'codename=' + output args << 'library=' + output if library args << output + '.rapc' args << files cmd.gsub!(/\//,"\\") outputstring = run(cmd, args) puts outputstring unless $? == 0 Dir.chdir currentdir end |
.reset_bulk_server ⇒ Object
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
# File 'lib/build/jake.rb', line 199 def self.reset_bulk_server() require 'rest_client' require 'json' begin platform = platform exact_url = BULK_SYNC_SERVER_URL puts "going to reset server: #{exact_url}" # login to the server unless @bulk_srv_token @bulk_srv_token = RestClient.post("#{exact_url}/rc/v1/system/login", { :login => BULK_SYNC_SERVER_CONSOLE_LOGIN, :password => BULK_SYNC_SERVER_CONSOLE_PASSWORD }.to_json, :content_type => :json) end RestClient.post("#{exact_url}/api/reset", {:api_token => @bulk_srv_token}.to_json, :content_type => :json) puts "reset OK" rescue Exception => e puts "reset_bulk_server failed: #{e}" end end |
.reset_spec_server(platform) ⇒ Object
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
# File 'lib/build/jake.rb', line 179 def self.reset_spec_server(platform) require 'rest_client' require 'json' begin platform = platform exact_url = SYNC_SERVER_BASE_URL.gsub(/exact_platform/, platform) puts "going to reset server: #{exact_url}" # login to the server unless @srv_token @srv_token = RestClient.post("#{exact_url}/rc/v1/system/login", { :login => SYNC_SERVER_CONSOLE_LOGIN, :password => SYNC_SERVER_CONSOLE_PASSWORD }.to_json, :content_type => :json) end # reset server RestClient.post("#{exact_url}/api/reset", {:api_token => @srv_token}.to_json, :content_type => :json) puts "reset OK" rescue Exception => e puts "reset_spec_server failed: #{e}" end end |
.run(command, args, wd = nil, system = false, hideerrors = false) ⇒ Object
412 413 414 |
# File 'lib/build/jake.rb', line 412 def self.run(command, args, wd=nil,system = false, hideerrors = false) self.run2(command, args, {:directory => wd, :system => system, :hiderrors => hideerrors}) end |
.run2(command, args, options = {}, &block) ⇒ Object
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 |
# File 'lib/build/jake.rb', line 340 def self.run2(command, args, = {}, &block) argv = [] currentdir = "" retval = "" argv << command argv += args argv.map! { |x| x.to_s }.map! { |x| x =~ /^".*"$/ ? x[1..-2] : x } wd = [:directory] if not wd.nil? currentdir = Dir.pwd() Dir.chdir wd end cmdstr = argv.map { |x| x =~ / |\|/ ? '"' + x + '"' : x }.join(' ') if [:string_for_add_to_command_line] != nil cmdstr = cmdstr + [:string_for_add_to_command_line] end $stdout.flush unless [:hide_output] puts "PWD: " + Dir.pwd() puts "CMD: " + cmdstr $stdout.flush end hideerrors = [:hideerrors] if hideerrors if RUBY_PLATFORM =~ /(win|w)32$/ nul = "nul" else nul = "/dev/null" end end if [:system] system(cmdstr) retval = "" else # this check was commented by crash on 1.9.2 Ruby on Mac OS argv = cmdstr #if RUBY_VERSION =~ /^1\.8/ if [:nowait] retval = IO.popen(argv) else IO.popen(argv) do |f| while line = f.gets if block_given? res = yield(line) if !res #puts "f.pid : #{f.pid}" Process.kill( 9, f.pid ) end else retval += line unless [:hide_output] puts "RET: " + line $stdout.flush end end end end end end if not wd.nil? Dir.chdir currentdir end retval end |
.run3(command, cd = nil, env = {}) ⇒ Object
446 447 448 |
# File 'lib/build/jake.rb', line 446 def self.run3(command, cd = nil, env = {}) fail "[#{command}]" unless self.run3_dont_fail(command, cd, env) end |
.run3_dont_fail(command, cd = nil, env = {}) ⇒ Object
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 |
# File 'lib/build/jake.rb', line 416 def self.run3_dont_fail(command, cd = nil, env = {}) set_list = [] env.each_pair do |k, v| if RUBY_PLATFORM =~ /(win|w)32$/ set_list << "set \"#{k}=#{v}\"&&" else set_list << "export #{k}=#{v}&&" end end to_print = "CMD: #{command}" to_run = set_list.join('') + command if !cd.nil? to_print = "PWD: #{cd}\n#{to_print}" if RUBY_PLATFORM =~ /(win|w)32$/ cd_ = cd.gsub('/', "\\") to_run = "cd /d \"#{cd_}\"&&#{to_run}" else to_run = "cd '#{cd}'&&#{to_run}" end end puts puts to_print STDOUT.flush system(to_run) end |
.run4(command) ⇒ Object
450 451 452 453 454 |
# File 'lib/build/jake.rb', line 450 def self.run4(command) out = `#{command}` fail "[#{command}]" if $?.exitstatus != 0 out end |
.run_local_server(port = 0) ⇒ Object
155 156 157 158 159 160 161 162 163 164 |
# File 'lib/build/jake.rb', line 155 def self.run_local_server(port = 0) require 'webrick' addr = localip #:BindAddress => addr, server = WEBrick::HTTPServer.new :Port => port port = server.config[:Port] puts "LOCAL SERVER STARTED ON #{addr}:#{port}" Thread.new { server.start } return server, addr, port end |
.run_local_server_with_logger(port, log_file) ⇒ Object
166 167 168 169 170 171 172 173 174 175 176 177 |
# File 'lib/build/jake.rb', line 166 def self.run_local_server_with_logger(port, log_file) require 'webrick' addr = localip log = WEBrick::Log.new log_file access_log = [[log_file, WEBrick::AccessLog::COMBINED_LOG_FORMAT]] server = WEBrick::HTTPServer.new :Port => port, :Logger => log, :AccessLog => access_log port = server.config[:Port] # puts "LOCAL SERVER STARTED ON #{addr}:#{port}" Thread.new { server.start } return server, addr, port end |
.run_rho_log_server(app_path) ⇒ Object
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 |
# File 'lib/build/jake.rb', line 881 def self.run_rho_log_server(app_path) require 'webrick' confpath_content = File.read($srcdir + "/apps/rhoconfig.txt") if File.exists?($srcdir + "/apps/rhoconfig.txt") confpath_content += "\r\n" + "rhologurl=http://" + $rhologhostaddr + ":" + $rhologhostport.to_s() if !confpath_content.include?("rhologurl=") confpath_content += "\r\n" + "LogToSocket=1" if !confpath_content.include?("LogToSocket=") File.open($srcdir + "/apps/rhoconfig.txt", "w") { |f| f.write(confpath_content) } if confpath_content && confpath_content.length()>0 begin require 'net/http' res = Net::HTTP.start(Jake.localip(), $rhologhostport) {|http| http.post('/', "RHOLOG_GET_APP_NAME") } puts "res : #{res}" puts "body : #{res.body}" if ( res && res.body == app_path) puts "Log server is already running. Reuse it." started = File.open($app_path + "/started", "w+") started.close return else puts "Close Log server for another app." res = Net::HTTP.start(Jake.localip(), $rhologhostport) {|http| http.post('/', "RHOLOG_CLOSE") } end rescue Exception => e puts "EXC: #{e}" end system("START rake run:webrickrhologserver[\"#{app_path}\"]") end |
.set_bbver(bbver) ⇒ Object
77 78 79 |
# File 'lib/build/jake.rb', line 77 def self.set_bbver(bbver) @@bbver = bbver end |
.setBuildProp(propName, propValue, config_yml = $app_config) ⇒ Object
947 948 949 |
# File 'lib/build/jake.rb', line 947 def self.setBuildProp(propName, propValue, config_yml=$app_config) config_yml[propName] = propValue end |
.unjar(src, targetdir) ⇒ Object
496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 |
# File 'lib/build/jake.rb', line 496 def self.unjar(src,targetdir) jpath = $config["env"]["paths"]["java"] cmd = jpath && jpath.length()>0 ? File.join(jpath, "jar" ) : "jar" # if RUBY_PLATFORM =~ /(win|w)32$/ # cmd = $config["env"]["paths"]["java"] + "/jar.exe" # else # cmd = $config["env"]["paths"]["java"] + "/jar" # end p = Pathname.new(src) src = p.realpath currentdir = Dir.pwd() src = src.to_s.gsub(/"/,"") args = Array.new args << "xf" args << src.to_s Dir.chdir targetdir puts run(cmd,args) Dir.chdir currentdir end |
.unzip(src_zip, dest_dir) ⇒ Object
Unzips archive to specified directory
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 |
# File 'lib/build/jake.rb', line 725 def self.unzip(src_zip, dest_dir) require 'zip' require 'fileutils' unless File.exist?(dest_dir) FileUtils.mkdir_p(dest_dir) end Zip::File.open(src_zip) do |zip_file| unzipped_bytes = 0 total_bytes = zip_file.inject(0) { |result, each| result + each.size } zip_file.each do |entry| if block_given? and entry.size != 0 unzipped_bytes = unzipped_bytes + entry.size yield(unzipped_bytes, total_bytes, "Unpacking files: #{(unzipped_bytes * 100) / total_bytes}%") end file_dir_name = File.join(dest_dir,File.dirname(entry.name)) FileUtils::mkdir_p file_dir_name unless Dir.exists?(file_dir_name) entry.extract(File.join(dest_dir, entry.name)) end end end |
.zip(where, what, dest) ⇒ Object
Zips specified files from directory
757 758 759 760 761 762 763 764 765 766 767 768 769 |
# File 'lib/build/jake.rb', line 757 def self.zip(where, what, dest) require 'zip' if File.exist?(dest) FileUtils.rm(dest); end Zip::File.open(dest, Zip::File::CREATE) do |zipfile| what.each do |filename| zipfile.add(filename, File.join(where, filename)) end end end |
.zip_upgrade_bundle(folder_path, zip_file_path) ⇒ Object
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 |
# File 'lib/build/jake.rb', line 771 def self.zip_upgrade_bundle(folder_path, zip_file_path) require 'zip' current_dir = Dir.pwd() begin Dir.chdir(folder_path) File.delete(zip_file_path) if File.exists?(zip_file_path) items_to_zip = [] Zip::File.open(zip_file_path, Zip::File::CREATE) do |zip_file| (Dir['RhoBundle/**/*']).each { |path| exclude_items = (Jake.getBuildProp2('rhobundle', 'exclude_items') || []).collect { |each| %r{#{each}} } begin puts "Excluded: #{path}".warning next end if (exclude_items.any? { |each| path.index(each) }) puts "added to zip : #{path}" zip_file.add(path, path) } end ensure Dir.chdir(current_dir) end end |