amalgalite 1.1.2-x86-mingw32 → 1.4.0-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. data/CONTRIBUTING.md +49 -0
  2. data/{HISTORY.rdoc → HISTORY.md} +102 -73
  3. data/LICENSE +2 -2
  4. data/Manifest.txt +104 -0
  5. data/README.md +73 -0
  6. data/Rakefile +25 -0
  7. data/TODO.md +49 -0
  8. data/ext/amalgalite/{amalgalite3.c → c/amalgalite.c} +12 -12
  9. data/ext/amalgalite/{amalgalite3.h → c/amalgalite.h} +5 -5
  10. data/ext/amalgalite/{amalgalite3_blob.c → c/amalgalite_blob.c} +2 -2
  11. data/ext/amalgalite/{amalgalite3_constants.c → c/amalgalite_constants.c} +2 -2
  12. data/ext/amalgalite/{amalgalite3_database.c → c/amalgalite_database.c} +49 -21
  13. data/ext/amalgalite/{amalgalite3_requires_bootstrap.c → c/amalgalite_requires_bootstrap.c} +131 -58
  14. data/ext/amalgalite/{amalgalite3_statement.c → c/amalgalite_statement.c} +2 -2
  15. data/ext/amalgalite/{extconf.rb → c/extconf.rb} +6 -5
  16. data/ext/amalgalite/{gen_constants.rb → c/gen_constants.rb} +3 -3
  17. data/ext/amalgalite/c/notes.txt +134 -0
  18. data/ext/amalgalite/{sqlite3.c → c/sqlite3.c} +111793 -83396
  19. data/ext/amalgalite/{sqlite3.h → c/sqlite3.h} +1597 -383
  20. data/ext/amalgalite/{sqlite3_options.h → c/sqlite3_options.h} +0 -0
  21. data/ext/amalgalite/{sqlite3ext.h → c/sqlite3ext.h} +114 -17
  22. data/lib/amalgalite.rb +13 -6
  23. data/lib/amalgalite/1.9/amalgalite.so +0 -0
  24. data/lib/amalgalite/2.0/amalgalite.so +0 -0
  25. data/lib/amalgalite/2.1/amalgalite.so +0 -0
  26. data/lib/amalgalite/column.rb +7 -5
  27. data/lib/amalgalite/database.rb +18 -10
  28. data/lib/amalgalite/packer.rb +5 -2
  29. data/lib/amalgalite/requires.rb +47 -16
  30. data/lib/amalgalite/schema.rb +63 -36
  31. data/lib/amalgalite/sqlite3/version.rb +0 -1
  32. data/lib/amalgalite/statement.rb +7 -5
  33. data/lib/amalgalite/table.rb +9 -8
  34. data/lib/amalgalite/type_maps/default_map.rb +0 -1
  35. data/lib/amalgalite/type_maps/storage_map.rb +0 -2
  36. data/lib/amalgalite/type_maps/text_map.rb +0 -1
  37. data/lib/amalgalite/version.rb +3 -32
  38. data/spec/aggregate_spec.rb +1 -1
  39. data/spec/amalgalite_spec.rb +1 -1
  40. data/spec/blob_spec.rb +1 -1
  41. data/spec/boolean_spec.rb +2 -1
  42. data/spec/busy_handler.rb +1 -1
  43. data/spec/database_spec.rb +18 -13
  44. data/spec/default_map_spec.rb +1 -1
  45. data/spec/function_spec.rb +1 -1
  46. data/spec/integeration_spec.rb +2 -1
  47. data/spec/packer_spec.rb +4 -4
  48. data/spec/paths_spec.rb +1 -1
  49. data/spec/progress_handler_spec.rb +4 -5
  50. data/spec/requires_spec.rb +36 -2
  51. data/spec/rtree_spec.rb +6 -5
  52. data/spec/schema_spec.rb +28 -20
  53. data/spec/spec_helper.rb +7 -7
  54. data/spec/sqlite3/constants_spec.rb +1 -1
  55. data/spec/sqlite3/database_status_spec.rb +4 -4
  56. data/spec/sqlite3/status_spec.rb +5 -5
  57. data/spec/sqlite3/version_spec.rb +12 -12
  58. data/spec/sqlite3_spec.rb +3 -3
  59. data/spec/statement_spec.rb +3 -4
  60. data/spec/storage_map_spec.rb +1 -1
  61. data/spec/tap_spec.rb +4 -4
  62. data/spec/text_map_spec.rb +1 -1
  63. data/spec/type_map_spec.rb +1 -1
  64. data/spec/version_spec.rb +3 -10
  65. data/tasks/custom.rake +102 -0
  66. data/tasks/default.rake +247 -0
  67. data/tasks/extension.rake +28 -202
  68. data/tasks/this.rb +206 -0
  69. metadata +194 -236
  70. data/README.rdoc +0 -54
  71. data/gemspec.rb +0 -63
  72. data/lib/amalgalite/1.8/amalgalite3.so +0 -0
  73. data/lib/amalgalite/1.9/amalgalite3.so +0 -0
  74. data/tasks/announce.rake +0 -44
  75. data/tasks/config.rb +0 -107
  76. data/tasks/distribution.rake +0 -77
  77. data/tasks/documentation.rake +0 -36
  78. data/tasks/rspec.rake +0 -30
  79. data/tasks/utils.rb +0 -80
