pg 0.12.0 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.sig +2 -0
  3. data/BSDL +22 -0
  4. data/ChangeLog +1504 -11
  5. data/Contributors.rdoc +7 -0
  6. data/History.rdoc +181 -3
  7. data/LICENSE +12 -14
  8. data/Manifest.txt +29 -15
  9. data/{BSD → POSTGRES} +0 -0
  10. data/{README.OS_X.rdoc → README-OS_X.rdoc} +0 -0
  11. data/{README.windows.rdoc → README-Windows.rdoc} +0 -0
  12. data/README.ja.rdoc +10 -3
  13. data/README.rdoc +54 -28
  14. data/Rakefile +53 -26
  15. data/Rakefile.cross +235 -196
  16. data/ext/errorcodes.def +931 -0
  17. data/ext/errorcodes.rb +45 -0
  18. data/ext/errorcodes.txt +463 -0
  19. data/ext/extconf.rb +37 -7
  20. data/ext/gvl_wrappers.c +19 -0
  21. data/ext/gvl_wrappers.h +211 -0
  22. data/ext/pg.c +317 -4277
  23. data/ext/pg.h +124 -21
  24. data/ext/pg_connection.c +3642 -0
  25. data/ext/pg_errors.c +89 -0
  26. data/ext/pg_result.c +920 -0
  27. data/lib/pg/connection.rb +86 -0
  28. data/lib/pg/constants.rb +11 -0
  29. data/lib/pg/exceptions.rb +11 -0
  30. data/lib/pg/result.rb +16 -0
  31. data/lib/pg.rb +26 -43
  32. data/sample/array_insert.rb +20 -0
  33. data/sample/async_api.rb +21 -24
  34. data/sample/async_copyto.rb +2 -2
  35. data/sample/async_mixed.rb +56 -0
  36. data/sample/check_conn.rb +21 -0
  37. data/sample/copyfrom.rb +1 -1
  38. data/sample/copyto.rb +1 -1
  39. data/sample/cursor.rb +2 -2
  40. data/sample/disk_usage_report.rb +186 -0
  41. data/sample/issue-119.rb +94 -0
  42. data/sample/losample.rb +6 -6
  43. data/sample/minimal-testcase.rb +17 -0
  44. data/sample/notify_wait.rb +51 -22
  45. data/sample/pg_statistics.rb +294 -0
  46. data/sample/replication_monitor.rb +231 -0
  47. data/sample/test_binary_values.rb +4 -6
  48. data/sample/wal_shipper.rb +434 -0
  49. data/sample/warehouse_partitions.rb +320 -0
  50. data/spec/lib/helpers.rb +70 -23
  51. data/spec/pg/connection_spec.rb +1128 -0
  52. data/spec/{pgresult_spec.rb → pg/result_spec.rb} +142 -47
  53. data/spec/pg_spec.rb +44 -0
  54. data.tar.gz.sig +0 -0
  55. metadata +145 -100
  56. metadata.gz.sig +0 -0
  57. data/GPL +0 -340
  58. data/ext/compat.c +0 -541
  59. data/ext/compat.h +0 -184
  60. data/misc/openssl-pg-segfault.rb +0 -31
  61. data/sample/psql.rb +0 -1181
  62. data/sample/psqlHelp.rb +0 -158
  63. data/sample/test1.rb +0 -60
  64. data/sample/test2.rb +0 -44
  65. data/sample/test4.rb +0 -71
  66. data/spec/m17n_spec.rb +0 -151
  67. data/spec/pgconn_spec.rb +0 -643
data/Rakefile.cross CHANGED
@@ -6,229 +6,268 @@ require 'rbconfig'
6
6
  require 'rake/clean'
7
7
  require 'rake/extensiontask'
8
8
  require 'rake/extensioncompiler'
9
+ require 'ostruct'
9
10
 
10
11
  MISCDIR = BASEDIR + 'misc'
11
12
 
12
13
  NUM_CPUS = if File.exist?('/proc/cpuinfo')
