lib/ruboto/util/update.rb in ruboto-0.9.0 vs lib/ruboto/util/update.rb in ruboto-0.10.0.rc.0
- old
+ new
@@ -8,11 +8,10 @@
###########################################################################
#
# Updating components
#
-
def update_android
root = Dir.getwd
build_xml_file = "#{root}/build.xml"
name = REXML::Document.new(File.read(build_xml_file)).root.attributes['name']
@@ -120,19 +119,10 @@
# EMXIF
ant_script.gsub!(/\s*<!-- BEGIN added by Ruboto -->.*?<!-- END added by Ruboto -->\s*/m, '')
raise "Bad ANT script" unless ant_script.gsub!(/\s*(<\/project>)/, "\n\n#{run_tests_override}\n\n\\1")
File.open('build.xml', 'w') { |f| f << ant_script }
-
- # FIXME(uwe): Remove when we stop supporting update from Ruboto < 0.5.3
- if File.directory? 'assets/scripts'
- log_action 'Moving test scripts to the "src" directory.' do
- FileUtils.mv Dir['assets/scripts/*'], 'src'
- FileUtils.rm_rf 'assets/scripts'
- end
- end
- # EMXIF
end
end
def update_jruby(force=nil, explicit = false)
jruby_core = Dir.glob("libs/jruby-core-*.jar")[0]
@@ -170,11 +160,14 @@
log_action("Copying #{JRubyJars::core_jar_path} to libs") { copier.copy_from_absolute_path JRubyJars::core_jar_path, "libs" }
log_action("Copying #{JRubyJars::stdlib_jar_path} to libs") { copier.copy_from_absolute_path JRubyJars::stdlib_jar_path, "libs" }
# FIXME(uwe): Try keeping the class count low to enable installation on Android 2.3 devices
# unless new_jruby_version =~ /^1.7.0/ && verify_target_sdk < 15
- log_action("Copying dx.jar to libs") { copier.copy 'libs' }
+ log_action("Copying dx.jar to libs") do
+ copier.copy 'libs'
+ # File.open('project.properties', 'a'){|f| f << "dex.force.jumbo=true\n"}
+ end
# end
reconfigure_jruby_libs(new_jruby_version)
puts "JRuby version is now: #{new_jruby_version}"
@@ -203,17 +196,10 @@
# EMXIF
end
def update_assets
puts "\nCopying files:"
-
- # FIXME(uwe): Remove when we stop supporting updating from Ruboto < 0.6.0
- if File.exists?('Rakefile') && !File.exists?('rakelib/ruboto.rake')
- FileUtils.rm 'Rakefile'
- end
- # EMXIF
-
weak_copier = Ruboto::Util::AssetCopier.new Ruboto::ASSETS, '.', false
%w{.gitignore Rakefile}.each { |f| log_action(f) { weak_copier.copy f } }
copier = Ruboto::Util::AssetCopier.new Ruboto::ASSETS, '.'
%w{assets rakelib res/layout test}.each do |f|
@@ -331,29 +317,19 @@
save_manifest
end
end
def update_core_classes(force = nil)
- # FIXME(uwe): Remove when we stop supporting updating from Ruboto 0.5.5 and older.
- FileUtils.rm_rf 'src/org/ruboto/callbacks'
- FileUtils.rm_f 'src/org/ruboto/RubotoView.java'
- # EMXIF
-
generate_core_classes(:class => "all", :method_base => "on", :method_include => "", :method_exclude => "", :force => force, :implements => "")
end
def read_ruboto_version
version_file = File.expand_path("./#{SCRIPTS_DIR}/ruboto/version.rb")
File.read(version_file).slice(/^\s*VERSION = '(.*?)'/, 1) if File.exists?(version_file)
end
def update_ruboto(force=nil)
- log_action("Copying ruboto.rb") do
- from = File.expand_path(Ruboto::GEM_ROOT + "/assets/#{SCRIPTS_DIR}/ruboto.rb")
- to = File.expand_path("./#{SCRIPTS_DIR}/ruboto.rb")
- FileUtils.cp from, to
- end
log_action("Copying ruboto/version.rb") do
from = File.expand_path(Ruboto::GEM_ROOT + "/lib/ruboto/version.rb")
to = File.expand_path("./#{SCRIPTS_DIR}/ruboto/version.rb")
FileUtils.mkdir_p File.dirname(to)
FileUtils.cp from, to
@@ -368,10 +344,11 @@
end
def reconfigure_jruby_libs(jruby_core_version)
reconfigure_jruby_core(jruby_core_version)
reconfigure_jruby_stdlib
+ reconfigure_dx_jar
end
# - Removes unneeded code from jruby-core
# - Split into smaller jars that can be used separately
def reconfigure_jruby_core(jruby_core_version)
@@ -381,24 +358,37 @@
FileUtils.rm_rf 'tmp'
Dir.mkdir 'tmp'
Dir.chdir 'tmp' do
FileUtils.move "../#{jruby_core}", "."
`jar -xf #{jruby_core}`
+ raise "Unpacking jruby-core jar failed: #$?" unless $? == 0
File.delete jruby_core
if jruby_core_version >= '1.7.0'
excluded_core_packages = [
+ '**/*Darwin*',
+ '**/*Solaris*',
+ '**/*windows*',
+ '**/*Windows*',
'META-INF', 'cext',
'com/headius', # included since we are trying to use DexClient
'com/headius/invokebinder',
- 'com/kenai/constantine', 'com/kenai/jffi', 'com/martiansoftware', 'ext', 'java',
+ 'com/kenai/constantine', 'com/kenai/jffi', 'com/martiansoftware',
+ 'ext',
+ 'java',
'jline', 'jni',
'jnr/constants/platform/darwin', 'jnr/constants/platform/fake', 'jnr/constants/platform/freebsd',
'jnr/constants/platform/openbsd', 'jnr/constants/platform/sunos', 'jnr/constants/platform/windows',
- 'jnr/ffi/annotations', 'jnr/ffi/byref', 'jnr/ffi/provider', 'jnr/ffi/util',
+ 'jnr/ffi/annotations', 'jnr/ffi/byref',
+ 'jnr/ffi/provider', 'jnr/ffi/util',
'jnr/ffi/posix/util',
+ 'jnr/ffi/Struct$*',
+ 'jnr/ffi/types',
+ 'jnr/posix/MacOS*',
+ 'jnr/posix/OpenBSD*',
'org/apache',
'org/bouncycastle', # TODO(uwe): Issue #154 Add back when we add jruby-openssl. The bouncycastle included in Android is cripled.
+ 'org/fusesource',
'org/jruby/ant',
'org/jruby/cext',
# 'org/jruby/compiler', # Needed for initialization, but shoud not be necessary
# 'org/jruby/compiler/impl', # Needed for initialization, but shoud not be necessary
'org/jruby/compiler/util',
@@ -408,27 +398,17 @@
'org/jruby/embed/osgi',
# 'org/jruby/ext/ffi', # Used by several JRuby core classes, but should not be needed unless we add FFI support
'org/jruby/ext/ffi/io',
'org/jruby/ext/ffi/jffi',
'org/jruby/ext/openssl', # TODO(uwe): Issue #154 Add back when we add jruby-openssl.
-
- # FIXME(uwe): IR is the future. We should try using it.
- # 'org/jruby/ir',
- 'org/jruby/ir/dataflow',
- # 'org/jruby/ir/instructions',
- # 'org/jruby/ir/interpreter',
- # 'org/jruby/ir/operands',
- # 'org/jruby/ir/passes',
- 'org/jruby/ir/representations',
- 'org/jruby/ir/targets',
- 'org/jruby/ir/transformations',
- 'org/jruby/ir/util',
-
'org/jruby/javasupport/bsf',
- # 'org/jruby/runtime/invokedynamic', # Should be excluded
# 'org/jruby/management', # should be excluded
+
+ 'org/jruby/org/bouncycastle', # TODO(uwe): Issue #154 Add back when we add jruby-openssl. The bouncycastle included in Android is cripled.
+
+ # 'org/jruby/runtime/invokedynamic', # Should be excluded
]
# TODO(uwe): Remove when we stop supporting jruby-jars < 1.7.0
else
print 'Retaining com.kenai.constantine and removing jnr for JRuby < 1.7.0...'
@@ -450,34 +430,43 @@
]
# ODOT
end
excluded_core_packages.each do |i|
- FileUtils.remove_dir(i, true) rescue puts "Failed to remove package: #{i} (#{$!})"
+ if File.directory? i
+ FileUtils.remove_dir(i, true) rescue puts "Failed to remove package: #{i} (#{$!})"
+ elsif Dir[i].each { |f| FileUtils.rm_rf f }.empty?
+ puts "Exclude pattern #{i.inspect} found no files."
+ end
end
# FIXME(uwe): Add a Ruboto.yml config for this if it works
- # Reduces the installation footprint, but also reduces performance and stack usage
+ # Reduces the installation footprint, but also reduces performance and increases stack
# FIXME(uwe): Measure the performance change
- if false && jruby_core_version =~ /^1.7.0/ && Dir.chdir('../..') { verify_target_sdk < 15 }
- invokers = Dir['**/*${INVOKER$*,POPULATOR}.class']
- log_action("Removing invokers & populators(#{invokers.size})") do
+ if false && jruby_core_version =~ /^1.7./ && Dir.chdir('../..') { verify_min_sdk < 15 }
+ invokers = Dir['**/*$INVOKER$*.class']
+ log_action("Removing invokers(#{invokers.size})") do
FileUtils.rm invokers
end
+ populators = Dir['**/*$POPULATOR.class']
+ log_action("Removing populators(#{populators.size})") do
+ FileUtils.rm populators
+ end
end
# Uncomment this section to get a jar for each top level package in the core
#Dir['**/*'].select{|f| !File.directory?(f)}.map{|f| File.dirname(f)}.uniq.sort.reverse.each do |dir|
# `jar -cf ../jruby-core-#{dir.gsub('/', '.')}-#{jruby_core_version}.jar #{dir}`
# FileUtils.rm_rf dir
#end
# Add our proxy class factory
- `javac -source 1.6 -target 1.6 -cp .:#{Ruboto::ASSETS}/libs/dx.jar:#{Dir["#{Ruboto::SdkVersions::ANDROID_HOME}/platforms/android-*/android.jar"][0]} -d . #{Ruboto::GEM_ROOT}/lib/*.java`
+ `javac -source 1.6 -target 1.6 -cp .:#{Ruboto::ASSETS}/libs/dx.jar -bootclasspath #{Dir["#{Ruboto::SdkVersions::ANDROID_HOME}/platforms/android-*/android.jar"][0]} -d . #{Ruboto::GEM_ROOT}/lib/*.java`
raise "Compile failed" unless $? == 0
`jar -cf ../#{jruby_core} .`
+ raise "Creating repackaged jruby-core jar failed: #$?" unless $? == 0
end
FileUtils.remove_dir "tmp", true
end
end
end
@@ -492,10 +481,11 @@
Dir.chdir 'tmp' do
FileUtils.mkdir_p 'old'
FileUtils.mkdir_p 'new/jruby.home'
Dir.chdir 'old' do
`jar -xf ../../#{jruby_stdlib}`
+ raise "Unpacking jruby-stdlib jar failed: #$?" unless $? == 0
end
FileUtils.move 'old/META-INF/jruby.home/lib', 'new/jruby.home/lib'
FileUtils.rm_rf 'new/jruby.home/lib/ruby/gems'
if excluded_stdlibs.any?
@@ -529,14 +519,43 @@
# FileUtils.rm_rf d
# FileUtils.rm_rf file if File.exists?(file)
# end
`jar -cf ../../#{jruby_stdlib} .`
+ raise "Creating repackaged jruby-stdlib jar failed: #$?" unless $? == 0
end
end
end
FileUtils.remove_dir "tmp", true
+ end
+ end
+
+ # - Removes unneeded code from dx.jar
+ def reconfigure_dx_jar
+ dx_jar = 'dx.jar'
+ Dir.chdir 'libs' do
+ log_action("Removing unneeded classes from #{dx_jar}") do
+ FileUtils.rm_rf 'tmp'
+ Dir.mkdir 'tmp'
+ Dir.chdir 'tmp' do
+ FileUtils.move "../#{dx_jar}", "."
+ `jar -xf #{dx_jar}`
+ raise "Unpacking dx.jar jar failed: #$?" unless $? == 0
+ File.delete dx_jar
+ excluded_core_packages = [
+ 'com/android/dx/command',
+ 'com/android/dx/ssa',
+ 'junit',
+ ]
+ excluded_core_packages.each do |i|
+ FileUtils.remove_dir(i, true) rescue puts "Failed to remove package: #{i} (#{$!})"
+ end
+ `jar -cf ../#{dx_jar} .`
+ raise "Creating repackaged dx.jar failed: #$?" unless $? == 0
+ end
+ FileUtils.remove_dir "tmp", true
+ end
end
end
def update_bundle
if File.exist?('Gemfile.apk') && File.exists?('libs/bundle.jar')