ruboto 1.0.3 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,13 +5,13 @@ require 'rexml/document'
5
5
  namespace :libs do
6
6
  desc 'take a fresh copy of the stdlib and rebuild it for use with this project'
7
7
  task :reconfigure_stdlib do
8
- require_relative 'stdlib_dependencies'
8
+ require_relative 'ruboto.stdlib'
9
9
  reconfigure_jruby_stdlib
10
10
  end
11
11
 
12
12
  desc 'check the stdlib dependencies and store them in auto_dependencies.yml'
13
13
  task :check_dependencies do
14
- require_relative 'stdlib_dependencies'
14
+ require_relative 'ruboto.stdlib'
15
15
 
16
16
  if File.exists? 'auto_dependencies.yml'
17
17
  old_dep = (YAML::load_file('auto_dependencies.yml') || {})
@@ -22,20 +22,20 @@ namespace :libs do
22
22
  puts "Dependencies haven't changed: #{new_dep.join(', ')}"
23
23
  else
24
24
  puts "New dependencies: #{new_dep.join(', ')}"
25
- File.open( "auto_dependencies.yml", 'w' ) do |out|
26
- YAML.dump( new_dep, out )
25
+ File.open('auto_dependencies.yml', 'w') do |out|
26
+ YAML.dump(new_dep, out)
27
27
  end
28
28
  end
29
29
  end
30
30
  end
31
31
 
32
- def log_action(initial_text, final_text="Done.", &block)
32
+ def log_action(initial_text, final_text='Done.', &block)
33
33
  $stdout.sync = true
34
34
 
35
- print initial_text, "..."
35
+ print initial_text, '...'
36
36
  result = yield
37
37
  puts final_text
38
-
38
+
39
39
  result
40
40
  end
41
41
 
@@ -46,12 +46,14 @@ end
46
46
 
47
47
  # - Moves ruby stdlib to the root of the jruby-stdlib jar
48
48
  def reconfigure_jruby_stdlib
49
- abort "cannot find jruby library in libs" if Dir["libs/jruby*"].empty?
50
-
49
+ abort 'cannot find jruby library in libs' if Dir['libs/jruby*'].empty?
50
+ if (gem_version = ENV['JRUBY_JARS_VERSION'])
51
+ gem('jruby-jars', gem_version)
52
+ end
51
53
  require 'jruby-jars'
52
54
 
53
55
  log_action("Copying #{JRubyJars::stdlib_jar_path} to libs") { FileUtils.cp JRubyJars::stdlib_jar_path, "libs/jruby-stdlib-#{JRubyJars::VERSION}.jar" }
54
- StdlibDependencies.load('rakelib/stdlib.yml')
56
+ StdlibDependencies.load('rakelib/ruboto.stdlib.yml')
55
57
 
56
58
  Dir.chdir 'libs' do
57
59
  jruby_stdlib = Dir['jruby-stdlib-*.jar'][-1]
@@ -92,7 +94,7 @@ def remove_unneeded_parts_of_stdlib
92
94
  included_stdlibs = ruboto_config['included_stdlibs']
93
95
  excluded_stdlibs = [*ruboto_config['excluded_stdlibs']].compact
94
96
 
95
- if included_stdlibs and included_stdlibs == "auto"
97
+ if included_stdlibs == 'auto'
96
98
  if File.exists? '../../auto_dependencies.yml'
97
99
  included_stdlibs = YAML::load_file('../../auto_dependencies.yml')
98
100
  else
@@ -140,15 +142,15 @@ def remove_unneeded_parts_of_stdlib
140
142
  end
141
143
  end
142
144
  end
143
- end
144
-
145
- if included_stdlibs.nil? and excluded_stdlibs.any?
145
+ elsif excluded_stdlibs.any?
146
146
  # Don't allow jruby and java to be removed
147
- excluded_stdlibs = excluded_stdlibs - %w(jruby java)
148
-
147
+ excluded_stdlibs -= %w(jruby java)
149
148
  ruby_stdlib_versions = Dir['*'] - %w(gems)
150
- ruby_stdlib_versions.each do |ld|
151
- excluded_stdlibs.each do |d|
149
+ excluded_stdlibs.each do |d|
150
+ if Dir["{#{ruby_stdlib_versions.join(',')}}/#{d}"].empty?
151
+ puts "Exclude pattern #{dir.inspect} does not match any files."
152
+ end
153
+ ruby_stdlib_versions.each do |ld|
152
154
  dir = "#{ld}/#{d}"