13
- File.read('/proc/cpuinfo').scan('processor').length
14
+ File.read('/proc/cpuinfo').scan('processor').length
14
15
  elsif RUBY_PLATFORM.include?( 'darwin' )
15
- `system_profiler SPHardwareDataType | grep 'Cores' | awk '{print $5}'`.chomp
16
+ `system_profiler SPHardwareDataType | grep 'Cores' | awk '{print $5}'`.chomp
16
17
  else
17
- 1
18
+ 1
18
19
  end
19
20
 
20
- # Cross-compilation constants
21
- OPENSSL_VERSION = ENV['OPENSSL_VERSION'] || '1.0.0e'
22
- POSTGRESQL_VERSION = ENV['POSTGRESQL_VERSION'] || '9.1.1'
21
+ class CrossLibrary < OpenStruct
22
+ include Rake::DSL
23
23
 
24
- COMPILE_HOME = Pathname( "./build" ).expand_path
25
- STATIC_SOURCESDIR = COMPILE_HOME + 'sources'
26
- STATIC_BUILDDIR = COMPILE_HOME + 'builds'
24
+ def initialize(for_platform, openssl_config)
25
+ super()
27
26
 
28
- # Static OpenSSL build vars
29
- STATIC_OPENSSL_BUILDDIR = STATIC_BUILDDIR + "openssl-#{OPENSSL_VERSION}"
27
+ self.for_platform = for_platform
28
+ self.openssl_config = openssl_config
30
29
 
31
- OPENSSL_SOURCE_URI =
32
- URI( "http://www.openssl.org/source/openssl-#{OPENSSL_VERSION}.tar.gz" )
33
- OPENSSL_TARBALL = STATIC_SOURCESDIR + File.basename( OPENSSL_SOURCE_URI.path )
34
- OPENSSL_MAKEFILE = STATIC_OPENSSL_BUILDDIR + 'Makefile'
30
+ # Cross-compilation constants
31
+ self.openssl_version = ENV['OPENSSL_VERSION'] || '1.0.1e'
32
+ self.postgresql_version = ENV['POSTGRESQL_VERSION'] || '9.2.3'
33
+
34
+ self.compile_home = Pathname( "./build" ).expand_path
35
+ self.static_sourcesdir = compile_home + 'sources'
36
+ self.static_builddir = compile_home + 'builds' + for_platform
35
37
 
36
- LIBSSLEAY32 = STATIC_OPENSSL_BUILDDIR + 'libssleay32.a'
37
- LIBEAY32 = STATIC_OPENSSL_BUILDDIR + 'libeay32.a'
38
+ # Static OpenSSL build vars
39
+ self.static_openssl_builddir = static_builddir + "openssl-#{openssl_version}"
40
+
41
+ self.openssl_source_uri =
42
+ URI( "http://www.openssl.org/source/openssl-#{openssl_version}.tar.gz" )
43
+ self.openssl_tarball = static_sourcesdir + File.basename( openssl_source_uri.path )
44
+ self.openssl_makefile = static_openssl_builddir + 'Makefile'
45
+
46
+ self.libssleay32 = static_openssl_builddir + 'libssleay32.a'
47
+ self.libeay32 = static_openssl_builddir + 'libeay32.a'
48
+
49
+ self.openssl_patches = Rake::FileList[ (MISCDIR + "openssl-#{openssl_version}.*.patch").to_s ]
38
50
 
