rakefile.rb in rhodes-2.0.3 vs rakefile.rb in rhodes-2.1.0

- old
+ new

@@ -12,17 +12,17 @@ end $app_basedir = pwd chdir File.dirname(__FILE__) -require 'lib/build/jake.rb' +require File.join(pwd, 'lib/build/jake.rb') -load 'platform/bb/build/bb.rake' -load 'platform/android/build/android.rake' -load 'platform/iphone/rbuild/iphone.rake' -load 'platform/wm/build/wm.rake' -load 'platform/linux/tasks/linux.rake' +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') def get_dir_hash(dir, init = nil) hash = init hash = Digest::SHA2.new if hash.nil? Dir.glob(dir + "/**/*").each do |f| @@ -57,10 +57,12 @@ $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 = "*.*" else $all_files_mask = "*" end @@ -88,21 +90,28 @@ 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 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, :remove_destination => true + cp_r asset + "/.", dest, :preserve => true, :remove_destination => true end def clear_linker_settings if $config["platform"] == "iphone" @@ -169,41 +178,11 @@ Dir.glob("*").each { |f| cp_r f,dest unless f =~ /^ext(\/|(\.yml)?$)/ } chdir start 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 } - - 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 - - extensions = [] - extensions += $app_config["extensions"] if $app_config["extensions"] and - $app_config["extensions"].is_a? Array - extensions += $app_config[$config["platform"]["extensions"]] if $config["platform"] and - $config["platform"]["extensions"] and $config["platform"]["extensions"].is_a? Array - $app_config["extensions"] = extensions - +def init_extensions(startdir, dest) extentries = [] extlibs = [] extpaths = $app_config["extpaths"] $app_config["extensions"].each do |extname| @@ -228,60 +207,64 @@ end unless extpath.nil? add_extension(extpath, dest) - 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" - libs.map! { |lib| lib + ".lib" } - else - libs.map! { |lib| "lib" + lib + ".a" } - end - extlibs += libs - end + 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") - exists = [] - 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 $config["platform"] != "bb" + exts = File.join($startdir, "platform", "shared", "ruby", "ext", "rho", "extensions.c") + exists = [] + 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.open(exts, "w") do |f| - f.puts "// WARNING! THIS FILE IS GENERATED AUTOMATICALLY! DO NOT EDIT IT MANUALLY!" - f.puts "// Generated #{Time.now.to_s}" - if $config["platform"] == "wm" - # Add libraries through pragma - extlibs.each do |lib| - f.puts "#pragma comment(lib, \"#{lib}\")" + if exists.sort! != extentries.sort! + File.open(exts, "w") do |f| + 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 - 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) } - set_linker_flags - + 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!(/"/,"\\\"") @@ -293,18 +276,46 @@ 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') - cp_r app + '/public', File.join($srcdir,'apps') if File.exists? app + '/public' - cp app + '/rhoconfig.txt', File.join($srcdir,'apps') + 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) } + 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" @@ -314,22 +325,25 @@ copy_assets($assetfolder) if ($assetfolder and File.exists? $assetfolder) chdir File.join($srcdir,'apps') - Dir.glob("**/*.#{$config['platform']}.*").each do |file| - oldfile = file.gsub(Regexp.new(Regexp.escape('.') + $config['platform'] + Regexp.escape('.')),'.') + replace_platform = $config['platform'] + replace_platform = "bb6" if $bb6 + 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("**/*.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 } + Dir.glob("**/CVS").each { |f| rm_rf f } end def create_manifest dir = File.join($srcdir, 'apps') @@ -344,11 +358,11 @@ if File.basename(path) == "config.rb" puts "******ERROR enumerating models***********" puts "Model definition has changed and doesn't use config.rb anymore: '#{path}' " puts "You should replace config.rb with <model_name>.rb file as described: " - puts "http://wiki.rhomobile.com/index.php/Rhom#Rhom_Models_2.0" + puts "http://wiki.rhomobile.com/index.php/Rhom#Rhom_Models" puts "*****************************************" exit 1 end fname = File.dirname(path) @@ -367,11 +381,34 @@ end fappManifest.close() end + +def process_exclude_folders + excl = [] + + if $app_config["excludedirs"] + excl << $app_config["excludedirs"]['all'] if $app_config["excludedirs"]['all'] + excl << $app_config["excludedirs"][$config["platform"]] if $app_config["excludedirs"][$config["platform"]] + end + + if $config["excludedirs"] + excl << $config["excludedirs"]['all'] if $config["excludedirs"]['all'] + excl << $config["excludedirs"][$config["platform"]] if $config["excludedirs"][$config["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 @@ -381,22 +418,13 @@ compileERB = "lib/build/compileERB/bb.rb" rhodeslib = File.dirname(__FILE__) + "/lib/framework" common_bundle_start(startdir,dest) - if not $config["excludedirs"].nil? - if $config["excludedirs"].has_key?($config["platform"]) - chdir File.join($srcdir, 'apps') - - excl = $config["excludedirs"][$config["platform"]] - excl.each do |mask| - Dir.glob(mask).each {|f| rm_rf f} - end - end - end + process_exclude_folders() - cp_r File.join(startdir, "res/build-tools/db"), File.join($srcdir, 'apps') + cp_r File.join(startdir, "platform/shared/db/res/db"), File.join($srcdir, 'apps') chdir startdir #create manifest create_manifest @@ -435,21 +463,21 @@ 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 - + 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 `jar uf ../RhoBundle.jar apps/#{$all_files_mask}` unless $? == 0 puts "Error creating Rhobundle.jar" exit 1 end @@ -464,10 +492,11 @@ 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 @@ -493,11 +522,11 @@ Dir.glob("**/*.rb") { |f| rm f } Dir.glob("**/*.erb") { |f| rm f } chdir startdir - cp_r "res/build-tools/db", $srcdir + cp_r "platform/shared/db/res/db", $srcdir end end end @@ -689,11 +718,14 @@ puts "Copying Rakefile" cp "Rakefile", "rakefile.rb" puts "Building manifest" out = "" - Dir.glob("**/*") {|fname| out << fname + "\n" if File.file? fname} + Dir.glob("**/*") do |fname| + # TODO: create exclusion list + out << fname + "\n" if File.file? fname and not fname =~ /rhosync-client/ + end File.open("Manifest.txt",'w') {|f| f.write(out)} puts "Loading gemspec" spec = Gem::Specification.load('rhodes.gemspec') @@ -729,5 +761,52 @@ task :rdocpush => :rdoc do puts "Pushing RDOC. This may take a while" `scp -r html/* dev@dev.rhomobile.com:dev.rhomobile.com/rhodes/` end + +namespace "build" do + # desc "Build rhosync-client package" + task :rhosync_client do + + ver = File.read("rhosync-client/version") #.gsub(".", "_") + zip_name = "rhosync-client-"+ver+".zip" + + bin_dir = "rhosync-client-bin" + src_dir = bin_dir + "/rhosync-client-"+ver #"/src" + shared_dir = src_dir + "/platform/shared" + rm_rf bin_dir + rm zip_name if File.exists? zip_name + mkdir_p bin_dir + mkdir_p src_dir + + cp_r 'rhosync-client', src_dir, :preserve => true + + mv src_dir+"/rhosync-client/license", src_dir + mv src_dir+"/rhosync-client/README.textile", src_dir + mv src_dir+"/rhosync-client/version", src_dir + mv src_dir+"/rhosync-client/changelog", src_dir + + Dir.glob(src_dir+"/rhosync-client/**/*").each do |f| + #puts f + rm_rf f if f.index("/build/") || f.index(".DS_Store") + + end + + mkdir_p shared_dir + + Dir.glob("platform/shared/*").each do |f| + next if f == "platform/shared/ruby" || f == "platform/shared/rubyext" || f == "platform/shared/xruby" || f == "platform/shared/shttpd" || + f == "platform/shared/stlport" + + #puts f + cp_r f, shared_dir #, :preserve => true + end + startdir = pwd + chdir bin_dir + puts `zip -r #{File.join(startdir, zip_name)} *` + + chdir startdir + + rm_rf bin_dir + end +end \ No newline at end of file