153
155
  FileUtils.rm_rf dir if File.exists? dir
154
156
  file = "#{dir}.rb"
@@ -157,11 +159,22 @@ def remove_unneeded_parts_of_stdlib
157
159
  end
158
160
  print "excluded #{excluded_stdlibs.join(' ')}..."
159
161
  end
162
+
163
+ # Corrects bug in krypt that loads FFI.
164
+ # Only affects JRuby 1.7.11, 1.7.12, and 9000 (until fixed).
165
+ # FIXME(uwe): Remove when we stop supporting JRuby 1.7.11 and 1.7.12
166
+ Dir['**/provider.rb'].each do |f|
167
+ puts "Patching #{f}..."
168
+ File.write(f, File.read(f).sub(%r{require_relative 'provider/ffi'}, "# require_relative 'provider/ffi'"))
169
+ end
170
+ # EMXIF
171
+
160
172
  end
161
173
  end
162
174
 
163
175
  def cleanup_jars
164
176
  Dir.chdir 'new' do
177
+ cmd_line_jar_found = false
165
178
  Dir['**/*.jar'].each do |j|
166
179
 
167
180
  # FIXME(uwe): Installing bcmail-jdk15-146.jar + bcprov-jdk15-146.jar fails due to
@@ -174,23 +187,31 @@ def cleanup_jars
174
187
  # EMXIF
175
188
 
176
189
  # FIXME(uwe): Adding the jars triggers the "LinearAlloc exceeded capacity"
177
- # bug in Android 2.3. Remove when we stop supporting android-10 and older
178
- abort "cannot find your AndroidManifest.xml to extract info from it" unless File.exists? '../../../AndroidManifest.xml'
190
+ # bug in Android 4.0. Remove when we stop supporting android-15 and older
191
+ abort 'cannot find your AndroidManifest.xml to extract info from it' unless File.exists? '../../../AndroidManifest.xml'
179
192
  manifest = REXML::Document.new(File.read('../../../AndroidManifest.xml')).root
180
193
  min_sdk_version = manifest.elements['uses-sdk'].attributes['android:minSdkVersion'].to_i
181
- if min_sdk_version <= 10
194
+ if min_sdk_version <= 15
182
195
  FileUtils.rm j
196
+ cmd_line_jar_found = true
183
197
  next
184
198
  end
185
199
  # EMXIF
186
200
 
187
- # FIXME(uwe): These should be included but break the 64K method count limit
188
- if j =~ /bcpkix-jdk15on-1\.?47|bcprov-jdk15on-1\.?47|jopenssl|kryptcore|kryptproviderjdk/
201
+ # FIXME(uwe): Duplicate in JRuby <=1.7.12. Remove when we stop supporting JRuby 1.7.12.
202
+ if j =~ /bc.*147/
189
203
  FileUtils.rm j
190
204
  next
191
205
  end
192
206
  # EMXIF
193
207
 
208
+ # Command line option libraries not needed
209
+ if j =~ /jline|readline/
210
+ cmd_line_jar_found = true
211
+ FileUtils.rm j
212
+ next
213
+ end
214
+
194
215
  print "#{File.basename(j).chomp('.jar')}..."
195
216
  system "jar xf #{j}"
196
217
  FileUtils.rm j
@@ -221,6 +242,32 @@ def cleanup_jars
221
242
  public
222
243
  Java::json.ext.ParserService.new.basicLoad(JRuby.runtime)
223
244
  END_CODE
245
+ elsif j =~ %r{jopenssl.jar$}
246
+ jar_load_code = <<-END_CODE
247
+ require 'jruby'
248
+ puts 'Starting JOpenSSL Service'
249
+ public
250
+ # Java::JopensslService.new.basicLoad(JRuby.runtime)
251
+ require 'java'
252
+ # remove the original bouncycastle provider of Android (com.android.org.bouncycastle.jce.provider)
253
+ java.security.Security.removeProvider("BC")
254
+ # add the new one used by jopenssl
255
+ java.security.Security.addProvider( org.bouncycastle.jce.provider.BouncyCastleProvider.new )
256
+ END_CODE
257
+ elsif j =~ %r{kryptproviderjdk.jar$}
258
+ jar_load_code = <<-END_CODE
259
+ require 'jruby'
260
+ puts 'Starting JRuby KryptproviderjdkService Service'
261
+ public
262
+ Java::KryptproviderjdkService.new.basicLoad(JRuby.runtime)
263
+ END_CODE
264
+ elsif j =~ %r{kryptcore.jar$}
265
+ jar_load_code = <<-END_CODE
266
+ require 'jruby'
267
+ puts 'Starting JRuby KryptcoreService Service'
268
+ public
269
+ Java::KryptcoreService.new.basicLoad(JRuby.runtime)
270
+ END_CODE
224
271
  else
