rakefile.rb in rhodes-3.2.3 vs rakefile.rb in rhodes-3.3.0.beta.1

- old
+ new

@@ -260,10 +260,24 @@ 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 + + #Process motorola extensions + if capabilities.index("motorola") + $app_config["capabilities"] += ["webkit_browser"] if $app_config["extensions"].index("webkit-browser") + $app_config["extensions"] += ["rhoelements"] + + idx_barcode = $app_config["extensions"].index("barcode") + $app_config["extensions"][idx_barcode] = "barcode-moto" if idx_barcode + + $app_config["capabilities"] += ["barcode"] if $app_config["extensions"].index("barcode-moto") + end + + puts "$app_config['extensions'] : #{$app_config['extensions']}" + puts "$app_config['capabilities'] : #{$app_config['capabilities']}" $hidden_app = $app_config["hidden_app"].nil?() ? "0" : $app_config["hidden_app"] #application build configs @@ -380,95 +394,118 @@ chdir start end def init_extensions(startdir, dest) extentries = [] + nativelib = [] extlibs = [] - extpaths = $app_config["extpaths"] - - $app_config["extensions"].each do |extname| + extpaths = $app_config["extpaths"] + + puts 'init extensions' + $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 + end if extpath.nil? begin $rhodes_extensions = nil require extname - extpath = $rhodes_extensions[0] unless $rhodes_extensions.nil? - rescue Exception => e - + extpath = $rhodes_extensions[0] unless $rhodes_extensions.nil? + $app_config["extpaths"] << extpath + rescue Exception => e + puts "exception" end - end - + unless extpath.nil? - add_extension(extpath, dest) + add_extension(extpath, dest) unless dest.nil? 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? + 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 = extconf["exttype"] + + if nlib != nil + nlib.each do |libname| + nativelib << libname + end + end + + extentries << entry unless entry.nil? + + if type.to_s() != "nativelib" 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 - end - + exts = File.join($startdir, "platform", "shared", "ruby", "ext", "rho", "extensions.c") - + puts "exts " + exts + if $config["platform"] != "bb" - exists = [] + 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 + 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 - - if (exists.sort! != extentries.sort! ) || (!File.exists?(exts)) - File.open(exts, "w") do |f| - puts "MODIFY : #{exts}" + 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 + 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 - extentries.each do |entry| - f.puts "extern void #{entry}(void);" + + nativelib.each do |lib| + f.puts "#pragma comment(lib, \"#{lib}\")" end - f.puts "void Init_Extensions(void) {" - extentries.each do |entry| - f.puts " #{entry}();" - end - f.puts "}" 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) } + extlibs.each { |lib| add_linker_library(lib) } + nativelib.each { |lib| add_linker_library(lib) } - set_linker_flags + set_linker_flags end unless $app_config["constants"].nil? File.open("rhobuild.rb","w") do |file| file << "module RhoBuild\n" @@ -478,17 +515,20 @@ end file << "end\n" end end - if $excludeextlib + if $excludeextlib and (not dest.nil?) chdir dest $excludeextlib.each {|e| Dir.glob(e).each {|f| rm f}} end + end def common_bundle_start(startdir, dest) + puts "common_bundle_start" + app = $app_path rhodeslib = "lib/framework" rm_rf $srcdir mkdir_p $srcdir @@ -595,11 +635,11 @@ namespace "build" do namespace "bundle" do task :xruby do #needs $config, $srcdir, $excludelib, $bindir app = $app_path - jpath = $config["env"]["paths"]["java"] + 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" @@ -712,10 +752,76 @@ chdir startdir cp_r "platform/shared/db/res/db", $srcdir end + task :upgrade_package do + + $bindir = File.join($app_path, "bin") + $current_platform = 'empty' + $srcdir = File.join($bindir, "RhoBundle") + + $targetdir = File.join($bindir, "target") + $excludelib = ['**/builtinME.rb','**/ServeME.rb','**/dateME.rb','**/rationalME.rb'] + $tmpdir = File.join($bindir, "tmp") + $appname = $app_config["name"] + $appname = "Rhodes" if $appname.nil? + $vendor = $app_config["vendor"] + $vendor = "rhomobile" if $vendor.nil? + $vendor = $vendor.gsub(/^[^A-Za-z]/, '_').gsub(/[^A-Za-z0-9]/, '_').gsub(/_+/, '_').downcase + $appincdir = File.join $tmpdir, "include" + + Rake::Task["config:common"].invoke + + Rake::Task["build:bundle:noxruby"].invoke + + new_zip_file = File.join($srcdir, "apps", "upgrade_bundle.zip") + + if RUBY_PLATFORM =~ /(win|w)32$/ + begin + + require 'rubygems' + require 'zip/zip' + require 'find' + require 'fileutils' + include FileUtils + + root = $srcdir + + new_zip_file = File.join($srcdir, "upgrade_bundle.zip") + + Zip::ZipFile.open(new_zip_file, Zip::ZipFile::CREATE)do |zipfile| + Find.find(root) do |path| + Find.prune if File.basename(path)[0] == ?. + dest = /apps\/(\w.*)/.match(path) + if dest + puts ' add file to zip : '+dest[1].to_s + zipfile.add(dest[1],path) + end + end + end + rescue + puts 'ERROR !' + puts 'Require "rubyzip" gem for make zip file !' + puts 'Install gem by "gem install rubyzip"' + end + else + chdir File.join($srcdir, "apps") + sh %{zip -r upgrade_bundle.zip .} + end + + + cp new_zip_file, $bindir + + rm new_zip_file + + + + end + + + task :noiseq do app = $app_path rhodeslib = File.dirname(__FILE__) + "/lib/framework" compileERB = "lib/build/compileERB/bb.rb" startdir = pwd @@ -926,9 +1032,10 @@ end end end end + task :gem do puts "Removing old gem" rm_rf Dir.glob("rhodes*.gem") puts "Copying Rakefile"