hitimes 1.1.1-x86-mingw32 → 1.2.2-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +10 -0
- data/CONTRIBUTING.md +45 -0
- data/{HISTORY → HISTORY.md} +42 -18
- data/LICENSE +11 -8
- data/Manifest.txt +45 -0
- data/README.md +163 -0
- data/Rakefile +23 -62
- data/ext/hitimes/c/extconf.rb +24 -0
- data/ext/hitimes/{hitimes_ext.c → c/hitimes.c} +1 -1
- data/ext/hitimes/{hitimes_instant_clock_gettime.c → c/hitimes_instant_clock_gettime.c} +0 -0
- data/ext/hitimes/c/hitimes_instant_osx.c +45 -0
- data/ext/hitimes/{hitimes_instant_windows.c → c/hitimes_instant_windows.c} +0 -0
- data/ext/hitimes/{hitimes_interval.c → c/hitimes_interval.c} +15 -7
- data/ext/hitimes/{hitimes_interval.h → c/hitimes_interval.h} +5 -5
- data/ext/hitimes/{hitimes_stats.c → c/hitimes_stats.c} +0 -0
- data/ext/hitimes/{hitimes_stats.h → c/hitimes_stats.h} +0 -0
- data/ext/hitimes/java/src/hitimes/Hitimes.java +54 -0
- data/ext/hitimes/java/src/hitimes/HitimesInterval.java +181 -0
- data/ext/hitimes/java/src/hitimes/HitimesService.java +16 -0
- data/ext/hitimes/java/src/hitimes/HitimesStats.java +112 -0
- data/lib/hitimes.rb +15 -5
- data/lib/hitimes/1.9/hitimes.so +0 -0
- data/lib/hitimes/2.0/hitimes.so +0 -0
- data/lib/hitimes/2.1/hitimes.so +0 -0
- data/lib/hitimes/version.rb +1 -50
- data/spec/hitimes_spec.rb +14 -0
- data/spec/interval_spec.rb +40 -37
- data/spec/metric_spec.rb +8 -10
- data/spec/mutex_stats_spec.rb +10 -8
- data/spec/paths_spec.rb +3 -5
- data/spec/spec_helper.rb +9 -3
- data/spec/stats_spec.rb +28 -30
- data/spec/timed_metric_spec.rb +42 -42
- data/spec/timed_value_metric_spec.rb +54 -55
- data/spec/value_metric_spec.rb +26 -28
- data/spec/version_spec.rb +4 -30
- data/tasks/default.rake +242 -0
- data/tasks/extension.rake +31 -101
- data/tasks/this.rb +206 -0
- metadata +158 -145
- data/README +0 -135
- data/ext/hitimes/extconf.rb +0 -17
- data/ext/hitimes/hitimes_instant_osx.c +0 -16
- data/gemspec.rb +0 -64
- data/lib/hitimes/1.8/hitimes_ext.so +0 -0
- data/lib/hitimes/1.9/hitimes_ext.so +0 -0
- data/tasks/announce.rake +0 -42
- data/tasks/config.rb +0 -109
- data/tasks/distribution.rake +0 -93
- data/tasks/documentation.rake +0 -32
- data/tasks/rspec.rake +0 -33
- data/tasks/rubyforge.rake +0 -55
- data/tasks/utils.rb +0 -80
data/spec/value_metric_spec.rb
CHANGED
@@ -1,6 +1,4 @@
|
|
1
|
-
require
|
2
|
-
|
3
|
-
require 'hitimes/value_metric'
|
1
|
+
require 'spec_helper'
|
4
2
|
|
5
3
|
describe Hitimes::ValueMetric do
|
6
4
|
before( :each ) do
|
@@ -9,50 +7,50 @@ describe Hitimes::ValueMetric do
|
|
9
7
|
end
|
10
8
|
|
11
9
|
it 'has a name' do
|
12
|
-
@metric.name.
|
10
|
+
@metric.name.must_equal "testing"
|
13
11
|
end
|
14
12
|
|
15
13
|
it "has associated data from initialization" do
|
16
14
|
m = Hitimes::ValueMetric.new( "more-data", 'foo' => 'bar', 'this' => 'that' )
|
17
|
-
m.additional_data['foo'].
|
18
|
-
m.additional_data['this'].
|
15
|
+
m.additional_data['foo'].must_equal 'bar'
|
16
|
+
m.additional_data['this'].must_equal 'that'
|
19
17
|
|
20
18
|
m = Hitimes::ValueMetric.new( "more-data", { 'foo' => 'bar', 'this' => 'that' } )
|
21
|
-
m.additional_data['foo'].
|
22
|
-
m.additional_data['this'].
|
19
|
+
m.additional_data['foo'].must_equal 'bar'
|
20
|
+
m.additional_data['this'].must_equal 'that'
|
23
21
|
end
|
24
22
|
|
25
23
|
it "calculates the mean of the measurements" do
|
26
|
-
@metric.mean.
|
24
|
+
@metric.mean.must_equal 4.5
|
27
25
|
end
|
28
26
|
|
29
27
|
it "calculates the stddev of the measurements" do
|
30
|
-
@metric.stddev.
|
28
|
+
@metric.stddev.must_be :>, 0.0
|
31
29
|
end
|
32
30
|
|
33
31
|
it "returns 0.0 for stddev if there is no data" do
|
34
32
|
m = Hitimes::ValueMetric.new('0-data')
|
35
|
-
m.stddev.
|
33
|
+
m.stddev.must_equal 0.0
|
36
34
|
end
|
37
35
|
|
38
36
|
it "keeps track of the sum of data" do
|
39
|
-
@metric.sum.
|
37
|
+
@metric.sum.must_equal 45.0
|
40
38
|
end
|
41
39
|
|
42
40
|
it "keeps track of the sum of squars of data" do
|
43
|
-
@metric.sumsq.
|
41
|
+
@metric.sumsq.must_equal 285.0
|
44
42
|
end
|
45
43
|
|
46
44
|
it "retuns 0.0 for mean if there is no data" do
|
47
|
-
Hitimes::ValueMetric.new('0-data').mean.
|
45
|
+
Hitimes::ValueMetric.new('0-data').mean.must_equal 0.0
|
48
46
|
end
|
49
47
|
|
50
48
|
it "keeps track of the min value" do
|
51
|
-
@metric.min.
|
49
|
+
@metric.min.must_equal 0
|
52
50
|
end
|
53
51
|
|
54
52
|
it "keeps track of the max value" do
|
55
|
-
@metric.max.
|
53
|
+
@metric.max.must_equal 9
|
56
54
|
end
|
57
55
|
|
58
56
|
it "keeps track of the first start time of all the measurements" do
|
@@ -60,11 +58,11 @@ describe Hitimes::ValueMetric do
|
|
60
58
|
f1 = Time.now.gmtime.to_f * 1_000_000
|
61
59
|
10.times{ |x| m.measure( x ); sleep 0.1 }
|
62
60
|
f2 = Time.now.gmtime.to_f * 1_000_000
|
63
|
-
m.sampling_start_time.
|
64
|
-
m.sampling_start_time.
|
61
|
+
m.sampling_start_time.must_be :>=, f1
|
62
|
+
m.sampling_start_time.must_be :<, f2
|
65
63
|
# distance from now to start time should be greater than the distance from
|
66
64
|
# the start to the min start_time
|
67
|
-
(f2 - m.sampling_start_time).
|
65
|
+
(f2 - m.sampling_start_time).must_be :>, ( m.sampling_start_time - f1 )
|
68
66
|
end
|
69
67
|
|
70
68
|
it "keeps track of the last stop time of all the intervals" do
|
@@ -72,37 +70,37 @@ describe Hitimes::ValueMetric do
|
|
72
70
|
f1 = Time.now.gmtime.to_f * 1_000_000
|
73
71
|
10.times {|x| m.measure( x ); sleep 0.1 }
|
74
72
|
f2 = Time.now.gmtime.to_f * 1_000_000
|
75
|
-
m.sampling_stop_time.
|
76
|
-
m.sampling_stop_time.
|
73
|
+
m.sampling_stop_time.must_be :>, f1
|
74
|
+
m.sampling_stop_time.must_be :<=, f2
|
77
75
|
# distance from now to max stop time time should be less than the distance
|
78
76
|
# from the start to the max stop time
|
79
|
-
(f2 - m.sampling_stop_time).
|
77
|
+
(f2 - m.sampling_stop_time).must_be :<, ( m.sampling_stop_time - f1 )
|
80
78
|
end
|
81
79
|
|
82
80
|
describe "#to_hash" do
|
83
81
|
|
84
82
|
it "has name value" do
|
85
83
|
h = @metric.to_hash
|
86
|
-
h['name'].
|
84
|
+
h['name'].must_equal "testing"
|
87
85
|
end
|
88
86
|
|
89
87
|
it "has an empty has for additional_data" do
|
90
88
|
h = @metric.to_hash
|
91
|
-
h['additional_data'].
|
92
|
-
h['additional_data'].size.
|
89
|
+
h['additional_data'].must_equal Hash.new
|
90
|
+
h['additional_data'].size.must_equal 0
|
93
91
|
end
|
94
92
|
|
95
93
|
it "has the right sum" do
|
96
94
|
h = @metric.to_hash
|
97
|
-
h['sum'].
|
95
|
+
h['sum'].must_equal 45
|
98
96
|
end
|
99
97
|
|
100
98
|
fields = ::Hitimes::Stats::STATS.dup + %w[ name additional_data sampling_start_time sampling_stop_time ]
|
101
99
|
fields = fields - [ 'rate' ]
|
102
100
|
fields.each do |f|
|
103
|
-
it "
|
101
|
+
it "has a value for #{f}" do
|
104
102
|
h = @metric.to_hash
|
105
|
-
h[f].
|
103
|
+
h[f].wont_be_nil
|
106
104
|
end
|
107
105
|
end
|
108
106
|
end
|
data/spec/version_spec.rb
CHANGED
@@ -1,33 +1,7 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe "Hitimes::Version" do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
it "should have a minor number that is >= 0" do
|
9
|
-
Hitimes::Version::MINOR.should >= 0
|
10
|
-
end
|
11
|
-
|
12
|
-
it "should have a tiny number that is >= 0" do
|
13
|
-
Hitimes::Version::BUILD.should >= 0
|
14
|
-
end
|
15
|
-
|
16
|
-
it "should have an array representation" do
|
17
|
-
Hitimes::Version.to_a.should have(3).items
|
18
|
-
end
|
19
|
-
|
20
|
-
it "should have a string representation" do
|
21
|
-
Hitimes::Version.to_s.should match(/\d+\.\d+\.\d+/)
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should have a hash representation" do
|
25
|
-
[ :major, :minor, :build ].each do |k|
|
26
|
-
Hitimes::Version.to_hash[k].should_not be_nil
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
it "should be accessable as a constant" do
|
31
|
-
Hitimes::VERSION.should match(/\d+\.\d+\.\d+/)
|
32
|
-
end
|
4
|
+
it "should be accessable as a constant" do
|
5
|
+
Hitimes::VERSION.must_match(/\d+\.\d+\.\d+/)
|
6
|
+
end
|
33
7
|
end
|
data/tasks/default.rake
ADDED
@@ -0,0 +1,242 @@
|
|
1
|
+
# vim: syntax=ruby
|
2
|
+
require 'rake/clean'
|
3
|
+
require 'digest'
|
4
|
+
#------------------------------------------------------------------------------
|
5
|
+
# If you want to Develop on this project just run 'rake develop' and you'll
|
6
|
+
# have all you need to get going. If you want to use bundler for development,
|
7
|
+
# then run 'rake develop:using_bundler'
|
8
|
+
#------------------------------------------------------------------------------
|
9
|
+
namespace :develop do
|
10
|
+
|
11
|
+
# Install all the development and runtime dependencies of this gem using the
|
12
|
+
# gemspec.
|
13
|
+
task :default => 'Gemfile' do
|
14
|
+
require 'rubygems/dependency_installer'
|
15
|
+
installer = ::Gem::DependencyInstaller.new
|
16
|
+
puts "Installing bundler..."
|
17
|
+
installer.install 'bundler'
|
18
|
+
sh 'bundle install'
|
19
|
+
puts "\n\nNow run 'rake test'"
|
20
|
+
end
|
21
|
+
|
22
|
+
# Create a Gemfile that just references the gemspec
|
23
|
+
file 'Gemfile' => :gemspec do
|
24
|
+
File.open( "Gemfile", "w+" ) do |f|
|
25
|
+
f.puts "# DO NOT EDIT - This file is automatically generated"
|
26
|
+
f.puts "# Make changes to Manifest.txt and/or Rakefile and regenerate"
|
27
|
+
f.puts 'source "https://rubygems.org/"'
|
28
|
+
f.puts 'gemspec'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
desc "Boostrap development"
|
33
|
+
task :develop => "develop:default"
|
34
|
+
|
35
|
+
#------------------------------------------------------------------------------
|
36
|
+
# Minitest - standard TestTask
|
37
|
+
#------------------------------------------------------------------------------
|
38
|
+
begin
|
39
|
+
require 'rake/testtask'
|
40
|
+
Rake::TestTask.new( :test ) do |t|
|
41
|
+
t.ruby_opts = %w[ -w -rubygems ]
|
42
|
+
t.libs = %w[ lib spec test ]
|
43
|
+
t.pattern = "{test,spec}/**/{test_*,*_spec}.rb"
|
44
|
+
end
|
45
|
+
|
46
|
+
task :test_requirements
|
47
|
+
task :test => :test_requirements
|
48
|
+
task :default => :test
|
49
|
+
rescue LoadError
|
50
|
+
This.task_warning( 'test' )
|
51
|
+
end
|
52
|
+
|
53
|
+
#------------------------------------------------------------------------------
|
54
|
+
# RDoc - standard rdoc rake task, although we must make sure to use a more
|
55
|
+
# recent version of rdoc since it is the one that has 'tomdoc' markup
|
56
|
+
#------------------------------------------------------------------------------
|
57
|
+
begin
|
58
|
+
gem 'rdoc' # otherwise we get the wrong task from stdlib
|
59
|
+
require 'rdoc/task'
|
60
|
+
RDoc::Task.new do |t|
|
61
|
+
t.markup = 'tomdoc'
|
62
|
+
t.rdoc_dir = 'doc'
|
63
|
+
t.main = 'README.md'
|
64
|
+
t.title = "#{This.name} #{This.version}"
|
65
|
+
t.rdoc_files.include( FileList['*.{rdoc,md,txt}'], FileList['ext/**/*.c'],
|
66
|
+
FileList['lib/**/*.rb'] )
|
67
|
+
end
|
68
|
+
rescue StandardError, LoadError
|
69
|
+
This.task_warning( 'rdoc' )
|
70
|
+
end
|
71
|
+
|
72
|
+
#------------------------------------------------------------------------------
|
73
|
+
# Coverage - optional code coverage, rcov for 1.8 and simplecov for 1.9, so
|
74
|
+
# for the moment only rcov is listed.
|
75
|
+
#------------------------------------------------------------------------------
|
76
|
+
begin
|
77
|
+
require 'simplecov'
|
78
|
+
desc 'Run tests with code coverage'
|
79
|
+
task :coverage do
|
80
|
+
ENV['COVERAGE'] = 'true'
|
81
|
+
Rake::Task[:test].execute
|
82
|
+
end
|
83
|
+
CLOBBER << 'coverage' if File.directory?('coverage')
|
84
|
+
rescue LoadError
|
85
|
+
This.task_warning( 'simplecov' )
|
86
|
+
end
|
87
|
+
|
88
|
+
#------------------------------------------------------------------------------
|
89
|
+
# Manifest - We want an explicit list of thos files that are to be packaged in
|
90
|
+
# the gem. Most of this is from Hoe.
|
91
|
+
#------------------------------------------------------------------------------
|
92
|
+
namespace 'manifest' do
|
93
|
+
desc "Check the manifest"
|
94
|
+
task :check => :clean do
|
95
|
+
files = FileList["**/*", ".*"].exclude( This.exclude_from_manifest ).to_a.sort
|
96
|
+
files = files.select{ |f| File.file?( f ) }
|
97
|
+
|
98
|
+
tmp = "Manifest.tmp"
|
99
|
+
File.open( tmp, 'w' ) do |f|
|
100
|
+
f.puts files.join("\n")
|
101
|
+
end
|
102
|
+
|
103
|
+
begin
|
104
|
+
sh "diff -du Manifest.txt #{tmp}"
|
105
|
+
ensure
|
106
|
+
rm tmp
|
107
|
+
end
|
108
|
+
puts "Manifest looks good"
|
109
|
+
end
|
110
|
+
|
111
|
+
desc "Generate the manifest"
|
112
|
+
task :generate => :clean do
|
113
|
+
files = %x[ git ls-files ].split("\n").sort
|
114
|
+
files.reject! { |f| f =~ This.exclude_from_manifest }
|
115
|
+
File.open( "Manifest.txt", "w" ) do |f|
|
116
|
+
f.puts files.join("\n")
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
#------------------------------------------------------------------------------
|
122
|
+
# Fixme - look for fixmes and report them
|
123
|
+
#------------------------------------------------------------------------------
|
124
|
+
namespace :fixme do
|
125
|
+
task :default => 'manifest:check' do
|
126
|
+
This.manifest.each do |file|
|
127
|
+
next if file == __FILE__
|
128
|
+
next unless file =~ %r/(txt|rb|md|rdoc|css|html|xml|css)\Z/
|
129
|
+
puts "FIXME: Rename #{file}" if file =~ /fixme/i
|
130
|
+
IO.readlines( file ).each_with_index do |line, idx|
|
131
|
+
prefix = "FIXME: #{file}:#{idx+1}".ljust(42)
|
132
|
+
puts "#{prefix} => #{line.strip}" if line =~ /fixme/i
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
def fixme_project_root
|
138
|
+
This.project_path( '../fixme' )
|
139
|
+
end
|
140
|
+
|
141
|
+
def fixme_project_path( subtree )
|
142
|
+
fixme_project_root.join( subtree )
|
143
|
+
end
|
144
|
+
|
145
|
+
def local_fixme_files
|
146
|
+
This.manifest.select { |p| p =~ %r|^tasks/| }
|
147
|
+
end
|
148
|
+
|
149
|
+
def outdated_fixme_files
|
150
|
+
local_fixme_files.select do |local|
|
151
|
+
upstream = fixme_project_path( local )
|
152
|
+
upstream.exist? &&
|
153
|
+
( Digest::SHA256.file( local ) != Digest::SHA256.file( upstream ) )
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
def fixme_up_to_date?
|
158
|
+
outdated_fixme_files.empty?
|
159
|
+
end
|
160
|
+
|
161
|
+
desc "See if the fixme tools are outdated"
|
162
|
+
task :outdated => :release_check do
|
163
|
+
if fixme_up_to_date? then
|
164
|
+
puts "Fixme files are up to date."
|
165
|
+
else
|
166
|
+
outdated_fixme_files.each do |f|
|
167
|
+
puts "#{f} is outdated"
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
desc "Update outdated fixme files"
|
173
|
+
task :update => :release_check do
|
174
|
+
if fixme_up_to_date? then
|
175
|
+
puts "Fixme files are already up to date."
|
176
|
+
else
|
177
|
+
puts "Updating fixme files:"
|
178
|
+
outdated_fixme_files.each do |local|
|
179
|
+
upstream = fixme_project_path( local )
|
180
|
+
puts " * #{local}"
|
181
|
+
FileUtils.cp( upstream, local )
|
182
|
+
end
|
183
|
+
puts "Use your git commands as appropriate."
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
187
|
+
desc "Look for fixmes and report them"
|
188
|
+
task :fixme => "fixme:default"
|
189
|
+
|
190
|
+
#------------------------------------------------------------------------------
|
191
|
+
# Gem Specification
|
192
|
+
#------------------------------------------------------------------------------
|
193
|
+
# Really this is only here to support those who use bundler
|
194
|
+
desc "Build the #{This.name}.gemspec file"
|
195
|
+
task :gemspec do
|
196
|
+
File.open( This.gemspec_file, "wb+" ) do |f|
|
197
|
+
f.puts "# DO NOT EDIT - This file is automatically generated"
|
198
|
+
f.puts "# Make changes to Manifest.txt and/or Rakefile and regenerate"
|
199
|
+
f.write This.platform_gemspec.to_ruby
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
# .rbc files from ruby 2.0
|
204
|
+
CLOBBER << FileList["**/*.rbc"]
|
205
|
+
|
206
|
+
# The standard gem packaging task, everyone has it.
|
207
|
+
require 'rubygems/package_task'
|
208
|
+
::Gem::PackageTask.new( This.platform_gemspec ) do
|
209
|
+
# nothing
|
210
|
+
end
|
211
|
+
|
212
|
+
#------------------------------------------------------------------------------
|
213
|
+
# Release - the steps we go through to do a final release, this is pulled from
|
214
|
+
# a compbination of mojombo's rakegem, hoe and hoe-git
|
215
|
+
#
|
216
|
+
# 1) make sure we are on the master branch
|
217
|
+
# 2) make sure there are no uncommitted items
|
218
|
+
# 3) check the manifest and make sure all looks good
|
219
|
+
# 4) build the gem
|
220
|
+
# 5) do an empty commit to have the commit message of the version
|
221
|
+
# 6) tag that commit as the version
|
222
|
+
# 7) push master
|
223
|
+
# 8) push the tag
|
224
|
+
# 7) pus the gem
|
225
|
+
#------------------------------------------------------------------------------
|
226
|
+
task :release_check do
|
227
|
+
unless `git branch` =~ /^\* master$/
|
228
|
+
abort "You must be on the master branch to release!"
|
229
|
+
end
|
230
|
+
unless `git status` =~ /^nothing to commit/m
|
231
|
+
abort "Nope, sorry, you have unfinished business"
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
desc "Create tag v#{This.version}, build and push #{This.platform_gemspec.full_name} to rubygems.org"
|
236
|
+
task :release => [ :release_check, 'manifest:check', :gem ] do
|
237
|
+
sh "git commit --allow-empty -a -m 'Release #{This.version}'"
|
238
|
+
sh "git tag -a -m 'v#{This.version}' v#{This.version}"
|
239
|
+
sh "git push origin master"
|
240
|
+
sh "git push origin v#{This.version}"
|
241
|
+
sh "gem push pkg/#{This.platform_gemspec.full_name}.gem"
|
242
|
+
end
|
data/tasks/extension.rake
CHANGED
@@ -1,108 +1,38 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
#
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
ruby conf.to_s
|
18
|
-
sh "make"
|
19
|
-
|
20
|
-
# install into requireable location so specs will run
|
21
|
-
subdir = "hitimes/#{RUBY_VERSION.sub(/\.\d$/,'')}"
|
22
|
-
dest_dir = Hitimes::Paths.lib_path( subdir )
|
23
|
-
mkdir_p dest_dir, :verbose => true
|
24
|
-
cp "hitimes_ext.#{Config::CONFIG['DLEXT']}", dest_dir, :verbose => true
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
if RUBY_PLATFORM == "java" then
|
30
|
-
desc "Build the jruby extension"
|
31
|
-
task :build_java => [ :clobber, "lib/hitimes/hitimes.jar" ]
|
32
|
-
|
33
|
-
file "lib/hitimes/hitimes.jar" => FileList["ext/java/src/hitimes/*.java"] do |t|
|
34
|
-
jruby_home = Config::CONFIG['prefix']
|
35
|
-
jruby_jar = File.join( jruby_home, 'lib', 'jruby.jar' )
|
36
|
-
|
37
|
-
mkdir_p 'pkg/classes'
|
38
|
-
sh "javac -classpath #{jruby_jar} -d pkg/classes #{t.prerequisites.join(' ')}"
|
39
|
-
|
40
|
-
dest_dir = File.dirname(t.name)
|
41
|
-
sh "jar cf #{t.name} -C pkg/classes ."
|
42
|
-
end
|
1
|
+
# To be used if the gem has extensions.
|
2
|
+
# If this task set is inclueded then you will need to also have
|
3
|
+
#
|
4
|
+
# spec.add_development_dependency( 'rake-compiler', '~> 0.8.1' )
|
5
|
+
#
|
6
|
+
# in your top level rakefile
|
7
|
+
begin
|
8
|
+
require 'rake/extensiontask'
|
9
|
+
require 'rake/javaextensiontask'
|
10
|
+
|
11
|
+
if RUBY_PLATFORM == "java" then
|
12
|
+
|
13
|
+
Rake::JavaExtensionTask.new( This.name) do |ext|
|
14
|
+
ext.ext_dir = File.join( 'ext', This.name, "java" )
|
15
|
+
ext.lib_dir = File.join( 'lib', This.name )
|
16
|
+
ext.gem_spec = This.java_gemspec
|
43
17
|
end
|
44
18
|
|
19
|
+
else
|
45
20
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
Hitimes::GEM_SPEC.extensions.each do |extension|
|
51
|
-
path = Pathname.new(extension)
|
52
|
-
parts = path.split
|
53
|
-
conf = parts.last
|
54
|
-
rvm = File.expand_path( "~/.rvm/bin/rvm" )
|
55
|
-
Dir.chdir(path.dirname) do |d|
|
56
|
-
if File.exist?( "Makefile" ) then
|
57
|
-
sh "make clean distclean"
|
58
|
-
end
|
59
|
-
cp "#{rbconfig}", "rbconfig.rb"
|
60
|
-
rubylib = ENV['RUBYLIB']
|
61
|
-
ENV['RUBYLIB'] = "."
|
62
|
-
sh %[#{rvm} #{version} -S extconf.rb]
|
63
|
-
ENV['RUBYLIB'] = rubylib
|
64
|
-
sh "make"
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
win_builds = []
|
70
|
-
ext_config.cross_rbconfig.keys.each do |v|
|
71
|
-
s = v.split("-").last
|
72
|
-
desc "Build the extension for windows version #{s}"
|
73
|
-
win_bname = "build_win-#{s}"
|
74
|
-
win_builds << win_bname
|
75
|
-
task win_bname => :clean do
|
76
|
-
build_win( s )
|
77
|
-
end
|
78
|
-
end
|
21
|
+
Rake::ExtensionTask.new( This.name ) do |ext|
|
22
|
+
ext.ext_dir = File.join( 'ext', This.name, "c" )
|
23
|
+
ext.lib_dir = File.join( 'lib', This.name )
|
24
|
+
ext.gem_spec = This.ruby_gemspec
|
79
25
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
parts = path.split
|
84
|
-
conf = parts.last
|
85
|
-
Dir.chdir(path.dirname) do |d|
|
86
|
-
if File.exist?( "Makefile" ) then
|
87
|
-
sh "make clean"
|
88
|
-
end
|
89
|
-
rm_f "rbconfig.rb"
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
task :clobber do
|
95
|
-
ext_config.configs.each do |extension|
|
96
|
-
path = Pathname.new(extension)
|
97
|
-
parts = path.split
|
98
|
-
conf = parts.last
|
99
|
-
Dir.chdir(path.dirname) do |d|
|
100
|
-
if File.exist?( "Makefile" ) then
|
101
|
-
sh "make distclean"
|
102
|
-
end
|
103
|
-
rm_f "rbconfig.rb"
|
104
|
-
end
|
105
|
-
end
|
26
|
+
ext.cross_compile = true # enable cross compilation (requires cross compile toolchain)
|
27
|
+
ext.cross_platform = 'i386-mingw32' # forces the Windows platform instead of the default one
|
28
|
+
# configure options only for cross compile
|
106
29
|
end
|
107
30
|
end
|
31
|
+
|
32
|
+
task :test_requirements => :compile
|
33
|
+
rescue LoadError
|
34
|
+
This.task_warning( 'extension' )
|
108
35
|
end
|
36
|
+
|
37
|
+
CLOBBER << FileList["lib/**/*.{jar,so,bundle}"]
|
38
|
+
CLOBBER << FileList["lib/#{This.name}/{1.8,1.9,2.0,2.1,2.2}/"]
|