39
- OPENSSL_PATCHES = Rake::FileList[ MISCDIR + "openssl-#{OPENSSL_VERSION}.*.patch" ]
51
+ # Static PostgreSQL build vars
52
+ self.static_postgresql_builddir = static_builddir + "postgresql-#{postgresql_version}"
53
+ self.postgresql_source_uri = begin
54
+ uristring = "http://ftp.postgresql.org/pub/source/v%s/postgresql-%s.tar.bz2" %
55
+ [ postgresql_version, postgresql_version ]
56
+ URI( uristring )
57
+ end
58
+ self.postgresql_tarball = static_sourcesdir + File.basename( postgresql_source_uri.path )
59
+
60
+ self.static_postgresql_srcdir = static_postgresql_builddir + 'src'
61
+ self.static_postgresql_libdir = static_postgresql_srcdir + 'interfaces/libpq'
62
+ self.static_postgresql_incdir = static_postgresql_srcdir + 'include'
63
+
64
+ self.postgresql_global_makefile = static_postgresql_srcdir + 'Makefile.global'
65
+ self.postgresql_shlib_makefile = static_postgresql_srcdir + 'Makefile.shlib'
66
+ self.postgresql_shlib_mf_orig = static_postgresql_srcdir + 'Makefile.shlib.orig'
67
+ self.postgresql_lib = static_postgresql_libdir + 'libpq.a'
68
+ self.postgresql_patches = Rake::FileList[ (MISCDIR + "postgresql-#{postgresql_version}.*.patch").to_s ]
40
69
 
41
- # Static PostgreSQL build vars
42
- STATIC_POSTGRESQL_BUILDDIR = STATIC_BUILDDIR + "postgresql-#{POSTGRESQL_VERSION}"
43
- POSTGRESQL_SOURCE_URI = begin
44
- uristring = "http://ftp9.us.postgresql.org/pub/mirrors/postgresql/source/" +
45
- "v%s/postgresql-%s.tar.bz2" % [ POSTGRESQL_VERSION, POSTGRESQL_VERSION ]
46
- URI( uristring )
47
- end
48
- POSTGRESQL_TARBALL = STATIC_SOURCESDIR + File.basename( POSTGRESQL_SOURCE_URI.path )
49
-
50
- STATIC_POSTGRESQL_SRCDIR = STATIC_POSTGRESQL_BUILDDIR + 'src'
51
- STATIC_POSTGRESQL_LIBDIR = STATIC_POSTGRESQL_SRCDIR + 'interfaces/libpq'
52
- STATIC_POSTGRESQL_INCDIR = STATIC_POSTGRESQL_SRCDIR + 'include'
53
-
54
- POSTGRESQL_GLOBAL_MAKEFILE = STATIC_POSTGRESQL_SRCDIR + 'Makefile.global'
55
- POSTGRESQL_SHLIB_MAKEFILE = STATIC_POSTGRESQL_SRCDIR + 'Makefile.shlib'
56
- POSTGRESQL_SHLIB_MF_ORIG = STATIC_POSTGRESQL_SRCDIR + 'Makefile.shlib.orig'
57
- POSTGRESQL_LIB = STATIC_POSTGRESQL_LIBDIR + 'libpq.a'
58
-
59
- CROSS_PREFIX = Rake::ExtensionCompiler.mingw_host
60
-
61
-
62
- # clean intermediate files and folders
63
- CLEAN.include( STATIC_BUILDDIR.to_s )
64
-
65
-
66
- ENV['RUBY_CC_VERSION'] ||= '1.8.7:1.9.3'
67
-
68
- def download(url, save_to)
69
- part = save_to+".part"
70
- sh "wget #{url.to_s.inspect} -O #{part.inspect} || curl #{url.to_s.inspect} -o #{part.inspect}"
71
- FileUtils.mv part, save_to
72
- end
73
-
74
- def run(*args)
75
- sh *args
76
- end
70
+ # Use rake-compilers config.yml to determine the toolchain that was used
71
+ # to build Ruby for this platform.
72
+ self.host_platform = begin
73
+ config_file = YAML.load_file(File.expand_path("~/.rake-compiler/config.yml"))
74
+ _, rbfile = config_file.find{|key, fname| key.start_with?("rbconfig-#{for_platform}-") }
75
+ IO.read(rbfile).match(/CONFIG\["host"\] = "(.*)"/)[1]
76
+ rescue
77
+ nil
78
+ end
77
79
 