225
272
  jar_load_code = ''
226
273
  end
@@ -228,6 +275,9 @@ def cleanup_jars
228
275
  File.open("#{j}.rb", 'w') { |f| f << jar_load_code }
229
276
  File.open("#{j}.jar.rb", 'w') { |f| f << jar_load_code }
230
277
  end
278
+ unless cmd_line_jar_found
279
+ puts "\nWARNING: No command line jar filtered. Has it changed?"
280
+ end
231
281
  end
232
282
  end
233
283
 
@@ -242,10 +292,10 @@ def find_dependencies
242
292
  else
243
293
  ruboto_config = {}
244
294
  end
245
- ruby_version = ruboto_config['ruby_version'] || "1.9"
295
+ ruby_version = ruboto_config['ruby_version'] || '1.9'
246
296
 
247
- local = StdlibDependencies.collect("src").dependencies
248
- stdlib = StdlibDependencies.load('rakelib/stdlib.yml')[ruby_version]
297
+ local = StdlibDependencies.collect('src').dependencies
298
+ stdlib = StdlibDependencies.load('rakelib/ruboto.stdlib.yml')[ruby_version]
249
299
 
250
300
  dependencies = local.values.flatten
251
301
  new_values = []
@@ -253,7 +303,7 @@ def find_dependencies
253
303
 
254
304
  while check_values.any?
255
305
  check_values.each do |j|
256
- new_values += stdlib[j] if stdlib[j]
306
+ new_values += stdlib[j] if stdlib[j]
257
307
  end
258
308
 
259
309
  check_values = new_values - dependencies
@@ -261,6 +311,7 @@ def find_dependencies
261
311
  new_values = []
262
312
  end
263
313
 
264
- dependencies.map{|d| d.split("/")[0]}.uniq.sort
265
- end
314
+ dependencies.reject! { |f| File.exists? "src/#{f}.rb" }
266
315
 
316
+ dependencies.map { |d| d.split('/')[0] }.uniq.sort
317
+ end
@@ -6,7 +6,7 @@
6
6
  class StdlibDependencies
7
7
  attr_reader :dependencies, :version
8
8
 
9
- REQUIRE = %r{^\s*require[ (]['"]([a-zA-Z0-9/-_]+)["'][)]?\s*$}
9
+ REQUIRE = %r{^\s*require[ (]['"]([a-zA-Z0-9/_-]+)["'][)]?\s*$}
10
10
  REQUIRE_RELATIVE = %r{^\s*require_relative[ (]['"]([a-zA-Z0-9/-_]+)["'][)]?\s*$}
11
11
 
12
12
  def self.[](key)
@@ -17,20 +17,20 @@ class StdlibDependencies
17
17
  @@versions ||= {}
18
18
  end
19
19
 
20
- def self.collect(dir=".")
21
- local = new("app")
22
- Dir.chdir(dir) do
23
- local.check_dir(["ruboto"])
20
+ def self.collect(dir='.')
21
+ local = new('app')
22
+ Dir.chdir(dir) do
23
+ local.check_dir(['ruboto'])
24
24
  end
25
25
  local
26
26
  end
27
27
 
28
- def self.generate(dir=".")
28
+ def self.generate(dir='.')
29
29
  versions
30
30
 
31
31
  Dir.chdir(dir) do
32
- raise("Can't find shared directory") unless File.directory?("shared")
33
- Dir["*"].select{|d| File.directory?(d) && d != "shared"}.each do |d|
32
+ raise("Can't find shared directory") unless File.directory?('shared')
33
+ Dir['*'].select{|d| File.directory?(d) && d != 'shared'}.each do |d|
34
34
  @@versions[d] = new(d).generate
35
35
  end
36
36
  end
@@ -40,14 +40,9 @@ class StdlibDependencies
40
40
 
41
41
  def self.dump(file)
42
42
  require 'yaml'
43
-
44
43
  all_dependencies = {}
