Rakefile in rhodes-3.0.2 vs Rakefile in rhodes-3.1.0.beta.1
- old
+ new
@@ -1,8 +1,34 @@
+#------------------------------------------------------------------------
+# (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 'rake/rdoctask'
+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
@@ -20,10 +46,12 @@
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|
@@ -198,10 +226,13 @@
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 = []
@@ -391,11 +422,11 @@
next if line !~ /^\s*extern\s+void\s+([A-Za-z_][A-Za-z0-9_]*)/
exists << $1
end
end
- if exists.sort! != extentries.sort!
+ 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}"
@@ -881,29 +912,62 @@
end
end
task :gem do
puts "Removing old gem"
- rm_rf Dir.glob("*.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 =~ /rhosync-client/
+ 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
@@ -920,10 +984,11 @@
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
@@ -932,50 +997,167 @@
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
+ # desc "Build rhoconnect-client package"
+ task :rhoconnect_client do
- ver = File.read("rhosync-client/version").chomp #.gsub(".", "_")
- zip_name = "rhosync-client-"+ver+".zip"
+ ver = File.read("rhoconnect-client/version").chomp #.gsub(".", "_")
+ zip_name = "rhoconnect-client-"+ver+".zip"
- bin_dir = "rhosync-client-bin"
- src_dir = bin_dir + "/rhosync-client-"+ver #"/src"
+ bin_dir = "rhoconnect-client-bin"
+ src_dir = bin_dir + "/rhoconnect-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
+ cp_r 'rhoconnect-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
+ mv src_dir+"/rhoconnect-client/license", src_dir
+ mv src_dir+"/rhoconnect-client/README.textile", src_dir
+ mv src_dir+"/rhoconnect-client/version", src_dir
+ mv src_dir+"/rhoconnect-client/changelog", src_dir
- Dir.glob(src_dir+"/rhosync-client/**/*").each do |f|
+ Dir.glob(src_dir+"/rhoconnect-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"
-
+ f == "platform/shared/stlport" || f == "platform/shared/qt"
#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
+
+namespace "run" do
+
+ desc "Run application on RhoSimulator"
+ task :rhosimulator_base => "config:common" do
+ puts "rho_reload_app_changes : #{ENV['rho_reload_app_changes']}"
+ $path = ""
+ $args = ["-approot='#{$app_path}'"]
+ cmd = nil
+
+ if RUBY_PLATFORM =~ /(win|w)32$/
+ if $config['env']['paths']['rhosimulator'] and $config['env']['paths']['rhosimulator'].length() > 0
+ $path = File.join( $config['env']['paths']['rhosimulator'], "rhosimulator.exe" )
+ else
+ $path = File.join( $startdir, "platform/win32/RhoSimulator/rhosimulator.exe" )
+ end
+ elsif RUBY_PLATFORM =~ /darwin/
+ if $config['env']['paths']['rhosimulator'] and $config['env']['paths']['rhosimulator'].length() > 0
+ $path = File.join( $config['env']['paths']['rhosimulator'], "RhoSimulator.app" )
+ else
+ $path = File.join( $startdir, "platform/osx/bin/RhoSimulator/RhoSimulator.app" )
+ end
+ cmd = 'open'
+ $args.unshift($path, '--args')
+ else
+ if $config['env']['paths']['rhosimulator'] and $config['env']['paths']['rhosimulator'].length() > 0
+ # $path = File.join( $config['env']['paths']['rhosimulator'], "RhoSimulator" )
+ else
+ # $path = File.join( $startdir, "platform/linux/bin/RhoSimulator/RhoSimulator" )
+ end
+ $args << ">/dev/null"
+ $args << "2>/dev/null"
+ end
+
+ $appname = $app_config["name"].nil? ? "Rhodes" : $app_config["name"]
+ if !File.exists?($path)
+ puts "Cannot find RhoSimulator: '#{$path}' does not exists"
+ puts "Install Rhodes gem OR"
+ puts "Install RhoSimulator and modify 'env:paths:rhosimulator' section in '<rhodes>/rhobuild.yml'"
+ exit 1
+ end
+
+ sim_conf = "rhodes_path='#{$startdir}'\r\n"
+ sim_conf += "app_name='#{$appname}'\r\n"
+ if ( ENV['rho_reload_app_changes'] )
+ sim_conf += "reload_app_changes=#{ENV['rho_reload_app_changes']}\r\n"
+ else
+ sim_conf += "reload_app_changes=1\r\n"
+ end
+
+ if $config['debug']
+ sim_conf += "debug_port=#{$config['debug']['port']}\r\n"
+ else
+ sim_conf += "debug_port=\r\n"
+ end
+
+ if $config['debug'] && $config['debug']['host'] && $config['debug']['host'].length() > 0
+ sim_conf += "debug_host='#{$config['debug']['host']}'\r\n"
+ else
+ sim_conf += "debug_host='127.0.0.1'\r\n"
+ end
+
+ sim_conf += $rhosim_config if $rhosim_config
+
+ #check gem extensions
+ $app_config["extensions"].each do |extname|
+ begin
+ $rhodes_extensions = nil
+ require extname
+ extpath = $rhodes_extensions[0] unless $rhodes_extensions.nil?
+ sim_conf += "ext_path='#{extpath}'\r\n" if extpath && extpath.length() > 0
+ rescue Exception => e
+ end
+ end
+
+ fdir = File.join($app_path, 'rhosimulator')
+ mkdir fdir unless File.exist?(fdir)
+
+ fname = File.join(fdir, 'rhosimconfig.txt')
+ File.open(fname, "wb") do |fconf|
+ fconf.write( sim_conf )
+ end
+
+ if not cmd.nil?
+ $path = cmd
+ end
+ end
+
+ task :rhosimulator => "run:rhosimulator_base" do
+ puts 'start rhosimulator'
+ Jake.run2 $path, $args, {:nowait => true}
+ end
+
+ task :rhosimulator_debug => "run:rhosimulator_base" do
+ puts 'start rhosimulator debug'
+ Jake.run2 $path, $args, {:nowait => true}
+
+ if RUBY_PLATFORM =~ /darwin/
+ while 1
+ end
+ end
+ end
+
+end
+
+namespace "build" do
+ task :rhosimulator => "config:common" do
+ if RUBY_PLATFORM =~ /(win|w)32$/
+ Rake::Task["build:win32:rhosimulator"].invoke
+ elsif RUBY_PLATFORM =~ /darwin/
+ Rake::Task["build:osx:rhosimulator"].invoke
+ else
+ puts "Sorry, at this time RhoSimulator can be built for Windows and Mac OS X only"
+ exit 1
+ end
end
end