pg 0.15.0.pre.432 → 0.15.0.pre.454
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/ChangeLog +197 -59
- data/History.rdoc +5 -2
- data/README.ja.rdoc +10 -3
- data/README.rdoc +13 -4
- data/Rakefile +15 -12
- data/Rakefile.cross +194 -169
- data/ext/extconf.rb +1 -0
- data/ext/pg.c +1 -1
- data/ext/pg_connection.c +105 -13
- data/ext/pg_result.c +1 -1
- data/lib/pg.rb +2 -2
- data/lib/pg/connection.rb +0 -14
- data/sample/disk_usage_report.rb +1 -1
- data/sample/pg_statistics.rb +1 -1
- data/sample/replication_monitor.rb +1 -1
- data/spec/lib/helpers.rb +28 -4
- data/spec/pg/connection_spec.rb +27 -8
- metadata +156 -132
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
data/ChangeLog
CHANGED
@@ -1,3 +1,141 @@
|
|
1
|
+
2013-03-16 Lars Kanis <kanis@comcard.de>
|
2
|
+
|
3
|
+
* ext/extconf.rb, ext/pg_connection.c, lib/pg/connection.rb,
|
4
|
+
spec/lib/helpers.rb, spec/pg/connection_spec.rb:
|
5
|
+
Add working Connection#socket_io for Windows and remove this method
|
6
|
+
for platforms that don't support it.
|
7
|
+
|
8
|
+
This also requires to move the code from Ruby to C.
|
9
|
+
|
10
|
+
Use different excudes for :unix and :socket_io.
|
11
|
+
[79d6ab5cf45a] [tip]
|
12
|
+
|
13
|
+
2013-03-14 Lars Kanis <kanis@comcard.de>
|
14
|
+
|
15
|
+
* ext/pg_connection.c:
|
16
|
+
Use #async_exec as alias to #exec on platforms with native threads.
|
17
|
+
|
18
|
+
Since we release the GVL for all blocking function calls, now, #exec
|
19
|
+
has the same behaviour as #async_exec.
|
20
|
+
|
21
|
+
Discussed on: https://groups.google.com/d/msg/ruby-
|
22
|
+
pg/OVVO7XjH7Aw/7UIwi6g10PsJ
|
23
|
+
[ca09386c2aac]
|
24
|
+
|
25
|
+
* ext/pg_connection.c:
|
26
|
+
Test case 'can wait for NOTIFY events' failed before this fix.
|
27
|
+
[266d915dfb86]
|
28
|
+
|
29
|
+
2013-03-13 Lars Kanis <kanis@comcard.de>
|
30
|
+
|
31
|
+
* spec/pg/connection_spec.rb:
|
32
|
+
Mark tests to #socket_io as UNIX-only - they fail on Windows.
|
33
|
+
[1f23c39fb8c8]
|
34
|
+
|
35
|
+
* Rakefile.cross:
|
36
|
+
Print proper message in case that cross compilation is not usable.
|
37
|
+
[307438918863]
|
38
|
+
|
39
|
+
* Rakefile, Rakefile.cross:
|
40
|
+
Merge with https://bitbucket.org/ged/ruby-pg
|
41
|
+
[3230e6c245e0]
|
42
|
+
|
43
|
+
* Rakefile, Rakefile.cross:
|
44
|
+
Add support for cross build for multiple platforms (i386-mingw32 and
|
45
|
+
x64-mingw32).
|
46
|
+
|
47
|
+
Update OpenSSL for cross build to 1.0.1e Update PostgreSQL for cross
|
48
|
+
build to 9.2.3
|
49
|
+
|
50
|
+
Remove -lws2_32 for PostgreSQL build. It fails to compile for
|
51
|
+
x64-mingw32 elsewise.
|
52
|
+
[6a2a1a53dedc]
|
53
|
+
|
54
|
+
2013-03-12 Michael Granger <ged@FaerieMUD.org>
|
55
|
+
|
56
|
+
* Rakefile.cross:
|
57
|
+
Bump PostgreSQL/OpenSSL versions for the binary gem
|
58
|
+
[b6f885cd57f7]
|
59
|
+
|
60
|
+
* spec/pg/connection_spec.rb:
|
61
|
+
Re-enable application_name setting with corrected guard
|
62
|
+
[5b2e5992bb78]
|
63
|
+
|
64
|
+
* .rvm.gems, Rakefile, Rakefile.cross:
|
65
|
+
Bump versions of dev dependencies
|
66
|
+
[cba92fb4b89e]
|
67
|
+
|
68
|
+
2013-03-06 Michael Granger <ged@FaerieMUD.org>
|
69
|
+
|
70
|
+
* README.rdoc:
|
71
|
+
Add a hint about installing with Bundler to the README.
|
72
|
+
|
73
|
+
Thanks to StackExchange user 'darnumbrella' for this hint.
|
74
|
+
http://stackoverflow.com/questions/15234810/cannot-install-pg-gem
|
75
|
+
[93bacacab796]
|
76
|
+
|
77
|
+
* History.rdoc:
|
78
|
+
Update History
|
79
|
+
[0ab4e5cf47e9]
|
80
|
+
|
81
|
+
2013-03-03 Michael Granger <ged@FaerieMUD.org>
|
82
|
+
|
83
|
+
* spec/pg/connection_spec.rb:
|
84
|
+
Remove application_name setting for PG < 8.3
|
85
|
+
[130d50d246fb]
|
86
|
+
|
87
|
+
* spec/pg/connection_spec.rb:
|
88
|
+
Fix tests under Postgres 8.3.
|
89
|
+
|
90
|
+
Ugh. I need an 8.3 testing box.
|
91
|
+
[bda5c1c794f1]
|
92
|
+
|
93
|
+
* spec/pg/connection_spec.rb:
|
94
|
+
Don't set the application_name for versions of PG less than 9.0
|
95
|
+
[9daa5a0012d8]
|
96
|
+
|
97
|
+
* spec/lib/helpers.rb:
|
98
|
+
Remove reference comment
|
99
|
+
[edc642a94aa6]
|
100
|
+
|
101
|
+
* ext/pg_connection.c, spec/lib/helpers.rb,
|
102
|
+
spec/pg/connection_spec.rb:
|
103
|
+
Clean up the #socket_io if it exists on #finish and #reset.
|
104
|
+
[fc290848221b]
|
105
|
+
|
106
|
+
2013-02-27 Michael Granger <ged@FaerieMUD.org>
|
107
|
+
|
108
|
+
* README.ja.rdoc, README.rdoc:
|
109
|
+
Update READMEs
|
110
|
+
|
111
|
+
* Update relevant versions
|
112
|
+
* Move the badge to a status section
|
113
|
+
* Add link list to the header
|
114
|
+
* Add a (hopefully) more-lucid description to README.ja.rdoc.
|
115
|
+
[ac1c999e8514]
|
116
|
+
|
117
|
+
2013-02-26 Michael Granger <ged@FaerieMUD.org>
|
118
|
+
|
119
|
+
* .travis.yml:
|
120
|
+
Add Ruby 2 to the Travis matrix
|
121
|
+
[d8c0be8a00fa]
|
122
|
+
|
123
|
+
2013-02-25 Michael Granger <ged@FaerieMUD.org>
|
124
|
+
|
125
|
+
* .rvmrc:
|
126
|
+
Test under Ruby 2.0.0 by default
|
127
|
+
[c7919322ac00]
|
128
|
+
|
129
|
+
* Merge with rpath_ldflag
|
130
|
+
[a249c3b79f82]
|
131
|
+
|
132
|
+
2013-02-04 Lars Kanis <kanis@comcard.de>
|
133
|
+
|
134
|
+
* ext/pg_connection.c:
|
135
|
+
Avoid warning about DWORD to int mapping in rb_raise() format
|
136
|
+
string.
|
137
|
+
[b1d3a145bef5]
|
138
|
+
|
1
139
|
2013-02-03 Michael Granger <ged@FaerieMUD.org>
|
2
140
|
|
3
141
|
* ext/pg_connection.c, spec/pg/connection_spec.rb:
|
@@ -8,13 +146,13 @@
|
|
8
146
|
PQexecParams() itself.
|
9
147
|
|
10
148
|
Thanks to Aaron Patterson for the idea.
|
11
|
-
[7c313c2355b7]
|
149
|
+
[7c313c2355b7]
|
12
150
|
|
13
151
|
2013-01-31 Michael Granger <ged@FaerieMUD.org>
|
14
152
|
|
15
153
|
* ext/extconf.rb:
|
16
154
|
Add experimental -rpath to the LDFLAGS
|
17
|
-
[8496c624dffd]
|
155
|
+
[8496c624dffd]
|
18
156
|
|
19
157
|
2013-01-30 Michael Granger <ged@FaerieMUD.org>
|
20
158
|
|
@@ -27,7 +165,7 @@
|
|
27
165
|
This keeps the IO in scope until the Connection is garbage-
|
28
166
|
collected, preventing Ruby from auto-closing the connection to
|
29
167
|
PostgreSQL.
|
30
|
-
[c1e35a055da6]
|
168
|
+
[c1e35a055da6]
|
31
169
|
|
32
170
|
2013-01-30 Michael Granger <ged@faeriemud.org>
|
33
171
|
|
@@ -178,6 +316,61 @@
|
|
178
316
|
Make source settings override TM2 defaults
|
179
317
|
[c5706b3f73af]
|
180
318
|
|
319
|
+
2012-12-26 Lars Kanis <kanis@comcard.de>
|
320
|
+
|
321
|
+
* ext/extconf.rb, ext/pg_connection.c, spec/pg/connection_spec.rb:
|
322
|
+
merge in default branch
|
323
|
+
[ca39e311d1eb] <use_gvl_for_blocking_functions>
|
324
|
+
|
325
|
+
* ext/gvl_wrappers.h:
|
326
|
+
Add some documentation to gvl_wrappers
|
327
|
+
[ffeb6a0afd1f] <use_gvl_for_blocking_functions>
|
328
|
+
|
329
|
+
* spec/pg/connection_spec.rb:
|
330
|
+
Add test case for threading with Connection#exec in ruby 1.9
|
331
|
+
[73b9aa38e8c0] <use_gvl_for_blocking_functions>
|
332
|
+
|
333
|
+
* ext/extconf.rb, ext/gvl_wrappers.c, ext/gvl_wrappers.h, ext/pg.h,
|
334
|
+
ext/pg_connection.c:
|
335
|
+
Add wrappers to blocking functions and callbacks in order to release
|
336
|
+
the GVL of ruby 1.9 as long as not in ruby code
|
337
|
+
[2f2c681424ed] <use_gvl_for_blocking_functions>
|
338
|
+
|
339
|
+
2012-07-02 Lars Kanis <kanis@comcard.de>
|
340
|
+
|
341
|
+
* ext/pg_connection.c, spec/pg/connection_spec.rb:
|
342
|
+
Fix encoding of values delivered to the row processor and add specs
|
343
|
+
for binary and text data.
|
344
|
+
[bb9c6625fbc9] <row_processor>
|
345
|
+
|
346
|
+
* ext/pg_connection.c:
|
347
|
+
Polish the documentation a little bit
|
348
|
+
[b7633be3c941] <row_processor>
|
349
|
+
|
350
|
+
2012-07-01 Lars Kanis <kanis@comcard.de>
|
351
|
+
|
352
|
+
* ext/pg_connection.c:
|
353
|
+
Get rid of gcc warning about (non-)const PGresult to
|
354
|
+
pg_new_result_for_callback()
|
355
|
+
[1a25786ed8f3] <row_processor>
|
356
|
+
|
357
|
+
* ext/pg_connection.c, spec/pg/connection_spec.rb:
|
358
|
+
Fix wrong encoding for Result object passed to a notice-receiver
|
359
|
+
block. Add proper specs for #set_notice_receiver.
|
360
|
+
[4280826bb9b9] <row_processor>
|
361
|
+
|
362
|
+
* ext/extconf.rb, ext/pg.h, ext/pg_connection.c, ext/pg_result.c,
|
363
|
+
spec/lib/helpers.rb, spec/pg/connection_spec.rb:
|
364
|
+
Implement PostgreSQL-9.2 functions PG::Connection#set_row_processor,
|
365
|
+
get_row_processor, skip_result
|
366
|
+
[b7ce4843f4d1] <row_processor>
|
367
|
+
|
368
|
+
2012-06-28 Lars Kanis <kanis@comcard.de>
|
369
|
+
|
370
|
+
* ext/pg_result.c:
|
371
|
+
Add PGRES_COPY_BOTH to documentation of PG::Result#result_status
|
372
|
+
[63998b47da6e] <copy_both_docu>
|
373
|
+
|
181
374
|
2013-01-29 Aaron Patterson <aaron.patterson@gmail.com>
|
182
375
|
|
183
376
|
* ext/pg_result.c, lib/pg/result.rb, spec/pg/result_spec.rb:
|
@@ -208,14 +401,6 @@
|
|
208
401
|
|
209
402
|
2012-12-26 Lars Kanis <kanis@comcard.de>
|
210
403
|
|
211
|
-
* ext/extconf.rb, ext/pg_connection.c, spec/pg/connection_spec.rb:
|
212
|
-
merge in default branch
|
213
|
-
[ca39e311d1eb] <use_gvl_for_blocking_functions>
|
214
|
-
|
215
|
-
* ext/gvl_wrappers.h:
|
216
|
-
Add some documentation to gvl_wrappers
|
217
|
-
[ffeb6a0afd1f] <use_gvl_for_blocking_functions>
|
218
|
-
|
219
404
|
* ext/pg.c:
|
220
405
|
Use proper const check instead of implicit relation
|
221
406
|
[d0c5d5f7f1e8]
|
@@ -235,18 +420,6 @@
|
|
235
420
|
single row mode of PostgreSQL 9.2)
|
236
421
|
[49e3fe1dafdf]
|
237
422
|
|
238
|
-
2012-12-26 Lars Kanis <kanis@comcard.de>
|
239
|
-
|
240
|
-
* spec/pg/connection_spec.rb:
|
241
|
-
Add test case for threading with Connection#exec in ruby 1.9
|
242
|
-
[73b9aa38e8c0] <use_gvl_for_blocking_functions>
|
243
|
-
|
244
|
-
* ext/extconf.rb, ext/gvl_wrappers.c, ext/gvl_wrappers.h, ext/pg.h,
|
245
|
-
ext/pg_connection.c:
|
246
|
-
Add wrappers to blocking functions and callbacks in order to release
|
247
|
-
the GVL of ruby 1.9 as long as not in ruby code
|
248
|
-
[2f2c681424ed] <use_gvl_for_blocking_functions>
|
249
|
-
|
250
423
|
2012-12-19 Lars Kanis <kanis@comcard.de>
|
251
424
|
|
252
425
|
* ext/extconf.rb, ext/pg.c, ext/pg_connection.c,
|
@@ -254,41 +427,6 @@
|
|
254
427
|
Add single row mode of PostgreSQL 9.2
|
255
428
|
[5cf348b75c1c] <single_row_mode>
|
256
429
|
|
257
|
-
2012-07-02 Lars Kanis <kanis@comcard.de>
|
258
|
-
|
259
|
-
* ext/pg_connection.c, spec/pg/connection_spec.rb:
|
260
|
-
Fix encoding of values delivered to the row processor and add specs
|
261
|
-
for binary and text data.
|
262
|
-
[bb9c6625fbc9] <row_processor>
|
263
|
-
|
264
|
-
* ext/pg_connection.c:
|
265
|
-
Polish the documentation a little bit
|
266
|
-
[b7633be3c941] <row_processor>
|
267
|
-
|
268
|
-
2012-07-01 Lars Kanis <kanis@comcard.de>
|
269
|
-
|
270
|
-
* ext/pg_connection.c:
|
271
|
-
Get rid of gcc warning about (non-)const PGresult to
|
272
|
-
pg_new_result_for_callback()
|
273
|
-
[1a25786ed8f3] <row_processor>
|
274
|
-
|
275
|
-
* ext/pg_connection.c, spec/pg/connection_spec.rb:
|
276
|
-
Fix wrong encoding for Result object passed to a notice-receiver
|
277
|
-
block. Add proper specs for #set_notice_receiver.
|
278
|
-
[4280826bb9b9] <row_processor>
|
279
|
-
|
280
|
-
* ext/extconf.rb, ext/pg.h, ext/pg_connection.c, ext/pg_result.c,
|
281
|
-
spec/lib/helpers.rb, spec/pg/connection_spec.rb:
|
282
|
-
Implement PostgreSQL-9.2 functions PG::Connection#set_row_processor,
|
283
|
-
get_row_processor, skip_result
|
284
|
-
[b7ce4843f4d1] <row_processor>
|
285
|
-
|
286
|
-
2012-06-28 Lars Kanis <kanis@comcard.de>
|
287
|
-
|
288
|
-
* ext/pg_result.c:
|
289
|
-
Add PGRES_COPY_BOTH to documentation of PG::Result#result_status
|
290
|
-
[63998b47da6e] <copy_both_docu>
|
291
|
-
|
292
430
|
2012-12-19 Michael Granger <ged@FaerieMUD.org>
|
293
431
|
|
294
432
|
* lib/pg/connection.rb:
|
@@ -596,7 +734,7 @@
|
|
596
734
|
|
597
735
|
* ext/pg_result.c:
|
598
736
|
Merged in larskanis/ruby-pg (pull request #7)
|
599
|
-
[4050c3412bd7]
|
737
|
+
[4050c3412bd7]
|
600
738
|
|
601
739
|
2012-03-10 Lars Kanis <kanis@comcard.de>
|
602
740
|
|
data/History.rdoc
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
== v0.15.0 [
|
1
|
+
== v0.15.0 [2013-03-03] Michael Granger <ged@FaerieMUD.org>
|
2
2
|
|
3
3
|
Bugfixes:
|
4
4
|
|
@@ -14,6 +14,7 @@ Documentation fixes:
|
|
14
14
|
|
15
15
|
Enhancements:
|
16
16
|
|
17
|
+
- Tested under Ruby 2.0.0p0.
|
17
18
|
- Add single row mode of PostgreSQL 9.2.
|
18
19
|
- Set fallback_application_name to programm name $0. Thanks to Will Leinweber
|
19
20
|
for the patch.
|
@@ -24,8 +25,10 @@ Enhancements:
|
|
24
25
|
rb_thread_select().
|
25
26
|
- Add an example of how to insert array data using a prepared statement (#145).
|
26
27
|
- Add continous integration tests on travis-ci.org.
|
27
|
-
- Add PG::Result#
|
28
|
+
- Add PG::Result#each_row for iterative over result sets by row. Thanks to
|
28
29
|
Aaron Patterson for the patch.
|
30
|
+
- Add a PG::Connection#socket_io method for fetching a (non-autoclosing) IO
|
31
|
+
object for the connection's socket.
|
29
32
|
|
30
33
|
Specs:
|
31
34
|
|
data/README.ja.rdoc
CHANGED
@@ -1,7 +1,14 @@
|
|
1
1
|
= pg
|
2
2
|
|
3
|
-
|
3
|
+
home :: https://bitbucket.org/ged/ruby-pg
|
4
|
+
mirror :: https://github.com/ged/ruby-pg
|
5
|
+
docs :: http://deveiate.org/code/pg
|
4
6
|
|
5
|
-
|
6
|
-
|
7
|
+
|
8
|
+
== Description
|
9
|
+
|
10
|
+
This file needs a translation of the English README. Pull requests, patches, or
|
11
|
+
volunteers gladly accepted.
|
12
|
+
|
13
|
+
Until such time, please accept my sincere apologies for not knowing Japanese.
|
7
14
|
|
data/README.rdoc
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
-
{<img src="https://travis-ci.org/ged/ruby-pg.png?branch=master" alt="Build Status" />}[https://travis-ci.org/ged/ruby-pg]
|
2
|
-
|
3
1
|
= pg
|
4
2
|
|
5
|
-
|
3
|
+
home :: https://bitbucket.org/ged/ruby-pg
|
4
|
+
mirror :: https://github.com/ged/ruby-pg
|
5
|
+
docs :: http://deveiate.org/code/pg
|
6
|
+
|
6
7
|
|
7
8
|
== Description
|
8
9
|
|
@@ -26,10 +27,14 @@ A small example usage:
|
|
26
27
|
end
|
27
28
|
end
|
28
29
|
|
30
|
+
== Build Status
|
31
|
+
|
32
|
+
{<img src="https://travis-ci.org/ged/ruby-pg.png?branch=master" alt="Build Status" />}[https://travis-ci.org/ged/ruby-pg]
|
33
|
+
|
29
34
|
|
30
35
|
== Requirements
|
31
36
|
|
32
|
-
* Ruby 1.8.7-
|
37
|
+
* Ruby 1.8.7-p371, 1.9.3-p392, or 2.0.0-p0.
|
33
38
|
* PostgreSQL 8.3.x (with headers, -dev packages, etc).
|
34
39
|
|
35
40
|
It may work with earlier versions of Ruby as well, but those are not regularly tested.
|
@@ -46,6 +51,10 @@ Postgres:
|
|
46
51
|
|
47
52
|
gem install pg -- --with-pg-config=<path to pg_config>
|
48
53
|
|
54
|
+
If you're installing via Bundler, you can provide compile hints like so:
|
55
|
+
|
56
|
+
bundle config build.pg --with-pg-config=<path to pg_config>
|
57
|
+
|
49
58
|
See README-OS_X.rdoc for more information about installing under MacOS X, and
|
50
59
|
README-Windows.rdoc for Windows build/installation instructions.
|
51
60
|
|
data/Rakefile
CHANGED
@@ -55,8 +55,8 @@ $hoespec = Hoe.spec 'pg' do
|
|
55
55
|
|
56
56
|
self.developer 'Michael Granger', 'ged@FaerieMUD.org'
|
57
57
|
|
58
|
-
self.dependency 'rake-compiler', '~> 0.
|
59
|
-
self.dependency 'hoe-deveiate', '~> 0.
|
58
|
+
self.dependency 'rake-compiler', '~> 0.8', :developer
|
59
|
+
self.dependency 'hoe-deveiate', '~> 0.2', :developer
|
60
60
|
|
61
61
|
self.spec_extras[:licenses] = ['BSD', 'Ruby', 'GPL']
|
62
62
|
self.spec_extras[:extensions] = [ 'ext/extconf.rb' ]
|
@@ -102,7 +102,7 @@ task :maint do
|
|
102
102
|
ENV['MAINTAINER_MODE'] = 'yes'
|
103
103
|
end
|
104
104
|
|
105
|
-
ENV['RUBY_CC_VERSION'] ||= '1.8.7:1.9.2'
|
105
|
+
ENV['RUBY_CC_VERSION'] ||= '1.8.7:1.9.2:2.0.0'
|
106
106
|
|
107
107
|
# Rake-compiler task
|
108
108
|
Rake::ExtensionTask.new do |ext|
|
@@ -112,15 +112,18 @@ Rake::ExtensionTask.new do |ext|
|
|
112
112
|
ext.lib_dir = 'lib'
|
113
113
|
ext.source_pattern = "*.{c,h}"
|
114
114
|
ext.cross_compile = true
|
115
|
-
ext.cross_platform =
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
115
|
+
ext.cross_platform = CrossLibraries.map(&:for_platform)[1,1]
|
116
|
+
|
117
|
+
ext.cross_config_options += CrossLibraries.map do |lib|
|
118
|
+
{
|
119
|
+
lib.for_platform => [
|
120
|
+
"--with-pg-include=#{lib.static_postgresql_libdir}",
|
121
|
+
"--with-opt-include=#{lib.static_postgresql_incdir}",
|
122
|
+
"--with-pg-lib=#{lib.static_postgresql_libdir}",
|
123
|
+
"--with-opt-lib=#{lib.static_openssl_builddir}",
|
124
|
+
]
|
125
|
+
}
|
126
|
+
end
|
124
127
|
end
|
125
128
|
|
126
129
|
|
data/Rakefile.cross
CHANGED
@@ -6,6 +6,7 @@ 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
|
|
@@ -17,218 +18,242 @@ else
|
|
17
18
|
1
|
18
19
|
end
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
POSTGRESQL_VERSION = ENV['POSTGRESQL_VERSION'] || '9.2.2'
|
21
|
+
class CrossLibrary < OpenStruct
|
22
|
+
include Rake::DSL
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
STATIC_BUILDDIR = COMPILE_HOME + 'builds'
|
24
|
+
def initialize(for_platform, openssl_config)
|
25
|
+
super()
|
27
26
|
|
28
|
-
|
29
|
-
|
27
|
+
self.for_platform = for_platform
|
28
|
+
self.openssl_config = openssl_config
|
30
29
|
|
31
|
-
|
32
|
-
|
33
|
-
|
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'
|
35
33
|
|
36
|
-
|
37
|
-
|
34
|
+
self.compile_home = Pathname( "./build" ).expand_path
|
35
|
+
self.static_sourcesdir = compile_home + 'sources'
|
36
|
+
self.static_builddir = compile_home + 'builds' + for_platform
|
38
37
|
|
39
|
-
|
38
|
+
# Static OpenSSL build vars
|
39
|
+
self.static_openssl_builddir = static_builddir + "openssl-#{openssl_version}"
|
40
40
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
[ 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
|
-
POSTGRESQL_PATCHES = Rake::FileList[ (MISCDIR + "postgresql-#{POSTGRESQL_VERSION}.*.patch").to_s ]
|
59
|
-
|
60
|
-
CROSS_PREFIX = begin
|
61
|
-
Rake::ExtensionCompiler.mingw_host
|
62
|
-
rescue => err
|
63
|
-
$stderr.puts "Cross-compilation disabled -- %s" % [ err.message ]
|
64
|
-
'unknown'
|
65
|
-
end
|
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'
|
66
45
|
|
46
|
+
self.libssleay32 = static_openssl_builddir + 'libssleay32.a'
|
47
|
+
self.libeay32 = static_openssl_builddir + 'libeay32.a'
|
67
48
|
|
68
|
-
|
69
|
-
CLEAN.include( STATIC_BUILDDIR.to_s )
|
49
|
+
self.openssl_patches = Rake::FileList[ (MISCDIR + "openssl-#{openssl_version}.*.patch").to_s ]
|
70
50
|
|
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 ]
|
69
|
+
|
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
|
+
end
|
71
77
|
|
72
|
-
ENV['RUBY_CC_VERSION'] ||= '1.8.7:1.9.3'
|
73
78
|
|
74
|
-
|
75
|
-
|
76
|
-
sh "wget #{url.to_s.inspect} -O #{part.inspect} || curl #{url.to_s.inspect} -o #{part.inspect}"
|
77
|
-
FileUtils.mv part, save_to
|
78
|
-
end
|
79
|
+
# clean intermediate files and folders
|
80
|
+
CLEAN.include( static_builddir.to_s )
|
79
81
|
|
80
|
-
def run(*args)
|
81
|
-
sh *args
|
82
|
-
end
|
83
82
|
|
84
|
-
|
85
|
-
### C R O S S - C O M P I L A T I O N - T A S K S
|
86
|
-
#####################################################################
|
83
|
+
ENV['RUBY_CC_VERSION'] ||= '1.8.7:1.9.3:2.0.0'
|
87
84
|
|
85
|
+
def download(url, save_to)
|
86
|
+
part = save_to+".part"
|
87
|
+
sh "wget #{url.to_s.inspect} -O #{part.inspect} || curl #{url.to_s.inspect} -o #{part.inspect}"
|
88
|
+
FileUtils.mv part, save_to
|
89
|
+
end
|
88
90
|
|
89
|
-
|
91
|
+
def run(*args)
|
92
|
+
sh *args
|
93
|
+
end
|
90
94
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
directory STATIC_OPENSSL_BUILDDIR.to_s
|
95
|
+
#####################################################################
|
96
|
+
### C R O S S - C O M P I L A T I O N - T A S K S
|
97
|
+
#####################################################################
|
95
98
|
|
96
|
-
# openssl source file should be stored there
|
97
|
-
file OPENSSL_TARBALL => STATIC_SOURCESDIR do |t|
|
98
|
-
download( OPENSSL_SOURCE_URI, t.name )
|
99
|
-
end
|
100
99
|
|
101
|
-
|
102
|
-
file STATIC_OPENSSL_BUILDDIR => OPENSSL_TARBALL do |t|
|
103
|
-
puts "extracting %s to %s" % [ OPENSSL_TARBALL, STATIC_OPENSSL_BUILDDIR.parent ]
|
104
|
-
STATIC_OPENSSL_BUILDDIR.mkpath
|
105
|
-
run 'tar', '-xzf', OPENSSL_TARBALL.to_s, '-C', STATIC_OPENSSL_BUILDDIR.parent.to_s
|
106
|
-
OPENSSL_MAKEFILE.unlink if OPENSSL_MAKEFILE.exist?
|
107
|
-
|
108
|
-
OPENSSL_PATCHES.each do |patchfile|
|
109
|
-
puts " applying patch #{patchfile}..."
|
110
|
-
run 'patch', '-Np1', '-d', STATIC_OPENSSL_BUILDDIR.to_s,
|
111
|
-
'-i', File.expand_path( patchfile, BASEDIR )
|
112
|
-
end
|
113
|
-
end
|
100
|
+
directory static_sourcesdir.to_s
|
114
101
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
"AR=#{CROSS_PREFIX}-ar",
|
120
|
-
"RANLIB=#{CROSS_PREFIX}-ranlib"
|
121
|
-
]
|
102
|
+
#
|
103
|
+
# Static OpenSSL build tasks
|
104
|
+
#
|
105
|
+
directory static_openssl_builddir.to_s
|
122
106
|
|
107
|
+
# openssl source file should be stored there
|
108
|
+
file openssl_tarball => static_sourcesdir do |t|
|
109
|
+
download( openssl_source_uri, t.name )
|
110
|
+
end
|
123
111
|
|
124
|
-
#
|
125
|
-
file
|
126
|
-
|
127
|
-
|
128
|
-
|
112
|
+
# Extract the openssl builds
|
113
|
+
file static_openssl_builddir => openssl_tarball do |t|
|
114
|
+
puts "extracting %s to %s" % [ openssl_tarball, static_openssl_builddir.parent ]
|
115
|
+
static_openssl_builddir.mkpath
|
116
|
+
run 'tar', '-xzf', openssl_tarball.to_s, '-C', static_openssl_builddir.parent.to_s
|
117
|
+
openssl_makefile.unlink if openssl_makefile.exist?
|
118
|
+
|
119
|
+
openssl_patches.each do |patchfile|
|
120
|
+
puts " applying patch #{patchfile}..."
|
121
|
+
run 'patch', '-Np1', '-d', static_openssl_builddir.to_s,
|
122
|
+
'-i', File.expand_path( patchfile, BASEDIR )
|
123
|
+
end
|
124
|
+
end
|
129
125
|
|
130
|
-
|
131
|
-
|
132
|
-
|
126
|
+
self.cmd_prelude = [
|
127
|
+
'env',
|
128
|
+
"CC=#{host_platform}-gcc",
|
129
|
+
"CFLAGS=-DDSO_WIN32",
|
130
|
+
"AR=#{host_platform}-ar",
|
131
|
+
"RANLIB=#{host_platform}-ranlib"
|
132
|
+
]
|
133
133
|
|
134
|
-
desc "compile static openssl libraries"
|
135
|
-
task :openssl_libs => [ LIBSSLEAY32, LIBEAY32 ]
|
136
134
|
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
135
|
+
# generate the makefile in a clean build location
|
136
|
+
file openssl_makefile => static_openssl_builddir do |t|
|
137
|
+
Dir.chdir( static_openssl_builddir ) do
|
138
|
+
cmd = cmd_prelude.dup
|
139
|
+
cmd << "./Configure" << openssl_config
|
141
140
|
|
142
|
-
|
143
|
-
|
144
|
-
end
|
141
|
+
run( *cmd )
|
142
|
+
end
|
143
|
+
end
|
145
144
|
|
146
|
-
desc "compile static
|
147
|
-
|
148
|
-
FileUtils.cp( STATIC_OPENSSL_BUILDDIR + 'libcrypto.a', LIBEAY32.to_s )
|
149
|
-
end
|
145
|
+
desc "compile static openssl libraries"
|
146
|
+
task :openssl_libs => [ libssleay32, libeay32 ]
|
150
147
|
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
148
|
+
task :compile_static_openssl => openssl_makefile do |t|
|
149
|
+
Dir.chdir( static_openssl_builddir ) do
|
150
|
+
cmd = cmd_prelude.dup
|
151
|
+
cmd << 'make' << "-j#{NUM_CPUS}" << 'build_libs'
|
155
152
|
|
153
|
+
run( *cmd )
|
154
|
+
end
|
155
|
+
end
|
156
156
|
|
157
|
+
desc "compile static #{libeay32}"
|
158
|
+
file libeay32 => :compile_static_openssl do |t|
|
159
|
+
FileUtils.cp( static_openssl_builddir + 'libcrypto.a', libeay32.to_s )
|
160
|
+
end
|
157
161
|
|
158
|
-
#
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
+
desc "compile static #{libssleay32}"
|
163
|
+
file libssleay32 => :compile_static_openssl do |t|
|
164
|
+
FileUtils.cp( static_openssl_builddir + 'libssl.a', libssleay32.to_s )
|
165
|
+
end
|
162
166
|
|
163
167
|
|
164
|
-
# postgresql source file should be stored there
|
165
|
-
file POSTGRESQL_TARBALL => STATIC_SOURCESDIR do |t|
|
166
|
-
download( POSTGRESQL_SOURCE_URI, t.name )
|
167
|
-
end
|
168
168
|
|
169
|
-
#
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
run 'tar', '-xjf', POSTGRESQL_TARBALL.to_s, '-C', STATIC_POSTGRESQL_BUILDDIR.parent.to_s
|
174
|
-
mv POSTGRESQL_SHLIB_MAKEFILE, POSTGRESQL_SHLIB_MF_ORIG
|
175
|
-
|
176
|
-
POSTGRESQL_PATCHES.each do |patchfile|
|
177
|
-
puts " applying patch #{patchfile}..."
|
178
|
-
run 'patch', '-Np1', '-d', STATIC_POSTGRESQL_BUILDDIR.to_s,
|
179
|
-
'-i', File.expand_path( patchfile, BASEDIR )
|
180
|
-
end
|
181
|
-
end
|
169
|
+
#
|
170
|
+
# Static PostgreSQL build tasks
|
171
|
+
#
|
172
|
+
directory static_postgresql_builddir.to_s
|
182
173
|
|
183
|
-
# generate the makefile in a clean build location
|
184
|
-
file POSTGRESQL_GLOBAL_MAKEFILE => [ STATIC_POSTGRESQL_BUILDDIR, :openssl_libs ] do |t|
|
185
|
-
options = [
|
186
|
-
'--target=i386-mingw32',
|
187
|
-
"--host=#{Rake::ExtensionCompiler.mingw_host}",
|
188
|
-
'--with-openssl',
|
189
|
-
'--without-zlib',
|
190
|
-
'--disable-shared',
|
191
|
-
]
|
192
|
-
|
193
|
-
Dir.chdir( STATIC_POSTGRESQL_BUILDDIR ) do
|
194
|
-
configure_path = STATIC_POSTGRESQL_BUILDDIR + 'configure'
|
195
|
-
cmd = [ configure_path.to_s, *options ]
|
196
|
-
cmd << "CFLAGS=-L#{STATIC_OPENSSL_BUILDDIR}"
|
197
|
-
cmd << "LDFLAGS=-L#{STATIC_OPENSSL_BUILDDIR}"
|
198
|
-
cmd << "LDFLAGS_SL=-L#{STATIC_OPENSSL_BUILDDIR}"
|
199
|
-
cmd << "LIBS=-lwsock32 -lws2_32 -lgdi32"
|
200
|
-
cmd << "CPPFLAGS=-I#{STATIC_OPENSSL_BUILDDIR}/include"
|
201
|
-
|
202
|
-
run( *cmd )
|
203
|
-
end
|
204
|
-
end
|
205
174
|
|
175
|
+
# postgresql source file should be stored there
|
176
|
+
file postgresql_tarball => static_sourcesdir do |t|
|
177
|
+
download( postgresql_source_uri, t.name )
|
178
|
+
end
|
206
179
|
|
207
|
-
#
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
180
|
+
# Extract the postgresql sources
|
181
|
+
file static_postgresql_builddir => postgresql_tarball do |t|
|
182
|
+
puts "extracting %s to %s" % [ postgresql_tarball, static_postgresql_builddir.parent ]
|
183
|
+
static_postgresql_builddir.mkpath
|
184
|
+
run 'tar', '-xjf', postgresql_tarball.to_s, '-C', static_postgresql_builddir.parent.to_s
|
185
|
+
mv postgresql_shlib_makefile, postgresql_shlib_mf_orig
|
186
|
+
|
187
|
+
postgresql_patches.each do |patchfile|
|
188
|
+
puts " applying patch #{patchfile}..."
|
189
|
+
run 'patch', '-Np1', '-d', static_postgresql_builddir.to_s,
|
190
|
+
'-i', File.expand_path( patchfile, BASEDIR )
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
# generate the makefile in a clean build location
|
195
|
+
file postgresql_global_makefile => [ static_postgresql_builddir, :openssl_libs ] do |t|
|
196
|
+
options = [
|
197
|
+
"--target=#{host_platform}",
|
198
|
+
"--host=#{host_platform}",
|
199
|
+
'--with-openssl',
|
200
|
+
'--without-zlib',
|
201
|
+
'--disable-shared',
|
202
|
+
]
|
203
|
+
|
204
|
+
Dir.chdir( static_postgresql_builddir ) do
|
205
|
+
configure_path = static_postgresql_builddir + 'configure'
|
206
|
+
cmd = [ configure_path.to_s, *options ]
|
207
|
+
cmd << "CFLAGS=-L#{static_openssl_builddir}"
|
208
|
+
cmd << "LDFLAGS=-L#{static_openssl_builddir}"
|
209
|
+
cmd << "LDFLAGS_SL=-L#{static_openssl_builddir}"
|
210
|
+
cmd << "LIBS=-lwsock32 -lgdi32"
|
211
|
+
cmd << "CPPFLAGS=-I#{static_openssl_builddir}/include"
|
212
|
+
|
213
|
+
run( *cmd )
|
214
|
+
end
|
214
215
|
end
|
215
|
-
end
|
216
|
-
tf.close
|
217
216
|
|
218
|
-
FileUtils.mv( tf.path, t.name, :verbose => $puts )
|
219
|
-
end
|
220
217
|
|
218
|
+
# patch the Makefile.shlib -- depend on the build dir so it's only
|
219
|
+
# rewritten if the tarball is re-extracted.
|
220
|
+
file postgresql_shlib_makefile => postgresql_shlib_mf_orig do |t|
|
221
|
+
tf = Tempfile.new( postgresql_shlib_makefile.basename.to_s )
|
222
|
+
postgresql_shlib_mf_orig.open( File::RDONLY ) do |ifh|
|
223
|
+
ifh.each_line do |line|
|
224
|
+
tf.print( line.sub(/^(\s*haslibarule\s*=\s*yes)/, "# \\1 ") )
|
225
|
+
end
|
226
|
+
end
|
227
|
+
tf.close
|
221
228
|
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
229
|
+
FileUtils.mv( tf.path, t.name, :verbose => $puts )
|
230
|
+
end
|
231
|
+
|
232
|
+
|
233
|
+
# make libpq.a
|
234
|
+
task postgresql_lib => [ postgresql_global_makefile, postgresql_shlib_makefile ] do |t|
|
235
|
+
Dir.chdir( postgresql_lib.dirname ) do
|
236
|
+
sh 'make', "-j#{NUM_CPUS}", postgresql_lib.basename.to_s, 'PORTNAME=win32'
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
240
|
+
|
241
|
+
#desc 'compile static libpg.a'
|
242
|
+
task :static_libpq => postgresql_lib
|
226
243
|
end
|
227
244
|
end
|
228
245
|
|
229
|
-
|
230
|
-
|
231
|
-
|
246
|
+
if File.exist?(File.expand_path("~/.rake-compiler/config.yml"))
|
247
|
+
CrossLibraries = [
|
248
|
+
['i386-mingw32', 'mingw'],
|
249
|
+
['x64-mingw32', 'mingw64'],
|
250
|
+
].map do |platform, openssl_config|
|
251
|
+
CrossLibrary.new platform, openssl_config
|
252
|
+
end
|
253
|
+
else
|
254
|
+
$stderr.puts "Cross-compilation disabled -- rake-compiler not properly installed"
|
255
|
+
CrossLibraries = []
|
256
|
+
end
|
232
257
|
|
233
258
|
desc 'cross compile pg for win32'
|
234
259
|
task :cross do
|