45
44
  versions.each{|k, v| all_dependencies[k] = v.dependencies}
46
-
47
- File.open( file, 'w' ) do |out|
48
- YAML.dump( all_dependencies, out )
49
- end
50
-
45
+ File.open(file, 'w') { |out| YAML.dump(all_dependencies, out) }
51
46
  versions
52
47
  end
53
48
 
@@ -55,10 +50,10 @@ class StdlibDependencies
55
50
  require 'yaml'
56
51
 
57
52
  @@versions = {}
58
- raise("Can't find #{file}") unless File.exists?(file)
53
+ raise("Can't find #{file}") unless File.exists?(file)
59
54
 
60
- File.open(file) do |versions|
61
- YAML.load(versions).each{|k,v| @@versions[k] = new(k, v)}
55
+ File.open(file) do |f|
56
+ YAML.load(f).each{|k,v| @@versions[k] = new(k, v)}
62
57
  end
63
58
 
64
59
  versions
@@ -74,10 +69,10 @@ class StdlibDependencies
74
69
  end
75
70
 
76
71
  def generate
77
- raise("Can't find shared directory") unless File.directory?("shared")
78
- raise("Can't find #{@version} directory") unless File.directory?(@version)
72
+ raise("Can't find shared directory") unless File.directory?('shared')
73
+ raise("Can't find #{@version} directory") unless File.directory?(@version)
79
74
 
80
- Dir.chdir("shared"){check_dir}
75
+ Dir.chdir('shared'){check_dir}
81
76
  Dir.chdir(@version){check_dir}
82
77
 
83
78
  # Clean up dependencies
@@ -85,10 +80,10 @@ class StdlibDependencies
85
80
  # remove duplicates
86
81
  @dependencies[i] = @dependencies[i].uniq
87
82
 
88
- # remove references to self
83
+ # remove references to self
89
84
  @dependencies[i] = @dependencies[i] - [i]
90
85
 
91
- # sort
86
+ # sort
92
87
  @dependencies[i] = @dependencies[i].sort
93
88
  end
94
89
 
@@ -128,9 +123,8 @@ class StdlibDependencies
128
123
  end
129
124
 
130
125
  def check_dir(exclude=[])
131
- Dir["**/*.rb"].select{|rb| not exclude.include?(rb.split('/')[0])}.each do |i|
126
+ Dir['**/*.rb'].select{|rb| not exclude.include?(rb.split('/')[0])}.each do |i|
132
127
  gather_dependencies(i)
133
128
  end
134
129
  end
135
130
  end
136
-
File without changes
data/assets/ruboto.yml CHANGED
@@ -13,11 +13,11 @@
13
13
  #
14
14
  # ruby_version
15
15
  #
16
- # Sets the jruby.compat.version property of JRuby
17
- # If you include the jruby jars, this is used to
16
+ # Sets the jruby.compat.version property for JRuby 1.7.x.
17
+ # If you include the jruby jars, this is also used to
18
18
  # trim away unused versions of the stdlib.
19
19
  #
20
- #ruby_version: 1.9
20
+ # ruby_version: 1.9
21
21
 
22
22
  ###################################
23
23
  #
@@ -44,19 +44,29 @@
44
44
  # Note: If you specify included_stdlibs above,
45
45
  # this information will be ingnored.
46
46
  #
47
- #excluded_stdlibs:
48
- #- ant
49
- #- cgi
50
- #- drb
51
- #- erb
52
- #- gauntlet_rdoc
53
- #- minitest
54
- #- profiler
55
- #- rake
56
- #- rdoc
57
- #- shell
58
- #- test
59
- #- webrick
60
- #- win32
61
- #- Win32API
47
+ # excluded_stdlibs:
48
+ # - ant
49
+ # - cgi
50
+ # - drb
51
+ # - erb
52
+ # - gauntlet_rdoc
53
+ # - minitest
54
+ # - profiler
55
+ # - rake
56
+ # - rdoc
57
+ # - shell
58
+ # - test
59
+ # - webrick
60
+ # - win32
61
+ # - Win32API
62
62
 
63
+ ###################################
64
+ #
65
+ # multi_dex
66
+ #
67
+ # Switch on use of multiple classes.dex files when building.
68
+ # This will allow you to have more than 65535 methods in your app.
69
+ # WARNING: This disables pre-dex during build which will increase your
70
+ # incremental build time substantially.
71
+ #
72
+ # multi_dex: true