78
- #####################################################################
79
- ### C R O S S - C O M P I L A T I O N - T A S K S
80
- #####################################################################
81
80
 
81
+ # clean intermediate files and folders
82
+ CLEAN.include( static_builddir.to_s )
82
83
 
83
- directory STATIC_SOURCESDIR.to_s
84
-
85
- #
86
- # Static OpenSSL build tasks
87
- #
88
- directory STATIC_OPENSSL_BUILDDIR.to_s
89
-
90
- # openssl source file should be stored there
91
- file OPENSSL_TARBALL => STATIC_SOURCESDIR do |t|
92
- download( OPENSSL_SOURCE_URI, t.name )
93
- end
94
-
95
- # Extract the openssl builds
96
- file STATIC_OPENSSL_BUILDDIR => OPENSSL_TARBALL do |t|
97
- puts "extracting %s to %s" % [ OPENSSL_TARBALL, STATIC_OPENSSL_BUILDDIR.parent ]
98
- STATIC_OPENSSL_BUILDDIR.mkpath
99
- run 'tar', '-xzf', OPENSSL_TARBALL.to_s, '-C', STATIC_OPENSSL_BUILDDIR.parent.to_s
100
- OPENSSL_MAKEFILE.unlink if OPENSSL_MAKEFILE.exist?
101
-
102
- OPENSSL_PATCHES.each do |patchfile|
103
- puts " applying patch #{patchfile}..."
104
- run 'patch', '-Np1', '-d', STATIC_OPENSSL_BUILDDIR.to_s,
105
- '-i', File.expand_path( patchfile, BASEDIR )
106
- end
107
- end
108
-
109
- CMD_PRELUDE = [
110
- 'env',
111
- "CC=#{CROSS_PREFIX}-gcc",
112
- "CFLAGS=-DDSO_WIN32",
113
- "AR=#{CROSS_PREFIX}-ar",
114
- "RANLIB=#{CROSS_PREFIX}-ranlib"
115
- ]
116
-
117
-
118
- # generate the makefile in a clean build location
119
- file OPENSSL_MAKEFILE => STATIC_OPENSSL_BUILDDIR do |t|
120
- Dir.chdir( STATIC_OPENSSL_BUILDDIR ) do
121
- cmd = CMD_PRELUDE.dup
122
- cmd << "./Configure" << 'mingw'
123
-
124
- run( *cmd )
125
- end
126
- end
127
-
128
- desc "compile static openssl libraries"
129
- task :openssl_libs => [ LIBSSLEAY32, LIBEAY32 ]
130
84
 
131
- task :compile_static_openssl => OPENSSL_MAKEFILE do |t|
132
- Dir.chdir( STATIC_OPENSSL_BUILDDIR ) do
133
- cmd = CMD_PRELUDE.dup
134
- cmd << 'make' << "-j#{NUM_CPUS}" << 'build_libs'
85
+ ENV['RUBY_CC_VERSION'] ||= '1.8.7:1.9.3:2.0.0'
135
86
 
