ruboto-core 0.1.0 → 0.2.1
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.
- data/Gemfile.lock +2 -1
- data/README.md +1 -1
- data/Rakefile +2 -2
- data/assets/Rakefile +181 -60
- data/assets/assets/scripts/ruboto.rb +249 -133
- data/assets/samples/sample_activity.rb +4 -4
- data/assets/src/InheritingActivity.java +8 -6
- data/assets/src/InheritingBroadcastReceiver.java +5 -5
- data/assets/src/InheritingClass.java +3 -3
- data/assets/src/InheritingService.java +3 -4
- data/assets/src/RubotoActivity.java +30 -15
- data/assets/src/RubotoBroadcastReceiver.java +6 -13
- data/assets/src/RubotoService.java +4 -3
- data/assets/src/org/ruboto/Script.java +117 -58
- data/assets/src/org/ruboto/test/ActivityTest.java +23 -17
- data/assets/src/org/ruboto/test/InstrumentationTestRunner.java +10 -6
- data/lib/java_class_gen/InheritingClass.java.erb +0 -1
- data/lib/java_class_gen/android_api.xml +1 -1
- data/lib/ruboto/commands/base.rb +227 -255
- data/lib/ruboto/util/build.rb +33 -22
- data/lib/ruboto/util/update.rb +210 -40
- data/lib/ruboto/util/verify.rb +4 -0
- data/lib/ruboto/util/xml_element.rb +28 -18
- data/test/activity/image_button.rb +21 -0
- data/test/activity/image_button_and_button.rb +31 -0
- data/test/activity/image_button_and_button_test.rb +27 -0
- data/test/activity/image_button_test.rb +21 -0
- data/test/app_test_methods.rb +54 -0
- data/test/rake_test.rb +53 -0
- data/test/ruboto_gen_test.rb +36 -0
- data/test/ruboto_update_test.rb +61 -0
- data/test/service_test.rb +49 -0
- data/test/test_helper.rb +113 -3
- metadata +44 -46
- data/test/app_test.rb +0 -44
data/lib/ruboto/util/build.rb
CHANGED
@@ -27,20 +27,20 @@ module Ruboto
|
|
27
27
|
# Aborts if the class is not found or if it is not available for
|
28
28
|
# all api levels
|
29
29
|
#
|
30
|
-
def get_class_or_interface(klass, force=
|
30
|
+
def get_class_or_interface(klass, force=nil)
|
31
31
|
element = verify_api.find_class_or_interface(klass, "either")
|
32
32
|
|
33
33
|
abort "ERROR: #{klass} not found" unless element
|
34
34
|
|
35
|
-
unless force
|
36
|
-
abort "#{klass} not available in minSdkVersion, added in #{element.attribute('api_added')}; use --force to create it" if
|
37
|
-
|
38
|
-
abort "#{klass} deprecated for targetSdkVersion, deprecatrd in #{element.attribute('deprecated')}; use --force to create it" if
|
39
|
-
|
35
|
+
unless force == "include"
|
36
|
+
abort "#{klass} not available in minSdkVersion, added in #{element.attribute('api_added')}; use '--force include' to create it" if
|
37
|
+
element.attribute('api_added') and element.attribute('api_added').to_i > verify_min_sdk.to_i
|
38
|
+
abort "#{klass} deprecated for targetSdkVersion, deprecatrd in #{element.attribute('deprecated')}; use '--force include' to create it" if
|
39
|
+
element.attribute('deprecated') and element.attribute('deprecated').to_i <= verify_target_sdk.to_i
|
40
40
|
end
|
41
41
|
|
42
42
|
abort "#{klass} removed for targetSdkVersion, removed in #{element.attribute('api_removed')}" if
|
43
|
-
|
43
|
+
element.attribute('api_removed') and element.attribute('api_removed').to_i <= verify_target_sdk.to_i
|
44
44
|
|
45
45
|
element
|
46
46
|
end
|
@@ -48,7 +48,7 @@ module Ruboto
|
|
48
48
|
#
|
49
49
|
# check_methods: Checks the methods to see if they are available for all api levels
|
50
50
|
#
|
51
|
-
def check_methods(methods, force=
|
51
|
+
def check_methods(methods, force=nil)
|
52
52
|
min_api = verify_min_sdk.to_i
|
53
53
|
target_api = verify_target_sdk.to_i
|
54
54
|
|
@@ -67,22 +67,29 @@ module Ruboto
|
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
|
+
abort = false
|
70
71
|
new_methods = methods
|
71
|
-
unless force
|
72
|
+
unless force == "include"
|
72
73
|
# Inform and remove methods changed inside the scope of the sdk versions
|
73
74
|
new_methods = methods.select do |i|
|
74
|
-
if i.attribute('api_added') and i.attribute('api_added').to_i > min_api
|
75
|
-
|
75
|
+
if i.attribute('api_added') and i.attribute('api_added').to_i > min_api and force == "exclude"
|
76
|
+
false
|
77
|
+
elsif i.attribute('api_added') and i.attribute('api_added').to_i > min_api
|
78
|
+
puts "Can't create #{i.method_signature} -- added in #{i.attribute('api_added')} -- use method_exclude or force exclude"
|
79
|
+
abort = true
|
80
|
+
false
|
81
|
+
elsif i.attribute('deprecated') and i.attribute('deprecated').to_i <= target_api and force == "exclude"
|
76
82
|
false
|
77
83
|
elsif i.attribute('deprecated') and i.attribute('deprecated').to_i <= target_api
|
78
|
-
puts "Can't create #{i.method_signature} -- deprecated in #{i.attribute('deprecated')} --
|
84
|
+
puts "Can't create #{i.method_signature} -- deprecated in #{i.attribute('deprecated')} -- use method_exclude or force exclude"
|
85
|
+
abort = true
|
79
86
|
false
|
80
87
|
else
|
81
88
|
true
|
82
89
|
end
|
83
90
|
end
|
84
91
|
|
85
|
-
abort("Aborting!") if
|
92
|
+
abort("Aborting!") if abort
|
86
93
|
end
|
87
94
|
|
88
95
|
new_methods
|
@@ -92,7 +99,7 @@ module Ruboto
|
|
92
99
|
# generate_subclass_or_interface: Creates a subclass or interface based on the specifications.
|
93
100
|
#
|
94
101
|
def generate_subclass_or_interface(params)
|
95
|
-
defaults = {:template => "InheritingClass", :method_base => "all", :method_include => "", :method_exclude => "", :force =>
|
102
|
+
defaults = {:template => "InheritingClass", :method_base => "all", :method_include => "", :method_exclude => "", :force => nil, :implements => ""}
|
96
103
|
params = defaults.merge(params)
|
97
104
|
params[:package] = verify_package unless params[:package]
|
98
105
|
|
@@ -125,10 +132,10 @@ module Ruboto
|
|
125
132
|
# on the API specifications.
|
126
133
|
#
|
127
134
|
def generate_core_classes(params)
|
128
|
-
%w(android.view.View.OnClickListener android.widget.AdapterView.OnItemClickListener).each do |i|
|
135
|
+
%w(android.view.View.OnClickListener android.widget.AdapterView.OnItemClickListener android.widget.AdapterView.OnItemSelectedListener).each do |i|
|
129
136
|
name = i.split(".")[-1]
|
130
137
|
if(params[:class] == name or params[:class] == "all")
|
131
|
-
generate_subclass_or_interface({:package => "org.ruboto.callbacks", :class => i, :name => "Ruboto#{name}"})
|
138
|
+
generate_subclass_or_interface({:package => "org.ruboto.callbacks", :class => i, :name => "Ruboto#{name}", :force => params[:force]})
|
132
139
|
end
|
133
140
|
end
|
134
141
|
|
@@ -139,8 +146,7 @@ module Ruboto
|
|
139
146
|
%w(android.app.Activity android.app.Service android.content.BroadcastReceiver android.view.View).each do |i|
|
140
147
|
name = i.split(".")[-1]
|
141
148
|
if(params[:class] == name or params[:class] == "all")
|
142
|
-
generate_subclass_or_interface(
|
143
|
-
hash.merge({:template => name == "View" ? "InheritingClass" : "Ruboto#{name}", :class => i, :name => "Ruboto#{name}"}))
|
149
|
+
generate_subclass_or_interface(hash.merge({:template => name == "View" ? "InheritingClass" : "Ruboto#{name}", :class => i, :name => "Ruboto#{name}"}))
|
144
150
|
end
|
145
151
|
end
|
146
152
|
|
@@ -160,24 +166,29 @@ module Ruboto
|
|
160
166
|
#
|
161
167
|
|
162
168
|
def generate_inheriting_file(klass, name, package, script_name, dest='.', filename = name)
|
163
|
-
file = File.join(dest, "src/#{package.gsub('.', '/')}", "#{filename}.java")
|
169
|
+
file = File.expand_path File.join(dest, "src/#{package.gsub('.', '/')}", "#{filename}.java")
|
164
170
|
text = File.read(File.join(Ruboto::ASSETS, "src/Inheriting#{klass}.java"))
|
165
171
|
File.open(file, 'w') do |f|
|
166
172
|
f << text.gsub("THE_PACKAGE", package).gsub("Inheriting#{klass}", name).gsub("start.rb", script_name)
|
167
173
|
end
|
174
|
+
puts "Added file #{file}."
|
168
175
|
|
169
176
|
sample_source = File.read(File.join(Ruboto::ASSETS, "samples/sample_#{underscore klass}.rb")).gsub("THE_PACKAGE", package).gsub("Sample#{klass}", name).gsub("start.rb", script_name)
|
170
177
|
FileUtils.mkdir_p File.join(dest, 'assets/scripts')
|
171
|
-
|
178
|
+
script_file = File.expand_path("assets/scripts/#{script_name}", dest)
|
179
|
+
File.open script_file, "a" do |f|
|
172
180
|
f << sample_source
|
173
181
|
end
|
182
|
+
puts "Added file #{script_file}."
|
174
183
|
|
175
184
|
sample_test_source = File.read(File.join(Ruboto::ASSETS, "samples/sample_#{underscore klass}_test.rb")).gsub("THE_PACKAGE", package).gsub("Sample#{klass}", name)
|
176
185
|
FileUtils.mkdir_p File.join(dest, 'test/assets/scripts')
|
177
|
-
|
186
|
+
test_file = File.expand_path("test/assets/scripts/#{script_name.chomp('.rb')}_test.rb", dest)
|
187
|
+
File.open test_file, "a" do |f|
|
178
188
|
f << sample_test_source
|
179
189
|
end
|
190
|
+
puts "Added file #{test_file}."
|
180
191
|
end
|
181
192
|
end
|
182
193
|
end
|
183
|
-
end
|
194
|
+
end
|
data/lib/ruboto/util/update.rb
CHANGED
@@ -1,23 +1,99 @@
|
|
1
1
|
module Ruboto
|
2
2
|
module Util
|
3
3
|
module Update
|
4
|
+
include Build
|
4
5
|
###########################################################################
|
5
6
|
#
|
6
7
|
# Updating components
|
7
8
|
#
|
9
|
+
def update_test(force = nil)
|
10
|
+
root = Dir.getwd
|
11
|
+
if force || !File.exists?("#{root}/test")
|
12
|
+
name = verify_strings.root.elements['string'].text.gsub(' ', '')
|
13
|
+
puts "\nGenerating Android test project #{name} in #{root}..."
|
14
|
+
system "android create test-project -m #{root} -n #{name}Test -p #{root}/test"
|
15
|
+
FileUtils.rm_rf File.join(root, 'test', 'src', verify_package.split('.'))
|
16
|
+
puts "Done"
|
17
|
+
else
|
18
|
+
puts "Test project already exists. Use --force to overwrite."
|
19
|
+
end
|
20
|
+
|
21
|
+
Dir.chdir File.join(root, 'test') do
|
22
|
+
test_manifest = REXML::Document.new(File.read('AndroidManifest.xml')).root
|
23
|
+
test_manifest.elements['instrumentation'].attributes['android:name'] = 'org.ruboto.test.InstrumentationTestRunner'
|
24
|
+
File.open("AndroidManifest.xml", 'w'){|f| test_manifest.document.write(f, 4)}
|
25
|
+
instrumentation_property = "test.runner=org.ruboto.test.InstrumentationTestRunner\n"
|
26
|
+
prop_lines = File.readlines('build.properties')
|
27
|
+
File.open('build.properties', 'a'){|f| f << instrumentation_property} unless prop_lines.include?(instrumentation_property)
|
28
|
+
ant_setup_line = /^(\s*<setup\s*\/>)/
|
29
|
+
run_tests_override = <<-EOF
|
30
|
+
<!-- BEGIN added by ruboto-core -->
|
31
|
+
<macrodef name="run-tests-helper">
|
32
|
+
<attribute name="emma.enabled" default="false"/>
|
33
|
+
<element name="extra-instrument-args" optional="yes"/>
|
34
|
+
<sequential>
|
35
|
+
<echo>Running tests with failure detection...</echo>
|
36
|
+
<exec executable="${adb}" failonerror="true" outputproperty="tests.output">
|
37
|
+
<arg line="${adb.device.arg}"/>
|
38
|
+
<arg value="shell"/>
|
39
|
+
<arg value="am"/>
|
40
|
+
<arg value="instrument"/>
|
41
|
+
<arg value="-w"/>
|
42
|
+
<arg value="-e"/>
|
43
|
+
<arg value="coverage"/>
|
44
|
+
<arg value="@{emma.enabled}"/>
|
45
|
+
<extra-instrument-args/>
|
46
|
+
<arg value="${manifest.package}/${test.runner}"/>
|
47
|
+
</exec>
|
48
|
+
<echo message="${tests.output}"/>
|
49
|
+
<fail message="Tests failed!!!">
|
50
|
+
<condition>
|
51
|
+
<or>
|
52
|
+
<contains string="${tests.output}" substring="INSTRUMENTATION_RESULT"/>
|
53
|
+
<contains string="${tests.output}" substring="INSTRUMENTATION_FAILED"/>
|
54
|
+
<contains string="${tests.output}" substring="FAILURES"/>
|
55
|
+
<not>
|
56
|
+
<matches string="${tests.output}" pattern="OK \\(\\d+ tests\\)" multiline="true"/>
|
57
|
+
</not>
|
58
|
+
</or>
|
59
|
+
</condition>
|
60
|
+
</fail>
|
61
|
+
</sequential>
|
62
|
+
</macrodef>
|
63
|
+
|
64
|
+
<target name="run-tests-quick" description="Runs tests with previously installed packages">
|
65
|
+
<run-tests-helper />
|
66
|
+
</target>
|
67
|
+
<!-- END added by ruboto-core -->
|
8
68
|
|
9
|
-
|
69
|
+
EOF
|
70
|
+
ant_script = File.read('build.xml')
|
71
|
+
# TODO(uwe): Old patches without dlimiter. Remove when we stop supporting upgrading from ruboto-core 0.2.0 and older.
|
72
|
+
ant_script.gsub!(/\s*<macrodef name="run-tests-helper">.*?<\/macrodef>\s*/m, '')
|
73
|
+
ant_script.gsub!(/\s*<target name="run-tests-quick".*?<\/target>\s*/m, '')
|
74
|
+
# TODO end
|
75
|
+
ant_script.gsub!(/\s*<!-- BEGIN added by ruboto-core -->.*?<!-- END added by ruboto-core -->\s*/m, '')
|
76
|
+
ant_script.gsub!(ant_setup_line, "\\1\n\n#{run_tests_override}")
|
77
|
+
File.open('build.xml', 'w'){|f| f << ant_script}
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def update_jruby(force=nil, with_psych=nil)
|
10
82
|
jruby_core = Dir.glob("libs/jruby-core-*.jar")[0]
|
11
83
|
jruby_stdlib = Dir.glob("libs/jruby-stdlib-*.jar")[0]
|
12
|
-
new_jruby_version = JRubyJars::
|
84
|
+
new_jruby_version = JRubyJars::VERSION
|
13
85
|
|
14
86
|
unless force
|
15
|
-
|
16
|
-
|
87
|
+
if !jruby_core || !jruby_stdlib
|
88
|
+
puts "Cannot find existing jruby jars in libs. Make sure you're in the root directory of your app."
|
89
|
+
return false
|
90
|
+
end
|
17
91
|
|
18
92
|
current_jruby_version = jruby_core ? jruby_core[16..-5] : "None"
|
19
|
-
|
20
|
-
|
93
|
+
if current_jruby_version == new_jruby_version
|
94
|
+
puts "Both jruby versions are #{new_jruby_version}. Nothing to update. Make sure you 'gem update jruby-jars' if there is a new version."
|
95
|
+
return false
|
96
|
+
end
|
21
97
|
|
22
98
|
puts "Current jruby version: #{current_jruby_version}"
|
23
99
|
puts "New jruby version: #{new_jruby_version}"
|
@@ -29,9 +105,63 @@ module Ruboto
|
|
29
105
|
log_action("Copying #{JRubyJars::core_jar_path} to libs") {copier.copy_from_absolute_path JRubyJars::core_jar_path, "libs"}
|
30
106
|
log_action("Copying #{JRubyJars::stdlib_jar_path} to libs") {copier.copy_from_absolute_path JRubyJars::stdlib_jar_path, "libs"}
|
31
107
|
|
32
|
-
reconfigure_jruby_libs
|
108
|
+
reconfigure_jruby_libs(new_jruby_version, with_psych)
|
33
109
|
|
34
110
|
puts "JRuby version is now: #{new_jruby_version}"
|
111
|
+
true
|
112
|
+
end
|
113
|
+
|
114
|
+
def update_assets(force = nil)
|
115
|
+
puts "\nCopying files:"
|
116
|
+
copier = Ruboto::Util::AssetCopier.new Ruboto::ASSETS, '.'
|
117
|
+
|
118
|
+
%w{Rakefile .gitignore assets res test}.each do |f|
|
119
|
+
log_action(f) {copier.copy f}
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
def update_classes(force = nil)
|
124
|
+
copier = Ruboto::Util::AssetCopier.new Ruboto::ASSETS, '.'
|
125
|
+
log_action("Ruboto java classes"){copier.copy "src/org/ruboto/*.java", "src/org/ruboto"}
|
126
|
+
log_action("Ruboto java test classes"){copier.copy "src/org/ruboto/test/*.java", "test/src/org/ruboto/test"}
|
127
|
+
end
|
128
|
+
|
129
|
+
def update_manifest(min_sdk, target, force = false)
|
130
|
+
log_action("\nAdding activities (RubotoActivity and RubotoDialog) and SDK versions to the manifest") do
|
131
|
+
if sdk_element = verify_manifest.elements['uses-sdk']
|
132
|
+
min_sdk ||= sdk_element.attributes["android:minSdkVersion"]
|
133
|
+
target ||= sdk_element.attributes["android:targetSdkVersion"]
|
134
|
+
end
|
135
|
+
if min_sdk.to_i >= 11
|
136
|
+
verify_manifest.elements['application'].attributes['android:hardwareAccelerated'] ||= 'true'
|
137
|
+
end
|
138
|
+
app_element = verify_manifest.elements['application']
|
139
|
+
if app_element.elements["activity[@android:name='org.ruboto.RubotoActivity']"]
|
140
|
+
puts 'found activity tag'
|
141
|
+
else
|
142
|
+
app_element.add_element 'activity', {"android:name" => "org.ruboto.RubotoActivity"}
|
143
|
+
end
|
144
|
+
if app_element.elements["activity[@android:name='org.ruboto.RubotoDialog']"]
|
145
|
+
puts 'found dialog tag'
|
146
|
+
else
|
147
|
+
app_element.add_element 'activity', {"android:name" => "org.ruboto.RubotoDialog", "android:theme" => "@android:style/Theme.Dialog"}
|
148
|
+
end
|
149
|
+
if sdk_element
|
150
|
+
sdk_element.attributes["android:minSdkVersion"] = min_sdk
|
151
|
+
sdk_element.attributes["android:targetSdkVersion"] = target
|
152
|
+
else
|
153
|
+
verify_manifest.add_element 'uses-sdk', {"android:minSdkVersion" => min_sdk, "android:targetSdkVersion" => target}
|
154
|
+
end
|
155
|
+
# # <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
156
|
+
# unless sdcard_permission_element = verify_manifest.elements["uses-permission[@android:name='android.permission.WRITE_EXTERNAL_STORAGE']"]
|
157
|
+
# verify_manifest.add_element 'uses-permission', {"android:name" => 'android.permission.WRITE_EXTERNAL_STORAGE'}
|
158
|
+
# end
|
159
|
+
save_manifest
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
def update_core_classes(force = nil)
|
164
|
+
generate_core_classes(:class => "all", :method_base => "on", :method_include => "", :method_exclude => "", :force => force, :implements => "")
|
35
165
|
end
|
36
166
|
|
37
167
|
def update_ruboto(force=nil)
|
@@ -47,13 +177,16 @@ module Ruboto
|
|
47
177
|
puts "New version: #{from_text[/\$RUBOTO_VERSION = (\d+)/, 1]}"
|
48
178
|
puts "Old version: #{to_text ? to_text[/\$RUBOTO_VERSION = (\d+)/, 1] : 'none'}"
|
49
179
|
|
50
|
-
|
51
|
-
|
180
|
+
if from_text[/\$RUBOTO_VERSION = (\d+)/, 1] == to_text[/\$RUBOTO_VERSION = (\d+)/, 1]
|
181
|
+
puts "The ruboto.rb version has not changed. Use --force to force update."
|
182
|
+
return false
|
183
|
+
end
|
52
184
|
end
|
53
185
|
|
54
|
-
log_action("Copying ruboto.rb
|
55
|
-
File.open(to, 'w') {|f| f << from_text
|
186
|
+
log_action("Copying ruboto.rb") do
|
187
|
+
File.open(to, 'w') {|f| f << from_text}
|
56
188
|
end
|
189
|
+
true
|
57
190
|
end
|
58
191
|
|
59
192
|
#
|
@@ -61,42 +194,79 @@ module Ruboto
|
|
61
194
|
# - removes unneeded code from jruby-core
|
62
195
|
# - moves ruby stdlib to the root of the ruby-stdlib jar
|
63
196
|
#
|
64
|
-
|
65
|
-
def reconfigure_jruby_libs
|
197
|
+
def reconfigure_jruby_libs(jruby_core_version, with_psych=nil)
|
66
198
|
jruby_core = JRubyJars::core_jar_path.split('/')[-1]
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
199
|
+
Dir.chdir 'libs' do
|
200
|
+
log_action("Removing unneeded classes from #{jruby_core}") do
|
201
|
+
Dir.mkdir "tmp"
|
202
|
+
Dir.chdir "tmp" do
|
203
|
+
FileUtils.move "../#{jruby_core}", "."
|
204
|
+
`jar -xf #{jruby_core}`
|
205
|
+
File.delete jruby_core
|
206
|
+
invalid_libs = ['cext', 'jni', 'org/jruby/ant', 'org/jruby/compiler/ir', 'org/jruby/demo', 'org/jruby/embed/bsf',
|
207
|
+
'org/jruby/embed/jsr223', 'org/jruby/ext/ffi','org/jruby/javasupport/bsf'
|
208
|
+
]
|
209
|
+
if jruby_core_version == '1.6.2'
|
210
|
+
puts 'Retaining FFI for JRuby 1.6.2'
|
211
|
+
invalid_libs.delete('org/jruby/ext/ffi')
|
212
|
+
end
|
213
|
+
invalid_libs.each {|i| FileUtils.remove_dir i, true}
|
214
|
+
`jar -cf ../#{jruby_core} .`
|
215
|
+
end
|
216
|
+
FileUtils.remove_dir "tmp", true
|
79
217
|
end
|
80
218
|
|
81
219
|
jruby_stdlib = JRubyJars::stdlib_jar_path.split('/')[-1]
|
82
220
|
log_action("Reformatting #{jruby_stdlib}") do
|
83
|
-
Dir.mkdir "
|
84
|
-
Dir.chdir "
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
221
|
+
Dir.mkdir "tmp"
|
222
|
+
Dir.chdir "tmp" do
|
223
|
+
FileUtils.move "../#{jruby_stdlib}", "."
|
224
|
+
`jar -xf #{jruby_stdlib}`
|
225
|
+
File.delete jruby_stdlib
|
226
|
+
|
227
|
+
FileUtils.move "META-INF/jruby.home/lib/ruby/1.8", ".."
|
228
|
+
Dir["META-INF/jruby.home/lib/ruby/site_ruby/1.8/*"].each do |f|
|
229
|
+
next if File.basename(f) =~ /^..?$/
|
230
|
+
FileUtils.move f, "../1.8/" + File.basename(f)
|
231
|
+
end
|
232
|
+
Dir["META-INF/jruby.home/lib/ruby/site_ruby/shared/*"].each do |f|
|
233
|
+
next if File.basename(f) =~ /^..?$/
|
234
|
+
FileUtils.move f, "../1.8/" + File.basename(f)
|
235
|
+
end
|
236
|
+
end
|
237
|
+
Dir.chdir "1.8" do
|
238
|
+
`jar -cf ../#{jruby_stdlib} .`
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
psych_jar = "psych.jar"
|
243
|
+
psych_already_present = File.exists? psych_jar
|
244
|
+
FileUtils.rm_f psych_jar
|
245
|
+
|
246
|
+
if with_psych || with_psych.nil? && psych_already_present
|
247
|
+
log_action("Adding psych #{File.basename psych_jar}") do
|
248
|
+
psych_dir = 'psych'
|
249
|
+
FileUtils.move "tmp/META-INF/jruby.home/lib/ruby/1.9", psych_dir
|
250
|
+
Dir.chdir psych_dir do
|
251
|
+
psych_files = Dir["**/*"]
|
252
|
+
puts if psych_files.any?
|
253
|
+
psych_files.each do |f|
|
254
|
+
next if File.basename(f) =~ /^..?$/
|
255
|
+
if File.exists? "../1.8/#{f}"
|
256
|
+
puts "Removing duplicate #{f}"
|
257
|
+
FileUtils.rm_f f
|
258
|
+
end
|
259
|
+
end
|
260
|
+
`jar -cf ../#{psych_jar} .`
|
261
|
+
end
|
262
|
+
FileUtils.remove_dir psych_dir, true
|
92
263
|
end
|
93
|
-
Dir.chdir "../1.8"
|
94
|
-
FileUtils.remove_dir "../tmp", true
|
95
|
-
`jar -cf ../#{jruby_stdlib} .`
|
96
|
-
Dir.chdir "../.."
|
97
|
-
FileUtils.remove_dir "libs/1.8", true
|
98
264
|
end
|
265
|
+
|
266
|
+
FileUtils.remove_dir "tmp", true
|
267
|
+
FileUtils.remove_dir "1.8", true
|
99
268
|
end
|
100
269
|
end
|
101
270
|
end
|
102
|
-
end
|
271
|
+
end
|
272
|
+
end
|
data/lib/ruboto/util/verify.rb
CHANGED
@@ -14,6 +14,10 @@ module Ruboto
|
|
14
14
|
@manifest ||= REXML::Document.new(File.read('AndroidManifest.xml')).root
|
15
15
|
end
|
16
16
|
|
17
|
+
def save_manifest
|
18
|
+
File.open("AndroidManifest.xml", 'w') {|f| verify_manifest.document.write(f, 4)}
|
19
|
+
end
|
20
|
+
|
17
21
|
def verify_package
|
18
22
|
verify_manifest
|
19
23
|
@package ||= @manifest.attribute('package').value
|
@@ -158,35 +158,45 @@ module Ruboto
|
|
158
158
|
args = ""
|
159
159
|
if params.size > 3
|
160
160
|
args = ", args"
|
161
|
-
rv << "
|
161
|
+
rv << "Object[] args = {" + params.map{|i| i[0]}.join(", ") + "};"
|
162
162
|
elsif params.size > 0
|
163
|
-
args = ", " + params.map{|i|
|
163
|
+
args = ", " + params.map{|i| i[0]}.join(", ")
|
164
164
|
end
|
165
165
|
|
166
166
|
return_cast = ""
|
167
|
-
if attribute("return") and (attribute("return").include?(".") or attribute("return") == "int[]")
|
168
|
-
return_cast = "return (#{attribute("return")})"
|
169
|
-
elsif attribute("return") and attribute("return") == "int"
|
170
|
-
return_cast = "return (Integer)"
|
171
|
-
elsif attribute("return") and attribute("return") != "void"
|
172
|
-
return_cast = "return (#{attribute("return").capitalize})"
|
173
|
-
end
|
174
|
-
return_cast = return_cast.gsub("<", "<").gsub(">", ">")
|
175
|
-
|
176
167
|
convert_return = ""
|
177
|
-
if attribute("return")
|
178
|
-
|
168
|
+
if attribute("return") && attribute("return") != "void"
|
169
|
+
if (attribute("return").include?(".") or attribute("return") == "int[]")
|
170
|
+
return_class = attribute("return")
|
171
|
+
elsif attribute("return") == 'int'
|
172
|
+
return_class = 'Integer'
|
173
|
+
else
|
174
|
+
return_class = attribute("return").capitalize
|
175
|
+
end
|
176
|
+
return_cast = "return (#{return_class.gsub("<", "<").gsub(">", ">")}) " if return_class
|
177
|
+
convert_return = ", #{return_class}.class"
|
179
178
|
end
|
180
179
|
|
181
|
-
|
180
|
+
if return_class == 'Integer'
|
181
|
+
# TODO(uwe): This is a fix for JRUBY-5937 Remove when the issue is fixed.
|
182
|
+
rv << "#{return_cast}((Number)getRuby().callMethod(callbackProcs[#{constant_string}], \"call\" #{args}#{convert_return})).intValue();"
|
183
|
+
# TODO end
|
184
|
+
else
|
185
|
+
rv << "#{return_cast}getRuby().callMethod(callbackProcs[#{constant_string}], \"call\" #{args}#{convert_return});"
|
186
|
+
end
|
182
187
|
rv
|
183
188
|
end
|
184
189
|
|
185
190
|
def method_definition
|
186
|
-
method_call(
|
187
|
-
|
188
|
-
|
189
|
-
|
191
|
+
method_call(
|
192
|
+
(attribute("return") ? attribute("return") : "void"),
|
193
|
+
attribute("name"), parameters,
|
194
|
+
if_else(
|
195
|
+
"callbackProcs[#{constant_string}] != null",
|
196
|
+
[super_string] + try_catch(ruby_call, ["re.printStackTrace();", default_return]),
|
197
|
+
[super_return]
|
198
|
+
)
|
199
|
+
).indent.join("\n")
|
190
200
|
end
|
191
201
|
|
192
202
|
def constructor_definition(class_name)
|