rakefile.rb in rhodes-7.1.17 vs rakefile.rb in rhodes-7.4.1
- old
+ new
@@ -22,10 +22,14 @@
# THE SOFTWARE.
#
# http://rhomobile.com
#------------------------------------------------------------------------
+task :gem do
+ load 'lib/build/buildgem.rb'
+end
+
require_relative 'lib/build/rho_packages.rb'
require File.join(File.dirname(__FILE__), 'lib/build/required_time.rb')
# RequiredTime.hook()
@@ -45,12 +49,12 @@
require 'openssl'
require 'pathname'
require 'rexml/document'
require 'securerandom'
require 'uri'
-require 'logger'
require 'rake'
+require 'logger'
# It does not work on Mac OS X. rake -T prints nothing. So I comment this hack out.
# NB: server build scripts depend on proper rake -T functioning.
=begin
#Look, another big fat hack. Make it so we can remove tasks from rake -T by setting comment to nil
@@ -80,11 +84,10 @@
$startdir.gsub!('\\', '/')
$push_type = -1
chdir File.dirname(__FILE__), :verbose => (Rake.application.options.trace == true)
-
require File.join(pwd, 'lib/build/jake.rb')
require File.join(pwd, 'lib/build/RhoLogger.rb')
require File.join(pwd, 'lib/build/GeneratorTimeChecker.rb')
require File.join(pwd, 'lib/build/GeneralTimeChecker.rb')
require File.join(pwd, 'lib/build/CheckSumCalculator.rb')
@@ -95,12 +98,29 @@
require File.join(pwd, 'lib/build/BuildConfig.rb')
require File.join(pwd, 'lib/build/RhoHubAccount.rb')
require File.join(pwd, 'lib/build/rhoDevelopment.rb')
+$logger = Logger.new(STDOUT)
+if Rake.application.options.trace
+ ENV["RHODES_BUILD_LOGGER_LEVEL"]= "DEBUG"
+ $logger.level = Logger::DEBUG
+else
+ ENV["RHODES_BUILD_LOGGER_LEVEL"]= "INFO"
+ $logger.level = Logger::INFO
+end
+$logger.formatter = proc do |severity,datetime,progname,msg|
+ "[#{severity}]\t#{msg}\n"
+end
+
+Jake.set_logger( $logger )
+
+
+
+
$timestamp_start_milliseconds = 0
module Rake
class Application
@@ -114,32 +134,13 @@
end
end #class Task
end #module Rake
-
-
-$logger = Logger.new(STDOUT)
-if Rake.application.options.trace
- ENV["RHODES_BUILD_LOGGER_LEVEL"]= "DEBUG"
- $logger.level = Logger::DEBUG
-else
- ENV["RHODES_BUILD_LOGGER_LEVEL"]= "INFO"
- $logger.level = Logger::INFO
-end
-
-
Rake::FileUtilsExt.verbose(Rake.application.options.trace == true)
-$logger.formatter = proc do |severity,datetime,progname,msg|
- "[#{severity}]\t#{msg}\n"
-end
-
-Jake.set_logger( $logger )
-
-
def print_timestamp(msg = 'just for info')
if $timestamp_start_milliseconds == 0
$timestamp_start_milliseconds = (Time.now.to_f*1000.0).to_i
end
curmillis = (Time.now.to_f*1000.0).to_i - $timestamp_start_milliseconds
@@ -153,17 +154,35 @@
load File.join(pwd, 'lib/commonAPI/printing_zebra/ext/platform/wm/PrintingService/PrintingService/installer/Rakefile')
#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/win32/build/win32.rake')
load File.join(pwd, 'platform/linux/tasks/linux.rake')
load File.join(pwd, 'platform/wp8/build/wp.rake')
load File.join(pwd, 'platform/uwp/build/uwp.rake')
load File.join(pwd, 'platform/osx/build/osx.rake')
load File.join(pwd, 'platform/sailfish/build/sailfish.rake')
+module OS
+ def OS.windows?
+ (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
+ end
+ def OS.mac?
+ (/darwin/ =~ RUBY_PLATFORM) != nil
+ end
+
+ def OS.unix?
+ !OS.windows?
+ end
+
+ def OS.linux?
+ OS.unix? and not OS.mac?
+ end
+end
+
#------------------------------------------------------------------------
def get_dir_hash(dir, init = nil)
hash = init
hash = Digest::SHA2.new if hash.nil?
@@ -196,11 +215,11 @@
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 = ['encrypt_files_key', 'nodejs_application', 'rubynodejs_application', 'security_token', 'encrypt_database', 'use_deprecated_encryption','android_title', 'iphone_db_in_approot', 'iphone_set_approot', 'iphone_userpath_in_approot', "iphone_use_new_ios7_status_bar_style", "iphone_full_screen", "webkit_outprocess", "webengine", "iphone_enable_startup_logging"]
+$application_build_configs_keys = ['encrypt_files_key', 'nodejs_application', 'rubynodejs_application', 'security_token', 'encrypt_database', 'use_deprecated_encryption','android_title', 'iphone_db_in_approot', 'iphone_set_approot', 'iphone_userpath_in_approot', "iphone_use_new_ios7_status_bar_style", "iphone_full_screen", "webkit_outprocess", "webengine", "iphone_enable_startup_logging", "local_https_server_with_client_checking"]
$winxpe_build = false
def make_application_build_config_header_file
f = StringIO.new("", "w+")
@@ -285,11 +304,11 @@
end
f.puts ''
if $js_application || $nodejs_application
- puts '#define RHO_NO_RUBY' if USE_TRACES
+ $logger.debug '#define RHO_NO_RUBY'
f.puts '#define RHO_NO_RUBY'
f.puts '#define RHO_NO_RUBY_API'
else
$logger.debug '//#define RHO_NO_RUBY'
end
@@ -2034,14 +2053,16 @@
extpaths << File.join($startdir, "../rho-tau-extensions-"+ENV['rhodes_version']+"/libs")
$app_config["extpaths"] = extpaths
if $app_config["build"] and $app_config["build"].casecmp("release") == 0
$debug = false
+ elsif $app_config["build"] and $app_config["build"].casecmp("debug") == 0
+ $debug = true
else
+ puts "\n\n\n\n\nYou must choose configuration manually in build.yml file. Type 'build: release' or 'build: debug' in root section!\n\n\n\n"
$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
@@ -2052,13 +2073,21 @@
if ($current_platform == "iphone") || ($current_platform == "android")
extensions << "decryptstub"
else
puts "do not checking for encrypt/decrypt because not iOS/Android 1"
end
- extensions << "zlib" if $current_platform == "win32" # required by coreapi on win32 for gzip support in Network
+ if $current_platform == "win32"
+ extensions << "zlib" # required by coreapi on win32 for gzip support in Network
+ extensions << "openssl.so" if $rhosimulator_build
+ extensions << "openssl" if $rhosimulator_build
+ extensions << "digest" if $rhosimulator_build
+ extensions << "digest-sha2" if $rhosimulator_build
+ end
+
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) }
@@ -2168,10 +2197,11 @@
end
if $current_platform == "uwp"
$app_config['extensions'] = $app_config['extensions'] | ['barcode']
end
+
end
if $current_platform == "android"
if $app_config['extensions'].index('rhoelementsext')
$app_config['extensions'].delete('rhoelementsext')
@@ -2336,11 +2366,11 @@
def copy_assets(asset, file_map)
dest = File.join($srcdir,'apps/public')
- cp_r asset + "/.", dest, :preserve => true, :remove_destination => true, :verbose => USE_TRACES
+ cp_r asset + "/.", dest, :preserve => true, :remove_destination => true, :verbose => Rake.application.options.trace
end
def clear_linker_settings
if $config["platform"] == "iphone"
# outfile = ""
@@ -2353,10 +2383,11 @@
# end
# File.open($startdir + "/platform/iphone/rhorunner.xcodeproj/project.pbxproj","w") {|f| f.write outfile}
# ENV["EXTENSIONS_LDFLAGS"] = ""
$ldflags = ""
+ $ldflags_array = []
end
end
def add_linker_library(libraryname)
@@ -2369,23 +2400,29 @@
# outfile << line
# end
# end
# File.open($startdir + "/platform/iphone/rhorunner.xcodeproj/project.pbxproj","w") {|f| f.write outfile}
# end
- simulator = $sdk =~ /iphonesimulator/
+ if $config["platform"] == "iphone"
+ 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"
+ 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?
+ $ldflags_array << "#{tmpdir}/#{libraryname}"
end
- $ldflags << "#{tmpdir}/#{libraryname}\n" unless $ldflags.nil?
end
def add_inker_library_absolute(fulllibraryfilepath)
+ if $config["platform"] == "iphone"
$ldflags << fulllibraryfilepath + "\n" unless $ldflags.nil?
+ #$ldflags_array << fulllibraryfilepath
+ end
end
def set_linker_flags
if $config["platform"] == "iphone"
simulator = $sdk =~ /iphonesimulator/
@@ -2785,15 +2822,15 @@
extjsmodulefiles << f
end
end
Dir.glob(extpath + "/public/api/generated/*.js").each do |f|
- if /(rho\.orm)|(rho\.ruby\.runtime)|(rho\.rhosim\.fix)/i.match(f.downcase())
- puts "add #{f} to extjsmodulefiles_opt.." if USE_TRACES
+ if /(rho\.orm)|(rho\.ruby\.runtime)|(rho\.rhosim\.fix)/i.match(f.downcase())
+ $logger.debug "add #{f} to extjsmodulefiles_opt.."
extjsmodulefiles_opt << f
else
- puts "add #{f} to extjsmodulefiles.." if USE_TRACES
+ $logger.debug "add #{f} to extjsmodulefiles.."
extjsmodulefiles << f
end
end
end
#end
@@ -2862,11 +2899,11 @@
mkdir_p rhoapi_nodejs_folder
end
#
if !$skip_build_js_api_files
if extjsmodulefiles.count > 0
- puts 'extjsmodulefiles=' + extjsmodulefiles.to_s if USE_TRACES
+ $logger.debug "extjsmodulefiles=#{extjsmodulefiles.to_s}"
write_modules_js(rhoapi_js_folder, "rhoapi-modules.js", extjsmodulefiles, do_separate_js_modules)
$ebfiles_shared_rt_js_appliction = ($js_application and ($current_platform == "wm" or $current_platform == "android") and $app_config["capabilities"].index('shared_runtime'))
if $use_shared_runtime || $ebfiles_shared_rt_js_appliction
start_path = Dir.pwd
@@ -2886,11 +2923,11 @@
write_modules_js(rhoapi_nodejs_folder, "rhoapi.js", extnodejsmodulefiles, false)
end
# make rhoapi-modules-ORM.js only if not shared-runtime (for WM) build
if !$shared_rt_js_appliction
if extjsmodulefiles_opt.count > 0
- puts 'extjsmodulefiles_opt=' + extjsmodulefiles_opt.to_s if USE_TRACES
+ $logger.debug 'extjsmodulefiles_opt=' + extjsmodulefiles_opt.to_s
#write_modules_js(rhoapi_js_folder, "rhoapi-modules-ORM.js", extjsmodulefiles_opt, do_separate_js_modules)
write_orm_modules_js(rhoapi_js_folder, extjsmodulefiles_opt)
end
end
end
@@ -2997,11 +3034,11 @@
def public_folder_cp_r(src_dir, dst_dir, level, file_map, start_path)
return if src_dir == dst_dir
- mkdir_p dst_dir, :verbose => USE_TRACES if not File.exists? dst_dir
+ mkdir_p dst_dir, :verbose => Rake.application.options.trace if not File.exists? dst_dir
Dir.foreach(src_dir) do |filename|
next if filename.eql?('.') || filename.eql?('..')
next if filename.eql?('api') && level == 0
@@ -3028,11 +3065,11 @@
puts "map_items=" + map_items.to_s if Rake.application.options.trace
puts "new_time=" + new_time.to_s if Rake.application.options.trace
puts "old_time=" + old_time.to_s if Rake.application.options.trace
end
- cp filepath, dst_path, :preserve => true, :verbose => USE_TRACES
+ cp filepath, dst_path, :preserve => true, :verbose => Rake.application.options.trace
end
end
end
def common_bundle_start( startdir, dest)
@@ -3518,11 +3555,11 @@
minify_inplace_batch(files_to_minify) if files_to_minify.length>0
end
def minify_inplace_batch(files_to_minify)
- puts "minifying file list: #{files_to_minify}" if USE_TRACES
+ $logger.debug "minifying file list: #{files_to_minify}"
cmd = "java -jar #{$minifier} -o \"x$:x\""
files_to_minify.each { |f| cmd += " #{f}" }
@@ -3532,25 +3569,25 @@
error = nil
begin
output, error, status = Open3.capture3(cmd)
rescue Exception => e
- puts "Minify error: #{e.inspect}"
+ $logger.debug "Minify error: #{e.inspect}"
error = e.inspect
end
- puts "Minification done: #{status}" if USE_TRACES
+ $logger.debug "Minification done: #{status}"
if !status || !status.exitstatus.zero?
- puts "WARNING: Minification error!" if USE_TRACES
+ $logger.debug "WARNING: Minification error!"
error = output if error.nil?
BuildOutput.warning(["Minification errors occured. Minificator stderr output: \n" + error], 'Minification error')
end
end
def minify_inplace(filename,type)
- puts "minify file: #{filename}" if USE_TRACES
+ $logger.debug "minify file: #{filename}"
f = StringIO.new("", "w+")
f.write(File.read(filename))
f.rewind()
@@ -3583,11 +3620,11 @@
error = e.inspect
#raise e
end
if !status || !status.exitstatus.zero?
- puts "WARNING: Minification error!" if USE_TRACES
+ $logger.debug "WARNING: Minification error!"
error = output if error.nil?
BuildOutput.warning(['Failed to minify ' + filename, 'Output: ' + error], 'Minification error')
@@ -3867,33 +3904,10 @@
end
end
end
-task :gem do
- puts "Removing old 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
- next unless File.file? fname
- next if fname =~ /rhoconnect-client/
- next if fname =~ /^spec\/api_generator_spec/
- next if fname =~ /ruby-standalone/
-
- out << fname + "\n"
- end
- File.open("Manifest.txt",'w') {|f| f.write(out)}
-
- puts "Building gem"
- Jake.run3('gem build rhodes.gemspec')
-end
-
namespace "rhomobile-debug" do
task :gem do
puts "Removing old gem"
rm_rf Dir.glob("rhomobile-debug*.gem")
rm_rf "rhomobile-debug"
@@ -3924,23 +3938,29 @@
task :tasks do
Rake::Task.tasks.each {|t| puts t.to_s.ljust(27) + "# " + t.comment.to_s}
end
-task :switch_app do
- puts "Preparing rhobuild.yml"
+task :switch_app => [ 'config:load' ] do
+
+ $logger.info "Configuring app location: #{$app_path}"
+ $config["env"]["app"] = $app_path.gsub(/\\/,"/")
+
+=begin
+ $logger.info "Preparing rhobuild.yml"
rhobuildyml = File.dirname(__FILE__) + "/rhobuild.yml"
if File.exists? rhobuildyml
config = YAML::load_file(rhobuildyml)
else
- puts "Cant find rhobuild.yml"
- exit 1
+ $logger.warn "Cant find rhobuild.yml"
end
config["env"]["app"] = $app_path.gsub(/\\/,"/")
File.open( rhobuildyml, 'w' ) do |out|
YAML.dump( config, out )
end
+=end
+
end
#Rake::RDocTask.new do |rd|
#RDoc::Task.new do |rd|
# rd.main = "README.textile"
@@ -4076,11 +4096,11 @@
startJSModules = []
startJSModules_opt = []
endJSModules = []
rhoapi_js_folder = File.join( $app_path, "public/api" )
- puts "rhoapi_js_folder: #{rhoapi_js_folder}" if USE_TRACES
+ $logger.debug "rhoapi_js_folder: #{rhoapi_js_folder}"
do_separate_js_modules = Jake.getBuildBoolProp("separate_js_modules", $app_config, false)
# TODO: checker init
gen_checker = GeneratorTimeChecker.new
@@ -4188,14 +4208,14 @@
extjsmodulefiles << f
end
end
Dir.glob(extpath + "/public/api/generated/*.js").each do |f|
if /(rho\.orm)|(rho\.ruby\.runtime)|(rho\.rhosim\.fix)/i.match(f.downcase())
- puts "add #{f} to extjsmodulefiles_opt.." if USE_TRACES
+ $logger.debug "add #{f} to extjsmodulefiles_opt.."
extjsmodulefiles_opt << f
else
- puts "add #{f} to extjsmodulefiles.." if USE_TRACES
+ $logger.debug "add #{f} to extjsmodulefiles.."
extjsmodulefiles << f
end
end
end
@@ -4215,16 +4235,16 @@
rm_rf rhoapi_js_folder if Dir.exist?(rhoapi_js_folder)
mkdir_p rhoapi_js_folder
end
#
if extjsmodulefiles.count > 0
- puts "extjsmodulefiles: #{extjsmodulefiles}" if USE_TRACES
+ $logger.debug "extjsmodulefiles: #{extjsmodulefiles}"
write_modules_js(rhoapi_js_folder, "rhoapi-modules.js", extjsmodulefiles, do_separate_js_modules)
end
#
if extjsmodulefiles_opt.count > 0
- puts "extjsmodulefiles_opt: #{extjsmodulefiles_opt}" if USE_TRACES
+ $logger.debug "extjsmodulefiles_opt: #{extjsmodulefiles_opt}"
#write_modules_js(rhoapi_js_folder, "rhoapi-modules-ORM.js", extjsmodulefiles_opt, do_separate_js_modules)
write_orm_modules_js(rhoapi_js_folder, extjsmodulefiles_opt)
end
sim_conf += "ext_path=#{config_ext_paths}\r\n" if config_ext_paths && config_ext_paths.length() > 0
@@ -4267,33 +4287,36 @@
args << "-security_token=#{ENV['security_token']}" if !ENV['security_token'].nil?
path = ''
cmd = ''
if RUBY_PLATFORM =~ /(win|w)32$/
+
+ path = File.join( $startdir, "platform/win32/RhoSimulator" )
+ unless File.directory?( path )
+ downloadRhosim( path )
+ end
+
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
oldDir = File.join( $startdir, "platform/win32/RhoSimulator" )
newDir = oldDir
- #newDir = File.join( $startdir, "platform/win32/RhoSimulatorRunnable" )
- #rm_rf newDir if Dir.exist?(newDir)
- #FileUtils.mkpath newDir
-
- #cp_r File.join(oldDir, "."), newDir
-
qtdir = ENV['QTDIR']
- #if !qtdir.nil?
- #cp File.join(qtdir, "bin/Qt5Core.dll"), newDir
- args << "-remote-debugging-port=9090"
- #end
- #Jake.run "taskkill /f /im RhoSimulator.exe"
+ args << "-remote-debugging-port=9090"
+
cmd = File.join(newDir, 'rhosimulator.exe')
elsif RUBY_PLATFORM =~ /darwin/
+
+ path = File.join( $startdir, "platform/osx/bin/RhoSimulator" )
+ unless File.directory?( path )
+ downloadRhosim( path )
+ end
+
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
@@ -4424,9 +4447,66 @@
$rhodes_version = File.read(File.join($startdir,'version')).chomp
File.open(File.join($startdir, 'platform/shared/qt/rhodes/RhoSimulatorVersion.h'), "wb") do |fversion|
fversion.write( "#define RHOSIMULATOR_VERSION \"#{$rhodes_version}\"\n" )
end
end
+end
+
+def downloadRhosim( targetPath )
+ require 'tempfile'
+
+ commit = `git rev-parse HEAD`.strip
+ branch = `git rev-parse --abbrev-ref HEAD`.strip
+
+ if RUBY_PLATFORM =~ /(win|w)32$/
+ url = "https://tau-autobuilds.s3.eu-central-1.amazonaws.com/rhomobile/rhodes/#{branch}/#{commit}/win32-RhoSimulator/RhoSimulator.zip"
+ elsif RUBY_PLATFORM =~ /darwin/
+ url = "https://tau-autobuilds.s3.eu-central-1.amazonaws.com/rhomobile/rhodes/#{branch}/#{commit}/osx-rhosimulator_osx-/RhoSimulator.app.zip"
+ else
+ return
+ end
+
+ $logger.info "Downloading rhosim from #{url}"
+
+ file = Tempfile.new('rhosim.zip')
+ file.binmode
+
+ uri = URI.parse(url)
+
+ http = Net::HTTP.new(uri.host, uri.port)
+ http.use_ssl = true
+
+ http.request_get(uri.path) do |response|
+ length = response['Content-Length'].to_i
+ x = 0
+
+ response.read_body do |fragment|
+ x += fragment.length
+ file.write(fragment)
+ end
+ end
+
+ file.flush
+ file.close
+
+ $logger.info "Unzipping #{file.path} to #{targetPath}"
+
+ mkdir_p( targetPath )
+
+ require 'zip'
+
+ zipfile = file.path
+ file.close
+
+ Zip::File.open(zipfile) do |zip_file|
+ zip_file.each do |f|
+ fpath = File.join(targetPath, f.name)
+ zip_file.extract(f, fpath)
+ end
+ end
+
+ file.delete
+
end
#------------------------------------------------------------------------
namespace :run do