Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 118 lines (109 sloc) 3.522 kb
c3431a1 @copiousfreetime core library in extension working
authored
1 require 'tasks/config'
2 require 'pathname'
f16060b @copiousfreetime update to upstream SQLite v3.6.3
authored
3 require 'zlib'
4 require 'archive/tar/minitar'
c3431a1 @copiousfreetime core library in extension working
authored
5
6 #-----------------------------------------------------------------------
7 # Extensions
8 #-----------------------------------------------------------------------
9
10 if ext_config = Configuration.for_if_exist?('extension') then
827e38e @copiousfreetime progress made on database and statement
authored
11 namespace :ext do
429df0d @copiousfreetime update to sqlite 3.6.6.2
authored
12 def current_sqlite_version
13 ext = Configuration.for('extension').configs.first
14 path = Pathname.new( ext )
15 h_path = path.dirname.realpath + "sqlite3.h"
16 File.open( h_path ) do |f|
17 f.each_line do |line|
18 if line =~ /\A#define SQLITE_VERSION\s+/ then
19 define ,constant ,value = line.split
20 return value
21 end
22 end
23 end
24 end
25
26 desc "Build the SQLite extension version #{current_sqlite_version}"
32791aa @copiousfreetime initial import
authored
27 task :build do
c3431a1 @copiousfreetime core library in extension working
authored
28 ext_config.configs.each do |extension|
29 path = Pathname.new(extension)
30 parts = path.split
31 conf = parts.last
32 Dir.chdir(path.dirname) do |d|
33 ruby conf.to_s
5376cfc @copiousfreetime Convert to using mkmf instead of mkrf
authored
34 #sh "rake default"
35 sh "make"
32791aa @copiousfreetime initial import
authored
36 end
c3431a1 @copiousfreetime core library in extension working
authored
37 end
38 end
32791aa @copiousfreetime initial import
authored
39
26f46d8 @copiousfreetime adding support for windows
authored
40 desc "Build the extensions for windows"
41 task :build_win => :clobber do
42 ext_config.configs.each do |extension|
43 path = Pathname.new( extension )
adb3a4b @copiousfreetime fix variable path spelling
authored
44 parts = path.split
26f46d8 @copiousfreetime adding support for windows
authored
45 conf = parts.last
c176747 @copiousfreetime move rbconfig-mingw out to parent
authored
46 mingw_rbconfig = path.dirname.parent.realpath + "rbconfig-mingw.rb"
26f46d8 @copiousfreetime adding support for windows
authored
47 Dir.chdir( path.dirname ) do |d|
c176747 @copiousfreetime move rbconfig-mingw out to parent
authored
48 cp mingw_rbconfig, "rbconfig.rb"
26f46d8 @copiousfreetime adding support for windows
authored
49 sh "ruby -I. extconf.rb"
50 sh "make"
7f379f5 @copiousfreetime remove rbconfig.rb after generating mingw makefile
authored
51 rm_f "rbconfig.rb"
26f46d8 @copiousfreetime adding support for windows
authored
52 end
53 end
54 end
55
c3431a1 @copiousfreetime core library in extension working
authored
56 task :clean do
57 ext_config.configs.each do |extension|
58 path = Pathname.new(extension)
59 parts = path.split
60 conf = parts.last
61 Dir.chdir(path.dirname) do |d|
5376cfc @copiousfreetime Convert to using mkmf instead of mkrf
authored
62 #sh "rake clean"
63 sh "make clean"
7f379f5 @copiousfreetime remove rbconfig.rb after generating mingw makefile
authored
64 rm_f "rbconfig.rb"
c3431a1 @copiousfreetime core library in extension working
authored
65 end
66 end
67 end
68
69 task :clobber do
70 ext_config.configs.each do |extension|
71 path = Pathname.new(extension)
72 parts = path.split
73 conf = parts.last
74 Dir.chdir(path.dirname) do |d|
5376cfc @copiousfreetime Convert to using mkmf instead of mkrf
authored
75 #sh "rake clobber"
26f46d8 @copiousfreetime adding support for windows
authored
76 if File.exist?( "Makefile") then
77 sh "make distclean"
78 end
7f379f5 @copiousfreetime remove rbconfig.rb after generating mingw makefile
authored
79 rm_f "rbconfig.rb"
c3431a1 @copiousfreetime core library in extension working
authored
80 end
81 end
82 end
f16060b @copiousfreetime update to upstream SQLite v3.6.3
authored
83
429df0d @copiousfreetime update to sqlite 3.6.6.2
authored
84 desc "Download and integrate the next version of sqlite (use VERSION=x.y.z)"
f16060b @copiousfreetime update to upstream SQLite v3.6.3
authored
85 task :update_sqlite do
86 next_version = ENV['VERSION']
2af9404 @copiousfreetime update to sqlite3 3.6.4
authored
87 raise "VERSION env variable must be set" unless next_version
f16060b @copiousfreetime update to upstream SQLite v3.6.3
authored
88 puts "downloading ..."
89 url = URI.parse("http://sqlite.org/sqlite-amalgamation-#{next_version}.tar.gz")
90 file = "tmp/#{File.basename( url.path ) }"
2af9404 @copiousfreetime update to sqlite3 3.6.4
authored
91 FileUtils.mkdir "tmp" unless File.directory?( "tmp" )
f16060b @copiousfreetime update to upstream SQLite v3.6.3
authored
92 File.open( file, "wb+") do |f|
93 res = Net::HTTP.get_response( url )
94 f.write( res.body )
95 end
96
97 puts "extracting..."
98 upstream_files = %w[ sqlite3.h sqlite3.c sqlite3ext.h ]
99 Zlib::GzipReader.open( file ) do |tgz|
100 Archive::Tar::Minitar::Reader.open( tgz ) do |tar|
101 tar.each_entry do |entry|
102 bname = File.basename( entry.full_name )
103 if upstream_files.include?( bname ) then
104 dest_file = File.join( "ext", bname )
105 puts "updating #{ dest_file }"
106 File.open( dest_file, "wb" ) do |df|
107 while bytes = entry.read do
108 df.write bytes
109 end
110 end
111 end
112 end
113 end
114 end
115 end
c3431a1 @copiousfreetime core library in extension working
authored
116 end
117 end
Something went wrong with that request. Please try again.