@@ -1,4 +1,4 @@
1
- require File.expand_path( File.join( File.dirname( __FILE__ ), "spec_helper.rb" ) )
1
+ require 'spec_helper'
2
2
  require 'amalgalite/type_maps/text_map'
3
3
 
4
4
  describe Amalgalite::TypeMaps::TextMap do
@@ -1,4 +1,4 @@
1
- require File.expand_path( File.join( File.dirname( __FILE__ ), "spec_helper.rb" ) )
1
+ require 'spec_helper'
2
2
  require 'amalgalite/type_map'
3
3
 
4
4
  describe Amalgalite::TypeMap do
data/spec/version_spec.rb CHANGED
@@ -1,15 +1,8 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__),"spec_helper.rb"))
1
+ require 'spec_helper'
2
2
  require 'amalgalite/version'
3
3
 
4
- describe "Amalgalite::Version" do
4
+ describe "Amalgalite::VERSION" do
5
5
  it "should have a version string" do
6
- Amalgalite::Version.to_s.should =~ /\d+\.\d+\.\d+/
7
- Amalgalite::VERSION.should =~ /\d+\.\d+\.\d+/
8
- end
9
- it "should have a version hash" do
10
- h = Amalgalite::Version.to_hash
11
- [ :major, :minor, :build ].each do |k|
12
- h[k].should_not be_nil
13
- end
6
+ expect(Amalgalite::VERSION).to match( /\d+\.\d+\.\d+/ )
14
7
  end
15
8
  end