136
- run( *cmd )
137
- end
87
+ def download(url, save_to)
88
+ part = save_to+".part"
89
+ sh "wget #{url.to_s.inspect} -O #{part.inspect} || curl #{url.to_s.inspect} -o #{part.inspect}"
90
+ FileUtils.mv part, save_to
91
+ end
92
+
93
+ def run(*args)
94
+ sh *args
95
+ end
96
+
97
+ #####################################################################
98
+ ### C R O S S - C O M P I L A T I O N - T A S K S
99
+ #####################################################################
100
+
101
+
102
+ directory static_sourcesdir.to_s
103
+
104
+ #
105
+ # Static OpenSSL build tasks
106
+ #
107
+ directory static_openssl_builddir.to_s
108
+
109
+ # openssl source file should be stored there
110
+ file openssl_tarball => static_sourcesdir do |t|
111
+ download( openssl_source_uri, t.name )
112
+ end
113
+
114
+ # Extract the openssl builds
115
+ file static_openssl_builddir => openssl_tarball do |t|
116
+ puts "extracting %s to %s" % [ openssl_tarball, static_openssl_builddir.parent ]
117
+ static_openssl_builddir.mkpath
118
+ run 'tar', '-xzf', openssl_tarball.to_s, '-C', static_openssl_builddir.parent.to_s
119
+ openssl_makefile.unlink if openssl_makefile.exist?
120
+
121
+ openssl_patches.each do |patchfile|
122
+ puts " applying patch #{patchfile}..."
123
+ run 'patch', '-Np1', '-d', static_openssl_builddir.to_s,
124
+ '-i', File.expand_path( patchfile, BASEDIR )
125
+ end
126
+ end
127
+
128
+ self.cmd_prelude = [
129
+ 'env',
130
+ "CC=#{host_platform}-gcc",
131
+ "CFLAGS=-DDSO_WIN32",
132
+ "AR=#{host_platform}-ar",
133
+ "RANLIB=#{host_platform}-ranlib"
134
+ ]
135
+
136
+
137
+ # generate the makefile in a clean build location
138
+ file openssl_makefile => static_openssl_builddir do |t|
139
+ Dir.chdir( static_openssl_builddir ) do
140
+ cmd = cmd_prelude.dup
141
+ cmd << "./Configure" << openssl_config
142
+
143
+ run( *cmd )
144
+ end
145
+ end
146
+
147
+ desc "compile static openssl libraries"
148
+ task :openssl_libs => [ libssleay32, libeay32 ]
149
+
150
+ task :compile_static_openssl => openssl_makefile do |t|
151
+ Dir.chdir( static_openssl_builddir ) do
152
+ cmd = cmd_prelude.dup
153
+ cmd << 'make' << "-j#{NUM_CPUS}" << 'build_libs'
154
+
155
+ run( *cmd )
156
+ end
157
+ end
158
+
159
+ desc "compile static #{libeay32}"
160
+ file libeay32 => :compile_static_openssl do |t|
161
+ FileUtils.cp( static_openssl_builddir + 'libcrypto.a', libeay32.to_s )
162
+ end
163
+
164
+ desc "compile static #{libssleay32}"
165
+ file libssleay32 => :compile_static_openssl do |t|
166
+ FileUtils.cp( static_openssl_builddir + 'libssl.a', libssleay32.to_s )
167
+ end
168
+
169
+
170
+
171
+ #
172
+ # Static PostgreSQL build tasks
173
+ #
174
+ directory static_postgresql_builddir.to_s
175
+
176
+
177
+ # postgresql source file should be stored there
178
+ file postgresql_tarball => static_sourcesdir do |t|
179
+ download( postgresql_source_uri, t.name )
180
+ end
181
+
182
+ # Extract the postgresql sources
183
+ file static_postgresql_builddir => postgresql_tarball do |t|
184
+ puts "extracting %s to %s" % [ postgresql_tarball, static_postgresql_builddir.parent ]
185
+ static_postgresql_builddir.mkpath
186
+ run 'tar', '-xjf', postgresql_tarball.to_s, '-C', static_postgresql_builddir.parent.to_s
187
+ mv postgresql_shlib_makefile, postgresql_shlib_mf_orig
188
+
189
+ postgresql_patches.each do |patchfile|
190
+ puts " applying patch #{patchfile}..."
191
+ run 'patch', '-Np1', '-d', static_postgresql_builddir.to_s,
192
+ '-i', File.expand_path( patchfile, BASEDIR )
193
+ end
194
+ end
195
+
196
+ # generate the makefile in a clean build location
197
+ file postgresql_global_makefile => [ static_postgresql_builddir, :openssl_libs ] do |t|
198
+ options = [
199
+ "--target=#{host_platform}",
200
+ "--host=#{host_platform}",
201
+ '--with-openssl',
202
+ '--without-zlib',
203
+ '--disable-shared',
204
+ ]
205
+
206
+ Dir.chdir( static_postgresql_builddir ) do
207
+ configure_path = static_postgresql_builddir + 'configure'
208
+ cmd = [ configure_path.to_s, *options ]
209
+ cmd << "CFLAGS=-L#{static_openssl_builddir}"
210
+ cmd << "LDFLAGS=-L#{static_openssl_builddir}"
211
+ cmd << "LDFLAGS_SL=-L#{static_openssl_builddir}"
212
+ cmd << "LIBS=-lwsock32 -lgdi32"
213
+ cmd << "CPPFLAGS=-I#{static_openssl_builddir}/include"
214
+
215
+ run( *cmd )
216
+ end
217
+ end
218
+
219
+
220
+ # patch the Makefile.shlib -- depend on the build dir so it's only
221
+ # rewritten if the tarball is re-extracted.
222
+ file postgresql_shlib_makefile => postgresql_shlib_mf_orig do |t|
223
+ tf = Tempfile.new( postgresql_shlib_makefile.basename.to_s )
224
+ postgresql_shlib_mf_orig.open( File::RDONLY ) do |ifh|
225
+ ifh.each_line do |line|
226
+ tf.print( line.sub(/^(\s*haslibarule\s*=\s*yes)/, "# \\1 ") )
227
+ end
228
+ end
229
+ tf.close
230
+
231
+ FileUtils.mv( tf.path, t.name, :verbose => $puts )
232
+ end
233
+
234
+
235
+ # make libpq.a
236
+ task postgresql_lib => [ postgresql_global_makefile, postgresql_shlib_makefile ] do |t|
237
+ Dir.chdir( postgresql_lib.dirname ) do
238
+ sh 'make', "-j#{NUM_CPUS}", postgresql_lib.basename.to_s, 'PORTNAME=win32'
239
+ end
240
+ end
241
+
242
+
243
+ #desc 'compile static libpg.a'
244
+ task :static_libpq => postgresql_lib
245
+ end
138
246
  end
139
247
 
140
- desc "compile static #{LIBEAY32}"
141
- file LIBEAY32 => :compile_static_openssl do |t|
142
- FileUtils.cp( STATIC_OPENSSL_BUILDDIR + 'libcrypto.a', LIBEAY32.to_s )
143
- end
144
-
145
- desc "compile static #{LIBSSLEAY32}"
146
- file LIBSSLEAY32 => :compile_static_openssl do |t|
147
- FileUtils.cp( STATIC_OPENSSL_BUILDDIR + 'libssl.a', LIBSSLEAY32.to_s )
148
- end
149
-
150
-
151
-
152
- #
153
- # Static PostgreSQL build tasks
154
- #
155
- directory STATIC_POSTGRESQL_BUILDDIR.to_s
156
-
157
-
158
- # postgresql source file should be stored there
159
- file POSTGRESQL_TARBALL => STATIC_SOURCESDIR do |t|
160
- download( POSTGRESQL_SOURCE_URI, t.name )
161
- end
162
-
163
- # Extract the postgresql sources
164
- file STATIC_POSTGRESQL_BUILDDIR => POSTGRESQL_TARBALL do |t|
165
- puts "extracting %s to %s" % [ POSTGRESQL_TARBALL, STATIC_POSTGRESQL_BUILDDIR.parent ]
166
- STATIC_POSTGRESQL_BUILDDIR.mkpath
167
- run 'tar', '-xjf', POSTGRESQL_TARBALL.to_s, '-C', STATIC_POSTGRESQL_BUILDDIR.parent.to_s
168
- mv POSTGRESQL_SHLIB_MAKEFILE, POSTGRESQL_SHLIB_MF_ORIG
169
- end
170
-
171
- # generate the makefile in a clean build location
172
- file POSTGRESQL_GLOBAL_MAKEFILE => [ STATIC_POSTGRESQL_BUILDDIR, :openssl_libs ] do |t|
173
- options = [
174
- '--target=i386-mingw32',
175
- "--host=#{Rake::ExtensionCompiler.mingw_host}",
176
- '--with-openssl',
177
- '--without-zlib',
178
- '--disable-shared',
179
- ]
180
-
181
- Dir.chdir( STATIC_POSTGRESQL_BUILDDIR ) do
182
- configure_path = STATIC_POSTGRESQL_BUILDDIR + 'configure'
183
- cmd = [ configure_path.to_s, *options ]
184
- cmd << "CFLAGS=-L#{STATIC_OPENSSL_BUILDDIR}"
185
- cmd << "LDFLAGS=-L#{STATIC_OPENSSL_BUILDDIR}"
186
- cmd << "LDFLAGS_SL=-L#{STATIC_OPENSSL_BUILDDIR}"
187
- cmd << "LIBS=-lwsock32 -lws2_32 -lgdi32"
188
- cmd << "CPPFLAGS=-I#{STATIC_OPENSSL_BUILDDIR}/include"
189
-
190
- run( *cmd )
191
- end
192
- end
193
-
194
-
195
- # patch the Makefile.shlib -- depend on the build dir so it's only
196
- # rewritten if the tarball is re-extracted.
197
- file POSTGRESQL_SHLIB_MAKEFILE => POSTGRESQL_SHLIB_MF_ORIG do |t|
198
- tf = Tempfile.new( POSTGRESQL_SHLIB_MAKEFILE.basename )
199
- POSTGRESQL_SHLIB_MF_ORIG.open( File::RDONLY ) do |ifh|
200
- ifh.each_line do |line|
201
- tf.print( line.sub(/^(\s*haslibarule\s*=\s*yes)/, "# \\1 ") )
202
- end
203
- end
204
- tf.close
205
-
206
- FileUtils.mv( tf.path, t.name, :verbose => $puts )
207
- end
208
-
209
-
210
- # make libpq.a
211
- task POSTGRESQL_LIB => [ POSTGRESQL_GLOBAL_MAKEFILE, POSTGRESQL_SHLIB_MAKEFILE ] do |t|
212
- Dir.chdir( POSTGRESQL_LIB.dirname ) do
213
- sh 'make', "-j#{NUM_CPUS}", POSTGRESQL_LIB.basename.to_s, 'PORTNAME=win32'
214
- end
248
+ if File.exist?(File.expand_path("~/.rake-compiler/config.yml"))
249
+ CrossLibraries = [
250
+ ['i386-mingw32', 'mingw'],
251
+ ['x64-mingw32', 'mingw64'],
252
+ ].map do |platform, openssl_config|
253
+ CrossLibrary.new platform, openssl_config
254
+ end
255
+ else
256
+ $stderr.puts "Cross-compilation disabled -- rake-compiler not properly installed"
257
+ CrossLibraries = []
215
258
  end
216
259
 
217
-
218
- #desc 'compile static libpg.a'
219
- task :static_libpq => POSTGRESQL_LIB
220
-
221
260
  desc 'cross compile pg for win32'
222
261
  task :cross do
223
- ENV['CROSS_COMPILING'] = 'yes'
262
+ ENV['CROSS_COMPILING'] = 'yes'
224
263
  end
225
264
  task :cross => [ :mingw32, :static_libpq ]
226
265
 
227
266
  task :mingw32 do
228
- # Use Rake::ExtensionCompiler helpers to find the proper host
229
- unless Rake::ExtensionCompiler.mingw_host then
230
- warn "You need to install mingw32 cross compile functionality to be able to continue."
231
- warn "Please refer to your distribution/package manager documentation about installation."
232
- fail
233
- end
267
+ # Use Rake::ExtensionCompiler helpers to find the proper host
268
+ unless Rake::ExtensionCompiler.mingw_host then
269
+ warn "You need to install mingw32 cross compile functionality to be able to continue."
270
+ warn "Please refer to your distribution/package manager documentation about installation."
271
+ fail
272
+ end
234
273
  end