data/tasks/custom.rake ADDED
@@ -0,0 +1,102 @@
1
+ #-----------------------------------------------------------------------
2
+ # Custom tasks for this project
3
+ #-----------------------------------------------------------------------
4
+ require 'pathname'
5
+ namespace :util do
6
+ desc "List the sqlite api calls that are not implemented"
7
+ task :todo do
8
+
9
+ not_implementing = %w[
10
+ sqlite3_exec
11
+ sqlite3_open
12
+ sqlite3_os_end
13
+ sqlite3_os_init
14
+ sqlite3_malloc
15
+ sqlite3_realloc
16
+ sqlite3_free
17
+ sqlite3_get_table
18
+ sqlite3_free_table
19
+ sqlite3_key
20
+ sqlite3_rekey
21
+ sqlite3_next_stmt
22
+ sqlite3_release_memory
23
+ sqlite3_sleep
24
+ sqlite3_snprintf
25
+ sqlite3_vmprintf
26
+ sqlite3_strnicmp
27
+ sqlite3_test_control
28
+ sqlite3_unlock_notify
29
+ sqlite3_vfs_find
30
+ sqlite3_vfs_register
31
+ sqlite3_vfs_unregister
32
+ ]
33
+
34
+ sqlite_h = File.join( *%w[ ext amalgalite c sqlite3.h ] )
35
+ api_todo = {}
36
+ IO.readlines( sqlite_h ).each do |line|
37
+ if line =~ /\ASQLITE_API/ then
38
+ if line !~ /SQLITE_DEPRECATED/ and line !~ /SQLITE_EXPERIMENTAL/ then
39
+ if md = line.match( /(sqlite3_[^(\s]+)\(/ ) then
40
+ next if not_implementing.include?(md.captures[0])
41
+ api_todo[md.captures[0]] = true
42
+ end
43
+ end
44
+ end
45
+ end
46
+
47
+ Dir.glob("ext/amalgalite/c/amalgalite*.c").each do |am_file|
48
+ IO.readlines( am_file ).each do |am_line|
49
+ if md = am_line.match( /(sqlite3_[^(\s]+)\(/ ) then
50
+ api_todo.delete( md.captures[0] )
51
+ end
52
+ end
53
+ end
54
+
55
+ puts "#{api_todo.keys.size} functions to still implement"
56
+ puts api_todo.keys.sort.join("\n")
57
+ end
58
+
59
+ desc "Download and integrate a version of sqlite"
60
+ task :update_sqlite, [:version,:year] do |task, args|
61
+ version = args[:version] or abort "A version of SQLite please `rake #{task.name}[version,year]`"
62
+ version_year = args[:year] or abort "The Year #{version} was released please `rake #{task.name}[version,year]`"
63
+
64
+ require 'uri'
65
+ require 'open-uri'
66
+ require 'zip'
67
+
68
+ parts = version.split(".")
69
+ next_version = [ parts.shift.to_s ]
70
+ parts.each do |p|
71
+ next_version << "#{"%02d" % p }"
72
+ end
73
+ next_version << "00" if next_version.size == 3
74
+
75
+ next_version = next_version.join('')
76
+
77
+ url = ::URI.parse("http://sqlite.org/#{version_year}/sqlite-amalgamation-#{next_version}.zip")
78
+ puts "downloading #{url.to_s} ..."
79
+ file = "tmp/#{File.basename( url.path ) }"
80
+ FileUtils.mkdir "tmp" unless File.directory?( "tmp" )
81
+ File.open( file, "wb+") do |f|
82
+ open(url) do |input|
83
+ f.write( input.read )
84
+ end
85
+ end
86
+
87
+ puts "extracting..."
88
+ upstream_files = %w[ sqlite3.h sqlite3.c sqlite3ext.h ]
89
+ Zip::ZipInputStream.open( file ) do |io|
90
+ loop do
91
+ entry = io.get_next_entry
92
+ break unless entry
93
+ bname = File.basename( entry.name )
94
+ if upstream_files.include?( bname ) then
95
+ dest_file = File.join( "ext", "amalgalite", "c", bname )
96
+ puts "updating #{dest_file}"
97
+ entry.extract( dest_file ) { true }
98
+ end
99
+ end
100
+ end
101
+ end
102
+ end
@@ -0,0 +1,247 @@
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
+ require 'rspec/core/rake_task'
47
+ RSpec::Core::RakeTask.new( :spec ) do |t|
48
+ t.ruby_opts = %w[ -w ]
49
+ t.rspec_opts = %w[ --color --format documentation ]
50
+ end
51
+ task :test_requirements
52
+ task :test => :test_requirements
53
+ task :default => :test
54
+ rescue LoadError
55
+ This.task_warning( 'test' )
56
+ end
57
+
58
+ #------------------------------------------------------------------------------
59
+ # RDoc - standard rdoc rake task, although we must make sure to use a more
60
+ # recent version of rdoc since it is the one that has 'tomdoc' markup
61
+ #------------------------------------------------------------------------------
62
+ begin
63
+ gem 'rdoc' # otherwise we get the wrong task from stdlib
64
+ require 'rdoc/task'
65
+ RDoc::Task.new do |t|
66
+ t.markup = 'tomdoc'
67
+ t.rdoc_dir = 'doc'
68
+ t.main = 'README.md'
69
+ t.title = "#{This.name} #{This.version}"
70
+ t.rdoc_files.include( FileList['*.{rdoc,md,txt}'], FileList['ext/**/*.c'],
71
+ FileList['lib/**/*.rb'] )
72
+ end
73
+ rescue StandardError, LoadError
74
+ This.task_warning( 'rdoc' )
75
+ end
76
+
77
+ #------------------------------------------------------------------------------
78
+ # Coverage - optional code coverage, rcov for 1.8 and simplecov for 1.9, so
79
+ # for the moment only rcov is listed.
80
+ #------------------------------------------------------------------------------
81
+ begin
82
+ require 'simplecov'
83
+ desc 'Run tests with code coverage'
84
+ task :coverage do
85
+ ENV['COVERAGE'] = 'true'
86
+ Rake::Task[:test].execute
87
+ end
88
+ CLOBBER << 'coverage' if File.directory?( 'coverage' )
89
+ rescue LoadError
90
+ This.task_warning( 'simplecov' )
91
+ end
92
+
93
+ #------------------------------------------------------------------------------
94
+ # Manifest - We want an explicit list of thos files that are to be packaged in
95
+ # the gem. Most of this is from Hoe.
96
+ #------------------------------------------------------------------------------
97
+ namespace 'manifest' do
98
+ desc "Check the manifest"
99
+ task :check => :clean do
100
+ files = FileList["**/*", ".*"].exclude( This.exclude_from_manifest ).to_a.sort
101
+ files = files.select{ |f| File.file?( f ) }
102
+
103
+ tmp = "Manifest.tmp"
104
+ File.open( tmp, 'w' ) do |f|
105
+ f.puts files.join("\n")
106
+ end
107
+
108
+ begin
109
+ sh "diff -du Manifest.txt #{tmp}"
110
+ ensure
111
+ rm tmp
112
+ end
113
+ puts "Manifest looks good"
114
+ end
115
+
116
+ desc "Generate the manifest"
117
+ task :generate => :clean do
118
+ files = %x[ git ls-files ].split("\n").sort
119
+ files.reject! { |f| f =~ This.exclude_from_manifest }
120
+ File.open( "Manifest.txt", "w" ) do |f|
121
+ f.puts files.join("\n")
122
+ end
123
+ end
124
+ end
125
+
126
+ #------------------------------------------------------------------------------
127
+ # Fixme - look for fixmes and report them
128
+ #------------------------------------------------------------------------------
129
+ namespace :fixme do
130
+ task :default => 'manifest:check' do
131
+ This.manifest.each do |file|
132
+ next if file == __FILE__
133
+ next unless file =~ %r/(txt|rb|md|rdoc|css|html|xml|css)\Z/
134
+ puts "FIXME: Rename #{file}" if file =~ /fixme/i
135
+ IO.readlines( file ).each_with_index do |line, idx|
136
+ prefix = "FIXME: #{file}:#{idx+1}".ljust(42)
137
+ puts "#{prefix} => #{line.strip}" if line =~ /fixme/i
138
+ end
139
+ end
140
+ end
141
+
142
+ def fixme_project_root
143
+ This.project_path( '../fixme' )
144
+ end
145
+
146
+ def fixme_project_path( subtree )
147
+ fixme_project_root.join( subtree )
148
+ end
149
+
150
+ def local_fixme_files
151
+ This.manifest.select { |p| p =~ %r|^tasks/| }
152
+ end
153
+
154
+ def outdated_fixme_files
155
+ local_fixme_files.select do |local|
156
+ upstream = fixme_project_path( local )
157
+ upstream.exist? &&
158
+ ( Digest::SHA256.file( local ) != Digest::SHA256.file( upstream ) )
159
+ end
160
+ end
161
+
162
+ def fixme_up_to_date?
163
+ outdated_fixme_files.empty?
164
+ end
165
+
166
+ desc "See if the fixme tools are outdated"
167
+ task :outdated => :release_check do
168
+ if fixme_up_to_date? then
169
+ puts "Fixme files are up to date."
170
+ else
171
+ outdated_fixme_files.each do |f|
172
+ puts "#{f} is outdated"
173
+ end
174
+ end
175
+ end
176
+
177
+ desc "Update outdated fixme files"
178
+ task :update => :release_check do
179
+ if fixme_up_to_date? then
180
+ puts "Fixme files are already up to date."
181
+ else
182
+ puts "Updating fixme files:"
183
+ outdated_fixme_files.each do |local|
184
+ upstream = fixme_project_path( local )
185
+ puts " * #{local}"
186
+ FileUtils.cp( upstream, local )
187
+ end
188
+ puts "Use your git commands as appropriate."
189
+ end
190
+ end
191
+ end
192
+ desc "Look for fixmes and report them"
193
+ task :fixme => "fixme:default"
194
+
195
+ #------------------------------------------------------------------------------
196
+ # Gem Specification
197
+ #------------------------------------------------------------------------------
198
+ # Really this is only here to support those who use bundler
199
+ desc "Build the #{This.name}.gemspec file"
200
+ task :gemspec do
201
+ File.open( This.gemspec_file, "wb+" ) do |f|
202
+ f.puts "# DO NOT EDIT - This file is automatically generated"
203
+ f.puts "# Make changes to Manifest.txt and/or Rakefile and regenerate"
204
+ f.write This.platform_gemspec.to_ruby
205
+ end
206
+ end
207
+
208
+ # .rbc files from ruby 2.0
209
+ CLOBBER << FileList["**/*.rbc"]
210
+
211
+ # The standard gem packaging task, everyone has it.
212
+ require 'rubygems/package_task'
213
+ ::Gem::PackageTask.new( This.platform_gemspec ) do
214
+ # nothing
215
+ end
216
+
217
+ #------------------------------------------------------------------------------
218
+ # Release - the steps we go through to do a final release, this is pulled from
219
+ # a compbination of mojombo's rakegem, hoe and hoe-git
220
+ #
221
+ # 1) make sure we are on the master branch
222
+ # 2) make sure there are no uncommitted items
223
+ # 3) check the manifest and make sure all looks good
224
+ # 4) build the gem
225
+ # 5) do an empty commit to have the commit message of the version
226
+ # 6) tag that commit as the version
227
+ # 7) push master
228
+ # 8) push the tag
229
+ # 7) pus the gem
230
+ #------------------------------------------------------------------------------
231
+ task :release_check do
232
+ unless `git branch` =~ /^\* master$/
233
+ abort "You must be on the master branch to release!"
234
+ end
235
+ unless `git status` =~ /^nothing to commit/m
236
+ abort "Nope, sorry, you have unfinished business"
237
+ end
238
+ end
239
+
240
+ desc "Create tag v#{This.version}, build and push #{This.platform_gemspec.full_name} to rubygems.org"
241
+ task :release => [ :release_check, 'manifest:check', :gem ] do
242
+ sh "git commit --allow-empty -a -m 'Release #{This.version}'"
243
+ sh "git tag -a -m 'v#{This.version}' v#{This.version}"
244
+ sh "git push origin master"
245
+ sh "git push origin v#{This.version}"
246
+ sh "gem push pkg/#{This.platform_gemspec.full_name}.gem"
247
+ end
data/tasks/extension.rake CHANGED
@@ -1,212 +1,38 @@
1
- require 'tasks/config'
2
- require 'pathname'
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
3
7
  begin
4
- require 'zip/zipfilesystem'
5
- rescue
6
- abort "rake development_dependencies"
7
- end
8
-
9
- #-----------------------------------------------------------------------
10
- # Extensions
11
- #-----------------------------------------------------------------------
12
-
13
- if ext_config = Configuration.for_if_exist?('extension') then
14
- namespace :ext do
15
- def current_sqlite_version
16
- ext = Configuration.for('extension').configs.first
17
- path = Pathname.new( ext )
18
- h_path = path.dirname.realpath + "sqlite3.h"
19
- File.open( h_path ) do |f|
20
- f.each_line do |line|
21
- if line =~ /\A#define SQLITE_VERSION\s+/ then
22
- define ,constant ,value = line.split
23
- return value
24
- end
25
- end
26
- end
27
- end
28
-
29
- desc "Build the SQLite extension version #{current_sqlite_version}"
30
- task :build => :clean do
31
- ext_config.configs.each do |extension|
32
- path = Pathname.new(extension)
33
- parts = path.split
34
- conf = parts.last
35
- Dir.chdir(path.dirname) do |d|
36
- ruby conf.to_s
37
- sh "make"
8
+ require 'rake/extensiontask'
9
+ require 'rake/javaextensiontask'
38
10
 
39
- # install into requireable location so specs will run
40
- subdir = "amalgalite/#{RUBY_VERSION.sub(/\.\d$/,'')}"
41
- dest_dir = Amalgalite::Paths.lib_path( subdir )
42
- mkdir_p dest_dir, :verbose => true
43
- cp "amalgalite3.#{Config::CONFIG['DLEXT']}", dest_dir, :verbose => true
44
- end
45
- end
46
- end
11
+ if RUBY_PLATFORM == "java" then
47
12
 
48
- def myruby
49
- require 'rbconfig'
50
- x = File.join(
51
- RbConfig::CONFIG['bindir'],
52
- RbConfig::CONFIG['ruby_install_name']
53
- )
54
- #puts "myruby = #{x}"
55
- return x
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
56
17
  end
57
18
 
58
- def build_win( version = "1.8.7" )
59
- ext_config = Configuration.for("extension")
60
- rbconfig = ext_config.cross_rbconfig["rbconfig-#{version}"]
61
- raise ArgumentError, "No cross compiler for version #{version}, we have #{ext_config.cross_rbconfig.keys.join(",")}" unless rbconfig
62
- Amalgalite::GEM_SPEC.extensions.each do |extension|
63
- path = Pathname.new(extension)
64
- parts = path.split
65
- conf = parts.last
66
- rvm = File.expand_path( "~/.rvm/bin/rvm" )
67
- Dir.chdir(path.dirname) do |d|
68
- if File.exist?( "Makefile" ) then
69
- sh "make clean distclean"
70
- end
71
- cp "#{rbconfig}", "rbconfig.rb"
72
- rubylib = ENV['RUBYLIB']
73
- ENV['RUBYLIB'] = "."
74
- sh %[ #{rvm} #{version} -S extconf.rb #{myruby} ]
75
- ENV['RUBYLIB'] = rubylib
76
- sh "make"
77
- end
78
- end
79
- end
19
+ else
80
20
 
81
- win_builds = []
82
- ext_config.cross_rbconfig.keys.each do |v|
83
- s = v.split("-").last
84
- desc "Build the extension for windows version #{s}"
85
- win_bname = "build_win-#{s}"
86
- win_builds << win_bname
87
- task win_bname => :clean do
88
- build_win( s )
89
- end
90
- 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
91
25
 
92
- task :clean do
93
- ext_config.configs.each do |extension|
94
- path = Pathname.new(extension)
95
- parts = path.split
96
- conf = parts.last
97
- Dir.chdir(path.dirname) do |d|
98
- if File.exist?( "Makefile" ) then
99
- sh "make clean"
100
- end
101
- rm_f "rbconfig.rb"
102
- end
103
- end
104
- end
105
-
106
- desc "List the sqlite api calls that are not implemented"
107
- task :todo do
108
-
109
- not_implementing = %w[
110
- sqlite3_exec
111
- sqlite3_open
112
- sqlite3_os_end
113
- sqlite3_os_init
114
- sqlite3_malloc
115
- sqlite3_realloc
116
- sqlite3_free
117
- sqlite3_get_table
118
- sqlite3_free_table
119
- sqlite3_key
120
- sqlite3_rekey
121
- sqlite3_next_stmt
122
- sqlite3_release_memory
123
- sqlite3_sleep
124
- sqlite3_snprintf
125
- sqlite3_vmprintf
126
- sqlite3_strnicmp
127
- sqlite3_test_control
128
- sqlite3_unlock_notify
129
- sqlite3_vfs_find
130
- sqlite3_vfs_register
131
- sqlite3_vfs_unregister
132
- ]
133
-
134
- sqlite_h = File.join( *%w[ ext amalgalite sqlite3.h ] )
135
- api_todo = {}
136
- IO.readlines( sqlite_h ).each do |line|
137
- if line =~ /\ASQLITE_API/ then
138
- if line !~ /SQLITE_DEPRECATED/ and line !~ /SQLITE_EXPERIMENTAL/ then
139
- if md = line.match( /(sqlite3_[^(\s]+)\(/ ) then
140
- next if not_implementing.include?(md.captures[0])
141
- api_todo[md.captures[0]] = true
142
- end
143
- end
144
- end
145
- end
146
-
147
- Dir.glob("ext/amalgalite/amalgalite*.c").each do |am_file|
148
- IO.readlines( am_file ).each do |am_line|
149
- if md = am_line.match( /(sqlite3_[^(\s]+)\(/ ) then
150
- api_todo.delete( md.captures[0] )
151
- end
152
- end
153
- end
154
-
155
- puts "#{api_todo.keys.size} functions to still implement"
156
- puts api_todo.keys.sort.join("\n")
157
- end
158
-
159
- task :clobber do
160
- ext_config.configs.each do |extension|
161
- path = Pathname.new(extension)
162
- parts = path.split
163
- conf = parts.last
164
- Dir.chdir(path.dirname) do |d|
165
- if File.exist?( "Makefile") then
166
- sh "make distclean"
167
- end
168
- rm_f "rbconfig.rb"
169
- end
170
- end
171
- end
172
-
173
- desc "Download and integrate the next version of sqlite (use VERSION=x.y.z)"
174
- task :update_sqlite do
175
- require 'uri'
176
- require 'net/http'
177
- parts = ENV['VERSION'].split(".")
178
- next_version = [ parts.shift.to_s ]
179
- parts.each do |p|
180
- next_version << "#{"%02d" % p }"
181
- end
182
- next_version << "00" if next_version.size == 3
183
-
184
- next_version = next_version.join('')
185
-
186
- raise "VERSION env variable must be set" unless next_version
187
- url = ::URI.parse("http://sqlite.org/sqlite-amalgamation-#{next_version}.zip")
188
- puts "downloading #{url.to_s} ..."
189
- file = "tmp/#{File.basename( url.path ) }"
190
- FileUtils.mkdir "tmp" unless File.directory?( "tmp" )
191
- File.open( file, "wb+") do |f|
192
- res = Net::HTTP.get_response( url )
193
- f.write( res.body )
194
- end
195
-
196
- puts "extracting..."
197
- upstream_files = %w[ sqlite3.h sqlite3.c sqlite3ext.h ]
198
- Zip::ZipInputStream.open( file ) do |io|
199
- loop do
200
- entry = io.get_next_entry
201
- break unless entry
202
- bname = File.basename( entry.name )
203
- if upstream_files.include?( bname ) then
204
- dest_file = File.join( "ext", "amalgalite", bname )
205
- puts "updating #{dest_file}"
206
- entry.extract( dest_file ) { true }
207
- end
208
- end
209
- 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
210
29
  end
211
30
  end
31
+
32
+ task :test_requirements => :compile
33
+ rescue LoadError
34
+ This.task_warning( 'extension' )
212
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}/"]