pg 0.18.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +5 -5
  2. checksums.yaml.gz.sig +0 -0
  3. data/BSDL +2 -2
  4. data/ChangeLog +1221 -4
  5. data/History.rdoc +130 -0
  6. data/Manifest.txt +0 -18
  7. data/README-Windows.rdoc +15 -26
  8. data/README.rdoc +16 -10
  9. data/Rakefile +32 -23
  10. data/Rakefile.cross +56 -38
  11. data/ext/errorcodes.def +33 -0
  12. data/ext/errorcodes.txt +15 -1
  13. data/ext/extconf.rb +27 -35
  14. data/ext/gvl_wrappers.c +4 -0
  15. data/ext/gvl_wrappers.h +27 -39
  16. data/ext/pg.c +19 -51
  17. data/ext/pg.h +22 -79
  18. data/ext/pg_binary_decoder.c +3 -1
  19. data/ext/pg_binary_encoder.c +14 -12
  20. data/ext/pg_coder.c +31 -10
  21. data/ext/pg_connection.c +350 -263
  22. data/ext/pg_copy_coder.c +34 -4
  23. data/ext/pg_result.c +27 -25
  24. data/ext/pg_text_decoder.c +9 -10
  25. data/ext/pg_text_encoder.c +93 -73
  26. data/ext/pg_type_map.c +20 -13
  27. data/ext/pg_type_map_by_column.c +7 -7
  28. data/ext/pg_type_map_by_mri_type.c +2 -2
  29. data/ext/pg_type_map_in_ruby.c +4 -7
  30. data/ext/util.c +3 -3
  31. data/ext/util.h +1 -1
  32. data/lib/pg/basic_type_mapping.rb +69 -42
  33. data/lib/pg/connection.rb +89 -38
  34. data/lib/pg/result.rb +10 -5
  35. data/lib/pg/text_decoder.rb +12 -3
  36. data/lib/pg/text_encoder.rb +8 -0
  37. data/lib/pg.rb +18 -10
  38. data/spec/helpers.rb +9 -16
  39. data/spec/pg/basic_type_mapping_spec.rb +58 -4
  40. data/spec/pg/connection_spec.rb +477 -217
  41. data/spec/pg/result_spec.rb +14 -7
  42. data/spec/pg/type_map_by_class_spec.rb +2 -2
  43. data/spec/pg/type_map_by_mri_type_spec.rb +1 -1
  44. data/spec/pg/type_spec.rb +145 -33
  45. data/spec/pg_spec.rb +1 -1
  46. data.tar.gz.sig +0 -0
  47. metadata +67 -66
  48. metadata.gz.sig +0 -0
  49. data/sample/array_insert.rb +0 -20
  50. data/sample/async_api.rb +0 -106
  51. data/sample/async_copyto.rb +0 -39
  52. data/sample/async_mixed.rb +0 -56
  53. data/sample/check_conn.rb +0 -21
  54. data/sample/copyfrom.rb +0 -81
  55. data/sample/copyto.rb +0 -19
  56. data/sample/cursor.rb +0 -21
  57. data/sample/disk_usage_report.rb +0 -186
  58. data/sample/issue-119.rb +0 -94
  59. data/sample/losample.rb +0 -69
  60. data/sample/minimal-testcase.rb +0 -17
  61. data/sample/notify_wait.rb +0 -72
  62. data/sample/pg_statistics.rb +0 -294
  63. data/sample/replication_monitor.rb +0 -231
  64. data/sample/test_binary_values.rb +0 -33
  65. data/sample/wal_shipper.rb +0 -434
  66. data/sample/warehouse_partitions.rb +0 -320
data/History.rdoc CHANGED
@@ -1,3 +1,132 @@
1
+ == v1.0.0 [2018-01-10] Michael Granger <ged@FaerieMUD.org>
2
+
3
+ Deprecated:
4
+ - Deprecate Ruby older than 2.2.
5
+ - Deprecate Connection#socket in favor of #socket_io.
6
+
7
+ Removed:
8
+ - Remove compatibility code for Ruby < 2.0 and PostgreSQL < 9.2.
9
+ - Remove partial compatibility with Rubinius.
10
+
11
+ Enhancements:
12
+ - Update error codes to PostgreSQL-10
13
+ - Update Windows binary gems to Ruby-2.5, PostgreSQL 10.1 and
14
+ OpenSSL 1.1.0g.
15
+
16
+ Bugfixes:
17
+ - Fix URI detection for connection strings. #265 (thanks to jjoos)
18
+ - MINGW: Workaround segfault due to GCC linker error in conjunction with MSVC.
19
+ This happens when linking to PostgreSQL-10.0-x64 from EnterpriseDB.
20
+
21
+ Documentation fixes:
22
+ - Add PostgreSQL version since when the given function is supported. #263
23
+ - Better documentation to `encoder` and `decoder` arguments of COPY related methods.
24
+
25
+
26
+ == v0.21.0 [2017-06-12] Michael Granger <ged@FaerieMUD.org>
27
+
28
+ Enhancements:
29
+ - Move add_dll_directory to the Runtime namespace for newest versions
30
+ of RubyInstaller.
31
+ - Deprecate PGconn, PGresult, and PGError top-level constants; a warning
32
+ will be output the first time one of them is used. They will be
33
+ removed in the upcoming 1.0 release.
34
+
35
+ Documentation fixes:
36
+ - Update the docs for PG::Result#cmd_tuples
37
+
38
+ New Samples:
39
+ - Add an example of the nicer #copy_data way of doing `COPY`.
40
+
41
+
42
+ == v0.20.0 [2017-03-10] Michael Granger <ged@FaerieMUD.org>
43
+
44
+ Enhancements:
45
+ - Update error codes to PostgreSQL-9.6
46
+ - Update Windows binary gems to Ruby-2.4, PostgreSQL 9.6.1 and
47
+ OpenSSL 1.0.2j.
48
+ - Add support for RubyInstaller2 to Windows binary gems.
49
+
50
+ Bugfixes:
51
+ - Use secure JSON methods for JSON (de)serialisation. #248
52
+ - Fix Result#inspect on a cleared result.
53
+ - Fix test case that failed on Ruby-2.4. #255
54
+
55
+ Documentation fixes:
56
+ - Talk about Integer instead of Fixnum.
57
+ - Fix method signature of Coder#encode.
58
+
59
+
60
+ == v0.19.0 [2016-09-21] Michael Granger <ged@FaerieMUD.org>
61
+
62
+ - Deprecate Ruby 1.9
63
+
64
+ Enhancements:
65
+ - Respect and convert character encoding of all strings sent
66
+ to the server. #231
67
+ - Add PostgreSQL-9.5 functions PQsslInUse(), PQsslAttribute()
68
+ and PQsslAttributeNames().
69
+ - Various documentation fixes and improvements.
70
+ - Add mechanism to build without pg_config:
71
+ gem install pg -- --with-pg-config=ignore
72
+ - Update Windows binary gems to Ruby-2.3, PostgreSQL 9.5.4 and
73
+ OpenSSL 1.0.2f.
74
+ - Add JSON coders and add them to BasicTypeMapForResults and
75
+ BasicTypeMapBasedOnResult
76
+ - Allow build from git per bundler.
77
+
78
+ Bugfixes:
79
+ - Release GVL while calling PQsetClientEncoding(). #245
80
+ - Add __EXTENSIONS__ to Solaris/SmartOS for Ruby >= 2.3.x. #236
81
+ - Fix wrong exception when running SQL while in Connection#copy_data
82
+ block for output
83
+
84
+
85
+ == v0.18.4 [2015-11-13] Michael Granger <ged@FaerieMUD.org>
86
+
87
+ Enhancements:
88
+ - Fixing compilation problems with Microsoft Visual Studio 2008. GH #10
89
+ - Avoid name clash with xcode and jemalloc. PR#22, PR#23
90
+
91
+ Bugfixes:
92
+ - Avoid segfault, when quote_ident or TextEncoder::Identifier
93
+ is called with Array containing non-strings. #226
94
+
95
+
96
+ == v0.18.3 [2015-09-03] Michael Granger <ged@FaerieMUD.org>
97
+
98
+ Enhancements:
99
+ - Use rake-compiler-dock to build windows gems easily.
100
+ - Add CI-tests on appveyor and fix test cases accordingly.
101
+
102
+ Bugfixes:
103
+ - Fix data type resulting in wrong base64 encoding.
104
+ - Change instance_of checks to kind_of for subclassing. #220
105
+ - TextDecoder::Date returns an actual Ruby Date instead of a Time
106
+ (thanks to Thomas Ramfjord)
107
+
108
+
109
+ == v0.18.2 [2015-05-14] Michael Granger <ged@FaerieMUD.org>
110
+
111
+ Enhancements:
112
+
113
+ - Allow URI connection string (thanks to Chris Bandy)
114
+ - Allow Array type parameter to conn.quote_ident
115
+
116
+ Bugfixes:
117
+
118
+ - Speedups and fixes for PG::TextDecoder::Identifier and quoting behavior
119
+ - Revert addition of PG::Connection#hostaddr [#202].
120
+ - Fix decoding of fractional timezones and timestamps [#203]
121
+ - Fixes for non-C99 compilers
122
+ - Avoid possible symbol name clash when linking againt static libpq.
123
+
124
+
125
+ == v0.18.1 [2015-01-05] Michael Granger <ged@FaerieMUD.org>
126
+
127
+ Correct the minimum compatible Ruby version to 1.9.3. #199
128
+
129
+
1
130
  == v0.18.0 [2015-01-01] Michael Granger <ged@FaerieMUD.org>
2
131
 
3
132
  Bugfixes:
@@ -14,6 +143,7 @@ Enhancements:
14
143
  - Add Enumerator variant to PG::Result#each and #each_row.
15
144
  - Add PG::Connection#conninfo and #hostaddr.
16
145
  - Add PG.init_openssl and PG.init_ssl methods.
146
+ - Add PG::Result.inspect
17
147
  - Force zero termination for all text strings that are given to libpq.
18
148
  It raises an ArgumentError if the string contains a null byte.
19
149
  - Update Windows cross build to PostgreSQL 9.3.
data/Manifest.txt CHANGED
@@ -51,24 +51,6 @@ lib/pg/result.rb
51
51
  lib/pg/text_decoder.rb
52
52
  lib/pg/text_encoder.rb
53
53
  lib/pg/type_map_by_column.rb
54
- sample/array_insert.rb
55
- sample/async_api.rb
56
- sample/async_copyto.rb
57
- sample/async_mixed.rb
58
- sample/check_conn.rb
59
- sample/copyfrom.rb
60
- sample/copyto.rb
61
- sample/cursor.rb
62
- sample/disk_usage_report.rb
63
- sample/issue-119.rb
64
- sample/losample.rb
65
- sample/minimal-testcase.rb
66
- sample/notify_wait.rb
67
- sample/pg_statistics.rb
68
- sample/replication_monitor.rb
69
- sample/test_binary_values.rb
70
- sample/wal_shipper.rb
71
- sample/warehouse_partitions.rb
72
54
  spec/data/expected_trace.out
73
55
  spec/data/random_binary_data
74
56
  spec/helpers.rb
data/README-Windows.rdoc CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  In order to build this extension on MS Windows you will need a couple things.
4
4
 
5
- First, a compiler. For the one click installer this means you should either
6
- use VC++ 6.0 or the compiler that comes with cygwin or mingw if you're
7
- building on that platform.
5
+ First, a compiler. For the one click installer this means you should use
6
+ the DevKit or the compiler that comes with cygwin if you're building on that
7
+ platform.
8
8
 
9
9
  If you've built Ruby yourself, you should use the same compiler to build
10
10
  this library that you used to build Ruby.
@@ -29,34 +29,23 @@ Adjust your path accordingly. BE SURE TO USE THE SHORT PATH NAMES! If you
29
29
  try to use a path with spaces in it, the nmake.exe program will choke.
30
30
 
31
31
 
32
- == Cross compiling for mswin32
32
+ == Building binary 'pg' gems for MS Windows
33
33
 
34
- Using rake-compiler a cross compiled pg gem can be build on a Linux or MacOS X
35
- host for the win32 platform. The generated gem is statically linked against
36
- libpq and libssl. OpenSSL and PostgreSQL are downloaded and compiled from the
37
- sources. There are no runtime dependencies to any but the standard Windows
38
- DLLs.
34
+ Binary gems for windows can be built on Linux, OS-X and even on Windows
35
+ with the help of docker. This is how regular windows gems are built for
36
+ rubygems.org .
39
37
 
40
- Install mingw32 using the instructions in rake-compiler's README.
41
- For Debian/Ubuntu it is <tt>apt-get install gcc-mingw32</tt> .
42
- Use ruby-1.8.7 for the following commands.
38
+ To do this, install boot2docker [on Windows](https://github.com/boot2docker/windows-installer/releases)
39
+ or [on OS X](https://github.com/boot2docker/osx-installer/releases) and make
40
+ sure it is started. A native Docker installation is best on Linux.
43
41
 
44
- Download and cross compile ruby 1.8 and 1.9 for win32 with:
42
+ Then run:
45
43
 
46
- rake-compiler cross-ruby VERSION=1.8.7-p352
47
- rake-compiler cross-ruby VERSION=1.9.2-p290
44
+ rake gem:windows
48
45
 
49
- Download and cross compile pg for win32:
50
-
51
- rake cross native gem
52
-
53
- or with custom versions:
54
-
55
- rake cross native gem RUBY_CC_VERSION=1.8.7:1.9.2 \
56
- OPENSSL_VERSION=1.0.0e POSTGRESQL_VERSION=9.1.1
57
-
58
- If everything works, there should be pg-VERSION-x86-mingw32.gem in the pkg
59
- directory.
46
+ This will download a docker image suited for building windows gems, and it
47
+ will download and build OpenSSL and PostgreSQL. Finally the gem is built
48
+ containing binaries for all supported ruby versions.
60
49
 
61
50
 
62
51
  == Reporting Problems
data/README.rdoc CHANGED
@@ -4,12 +4,14 @@ home :: https://bitbucket.org/ged/ruby-pg
4
4
  mirror :: https://github.com/ged/ruby-pg
5
5
  docs :: http://deveiate.org/code/pg
6
6
 
7
+ {<img src="https://badges.gitter.im/Join%20Chat.svg" alt="Join the chat at https://gitter.im/ged/ruby-pg">}[https://gitter.im/ged/ruby-pg?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge]
8
+
7
9
 
8
10
  == Description
9
11
 
10
12
  Pg is the Ruby interface to the {PostgreSQL RDBMS}[http://www.postgresql.org/].
11
13
 
12
- It works with {PostgreSQL 8.4 and later}[http://www.postgresql.org/support/versioning/].
14
+ It works with {PostgreSQL 9.2 and later}[http://www.postgresql.org/support/versioning/].
13
15
 
14
16
  A small example usage:
15
17
 
@@ -21,7 +23,7 @@ A small example usage:
21
23
  conn = PG.connect( dbname: 'sales' )
22
24
  conn.exec( "SELECT * FROM pg_stat_activity" ) do |result|
23
25
  puts " PID | User | Query"
24
- result.each do |row|
26
+ result.each do |row|
25
27
  puts " %7d | %-16s | %s " %
26
28
  row.values_at('procpid', 'usename', 'current_query')
27
29
  end
@@ -29,15 +31,16 @@ A small example usage:
29
31
 
30
32
  == Build Status
31
33
 
32
- {<img src="https://travis-ci.org/ged/ruby-pg.png?branch=master" alt="Build Status" />}[https://travis-ci.org/ged/ruby-pg]
34
+ {<img src="https://travis-ci.org/ged/ruby-pg.svg?branch=master" alt="Build Status Travis-CI" />}[https://travis-ci.org/ged/ruby-pg]
35
+ {<img src="https://ci.appveyor.com/api/projects/status/at4g4swb2cd4xji7/branch/master?svg=true" alt="Build Status Appveyor" />}[https://ci.appveyor.com/project/ged/ruby-pg]
33
36
 
34
37
 
35
38
  == Requirements
36
39
 
37
- * Ruby 1.9.3-p392, or 2.0.0-p0.
38
- * PostgreSQL 8.4.x or later (with headers, -dev packages, etc).
40
+ * Ruby 2.2 or newer
41
+ * PostgreSQL 9.2.x or later (with headers, -dev packages, etc).
39
42
 
40
- It may work with earlier versions of Ruby/PostgreSQL as well, but those are
43
+ It usually work with earlier versions of Ruby/PostgreSQL as well, but those are
41
44
  not regularly tested.
42
45
 
43
46
 
@@ -63,6 +66,10 @@ There's also {a Google+ group}[http://goo.gl/TFy1U] and a
63
66
  {mailing list}[http://groups.google.com/group/ruby-pg] if you get stuck, or just
64
67
  want to chat about something.
65
68
 
69
+ If you want to install as a signed gem, the public certs of the gem signers
70
+ can be found in {the `certs` directory}[https://bitbucket.org/ged/ruby-pg/src/tip/certs/]
71
+ of the repository.
72
+
66
73
 
67
74
  == Type Casts
68
75
 
@@ -109,7 +116,7 @@ needs for type casting. The default type map is PG::TypeMapAllStrings.
109
116
 
110
117
  A type map can be assigned per connection or per query respectively per
111
118
  result set. Type maps can also be used for COPY in and out data streaming.
112
-
119
+ See PG::Connection#copy_data .
113
120
 
114
121
  == Contributing
115
122
 
@@ -130,7 +137,7 @@ Lars Kanis <lars@greiz-reinsdorf.de>.
130
137
 
131
138
  == Copying
132
139
 
133
- Copyright (c) 1997-2013 by the authors.
140
+ Copyright (c) 1997-2016 by the authors.
134
141
 
135
142
  * Jeff Davis <ruby-pg@j-davis.com>
136
143
  * Guy Decoux (ts) <decoux@moulon.inra.fr>
@@ -142,7 +149,7 @@ Copyright (c) 1997-2013 by the authors.
142
149
  * Noboru Saitou <noborus@netlab.jp>
143
150
 
144
151
  You may redistribute this software under the same terms as Ruby itself; see
145
- http://www.ruby-lang.org/en/LICENSE.txt or the LICENSE file in the source
152
+ https://www.ruby-lang.org/en/about/license.txt or the BSDL file in the source
146
153
  for details.
147
154
 
148
155
  Portions of the code are from the PostgreSQL project, and are distributed
@@ -158,4 +165,3 @@ to this library over the years.
158
165
 
159
166
  We are thankful to the people at the ruby-list and ruby-dev mailing lists.
160
167
  And to the people who developed PostgreSQL.
161
-
data/Rakefile CHANGED
@@ -55,29 +55,24 @@ $hoespec = Hoe.spec 'pg' do
55
55
  self.extra_rdoc_files = Rake::FileList[ '*.rdoc' ]
56
56
  self.extra_rdoc_files.include( 'POSTGRES', 'LICENSE' )
57
57
  self.extra_rdoc_files.include( 'ext/*.c' )
58
- self.license :BSD
58
+ self.license 'BSD-3-Clause'
59
59
 
60
60
  self.developer 'Michael Granger', 'ged@FaerieMUD.org'
61
61
  self.developer 'Lars Kanis', 'lars@greiz-reinsdorf.de'
62
62
 
63
- self.dependency 'rake-compiler', '~> 0.9', :developer
64
- self.dependency 'hoe', '~> 3.12', :developer
65
- self.dependency 'hoe-deveiate', '~> 0.6', :developer
63
+ self.dependency 'rake-compiler', '~> 1.0', :developer
64
+ self.dependency 'rake-compiler-dock', ['~> 0.6', '>= 0.6.2'], :developer
65
+ self.dependency 'hoe-deveiate', '~> 0.9', :developer
66
66
  self.dependency 'hoe-bundler', '~> 1.0', :developer
67
- self.dependency 'rspec', '~> 3.0', :developer
67
+ self.dependency 'rspec', '~> 3.5', :developer
68
+ self.dependency 'rdoc', '~> 5.1', :developer
68
69
 
69
- self.spec_extras[:licenses] = ['BSD', 'Ruby', 'GPL']
70
70
  self.spec_extras[:extensions] = [ 'ext/extconf.rb' ]
71
71
 
72
- self.require_ruby_version( '>= 1.8.7' )
72
+ self.require_ruby_version( '>= 2.0.0' )
73
73
 
74
74
  self.hg_sign_tags = true if self.respond_to?( :hg_sign_tags= )
75
75
  self.check_history_on_release = true if self.respond_to?( :check_history_on_release= )
76
- self.spec_extras[:rdoc_options] = [
77
- '-f', 'fivefish',
78
- '-t', 'pg: The Ruby Interface to PostgreSQL',
79
- '-m', 'README.rdoc',
80
- ]
81
76
 
82
77
  self.rdoc_locations << "deveiate:/usr/local/www/public/code/#{remote_rdoc_dir}"
83
78
  end
@@ -85,7 +80,7 @@ end
85
80
  ENV['VERSION'] ||= $hoespec.spec.version.to_s
86
81
 
87
82
  # Tests should pass before checking in
88
- task 'hg:precheckin' => [ :check_history, :check_manifest, :spec ]
83
+ task 'hg:precheckin' => [ :check_history, :check_manifest, :spec, :gemspec ]
89
84
 
90
85
  # Support for 'rvm specs'
91
86
  task :specs => :spec
@@ -101,7 +96,7 @@ task :test do
101
96
  # the installed gem dir. So we clear the task rake-compiler set up
102
97
  # to break the dependency between :spec and :compile when running under
103
98
  # rubygems-test, and then run :spec.
104
- Rake::Task[ EXT.to_s ].clear
99
+ Rake::Task[ EXT.to_s ].clear if File.exist?(EXT.to_s)
105
100
  Rake::Task[ :spec ].execute
106
101
  end
107
102
 
@@ -110,8 +105,6 @@ task :maint do
110
105
  ENV['MAINTAINER_MODE'] = 'yes'
111
106
  end
112
107
 
113
- ENV['RUBY_CC_VERSION'] ||= '1.8.7:1.9.2:2.0.0'
114
-
115
108
  # Rake-compiler task
116
109
  Rake::ExtensionTask.new do |ext|
117
110
  ext.name = 'pg_ext'
@@ -136,8 +129,22 @@ Rake::ExtensionTask.new do |ext|
136
129
 
137
130
  # Add libpq.dll to windows binary gemspec
138
131
  ext.cross_compiling do |spec|
139
- # mingw32-platform strings differ (RUBY_PLATFORM=i386-mingw32 vs. x86-mingw32 for rubygems)
140
- spec.files << "lib/#{spec.platform.to_s.gsub(/^x86-/, "i386-")}/libpq.dll"
132
+ spec.files << "lib/libpq.dll"
133
+ end
134
+ end
135
+
136
+
137
+ # Use the fivefish formatter for docs generated from development checkout
138
+ if File.directory?( '.hg' )
139
+ require 'rdoc/task'
140
+
141
+ Rake::Task[ 'docs' ].clear
142
+ RDoc::Task.new( 'docs' ) do |rdoc|
143
+ rdoc.main = "README.rdoc"
144
+ rdoc.rdoc_files.include( "*.rdoc", "ChangeLog", "lib/**/*.rb", 'ext/**/*.{c,h}' )
145
+ rdoc.generator = :fivefish
146
+ rdoc.title = "PG: The Ruby PostgreSQL Driver"
147
+ rdoc.rdoc_dir = 'doc'
141
148
  end
142
149
  end
143
150
 
@@ -146,10 +153,12 @@ end
146
153
  file '.hg/branch' do
147
154
  warn "WARNING: You need the Mercurial repo to update the ChangeLog"
148
155
  end
156
+ Rake::Task["ChangeLog"].clear
149
157
  file 'ChangeLog' do |task|
150
158
  if File.exist?('.hg/branch')
151
159
  $stderr.puts "Updating the changelog..."
152
160
  begin
161
+ include Hoe::MercurialHelpers
153
162
  content = make_changelog()
154
163
  rescue NameError
155
164
  abort "Packaging tasks require the hoe-mercurial plugin (gem install hoe-mercurial)"
@@ -175,13 +184,11 @@ end
175
184
 
176
185
  desc "Update list of server error codes"
177
186
  task :update_error_codes do
178
- URL_ERRORCODES_TXT = "http://git.postgresql.org/gitweb/?p=postgresql.git;a=blob_plain;f=src/backend/utils/errcodes.txt;hb=HEAD"
187
+ URL_ERRORCODES_TXT = "http://git.postgresql.org/gitweb/?p=postgresql.git;a=blob_plain;f=src/backend/utils/errcodes.txt;hb=refs/tags/REL_10_1"
179
188
 
180
189
  ERRORCODES_TXT = "ext/errorcodes.txt"
181
190
  sh "wget #{URL_ERRORCODES_TXT.inspect} -O #{ERRORCODES_TXT.inspect} || curl #{URL_ERRORCODES_TXT.inspect} -o #{ERRORCODES_TXT.inspect}"
182
- end
183
191
 
184
- file 'ext/errorcodes.def' => ['ext/errorcodes.rb', 'ext/errorcodes.txt'] do
185
192
  ruby 'ext/errorcodes.rb', 'ext/errorcodes.txt', 'ext/errorcodes.def'
186
193
  end
187
194
 
@@ -195,12 +202,14 @@ file GEMSPEC => __FILE__
195
202
  task GEMSPEC do |task|
196
203
  spec = $hoespec.spec
197
204
  spec.files.delete( '.gemtest' )
198
- spec.version = "#{spec.version}.pre#{Time.now.strftime("%Y%m%d%H%M%S")}"
205
+ spec.signing_key = nil
206
+ spec.version = "#{spec.version.bump}.0.pre#{Time.now.strftime("%Y%m%d%H%M%S")}"
207
+ spec.cert_chain = [ 'certs/ged.pem' ]
199
208
  File.open( task.name, 'w' ) do |fh|
200
209
  fh.write( spec.to_ruby )
201
210
  end
202
211
  end
203
212
 
204
- CLOBBER.include( GEMSPEC.to_s )
213
+ CLOBBER.include( '*.gemspec' )
205
214
  task :default => :gemspec
206
215
 
data/Rakefile.cross CHANGED
@@ -21,17 +21,28 @@ end
21
21
  class CrossLibrary < OpenStruct
22
22
  include Rake::DSL
23
23
 
24
- def initialize(for_platform, openssl_config)
24
+ def initialize(for_platform, openssl_config, toolchain)
25
25
  super()
26
26
 
27
27
  self.for_platform = for_platform
28
28
  self.openssl_config = openssl_config
29
+ self.host_platform = toolchain
29
30
 
30
31
  # Cross-compilation constants
31
- self.openssl_version = ENV['OPENSSL_VERSION'] || '1.0.1i'
32
- self.postgresql_version = ENV['POSTGRESQL_VERSION'] || '9.3.5'
33
-
34
- self.compile_home = Pathname( "./build" ).expand_path
32
+ self.openssl_version = ENV['OPENSSL_VERSION'] || '1.1.0g'
33
+ self.postgresql_version = ENV['POSTGRESQL_VERSION'] || '10.1'
34
+
35
+ # Check if symlinks work in the current working directory.
36
+ # This fails, if rake-compiler-dock is running on a Windows box.
37
+ begin
38
+ FileUtils.rm_f '.test_symlink'
39
+ FileUtils.ln_s '/', '.test_symlink'
40
+ rescue SystemCallError
41
+ # Symlinks don't work -> use home directory instead
42
+ self.compile_home = Pathname( "~/.ruby-pg-build" ).expand_path
43
+ else
44
+ self.compile_home = Pathname( "./build" ).expand_path
45
+ end
35
46
  self.static_sourcesdir = compile_home + 'sources'
36
47
  self.static_builddir = compile_home + 'builds' + for_platform
37
48
 
@@ -43,8 +54,8 @@ class CrossLibrary < OpenStruct
43
54
  self.openssl_tarball = static_sourcesdir + File.basename( openssl_source_uri.path )
44
55
  self.openssl_makefile = static_openssl_builddir + 'Makefile'
45
56
 
46
- self.libssleay32 = static_openssl_builddir + 'libssleay32.a'
47
- self.libeay32 = static_openssl_builddir + 'libeay32.a'
57
+ self.libssl = static_openssl_builddir + 'libssl.a'
58
+ self.libcrypto = static_openssl_builddir + 'libcrypto.a'
48
59
 
49
60
  self.openssl_patches = Rake::FileList[ (MISCDIR + "openssl-#{openssl_version}.*.patch").to_s ]
50
61
 
@@ -67,23 +78,10 @@ class CrossLibrary < OpenStruct
67
78
  self.postgresql_lib = static_postgresql_libdir + 'libpq.dll'
68
79
  self.postgresql_patches = Rake::FileList[ (MISCDIR + "postgresql-#{postgresql_version}.*.patch").to_s ]
69
80
 
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\["CC"\] = "(.*)"/)[1].sub(/\-gcc/, '')
76
- rescue
77
- nil
78
- end
79
-
80
-
81
81
  # clean intermediate files and folders
82
82
  CLEAN.include( static_builddir.to_s )
83
83
 
84
84
 
85
- ENV['RUBY_CC_VERSION'] ||= '1.9.3:2.0.0'
86
-
87
85
  def download(url, save_to)
88
86
  part = save_to+".part"
89
87
  sh "wget #{url.to_s.inspect} -O #{part.inspect} || curl #{url.to_s.inspect} -o #{part.inspect}"
@@ -126,11 +124,9 @@ class CrossLibrary < OpenStruct
126
124
  end
127
125
 
128
126
  self.cmd_prelude = [
129
- 'env',
130
- "CC=#{host_platform}-gcc",
127
+ "env",
128
+ "CROSS_COMPILE=#{host_platform}-",
131
129
  "CFLAGS=-DDSO_WIN32",
132
- "AR=#{host_platform}-ar",
133
- "RANLIB=#{host_platform}-ranlib"
134
130
  ]
135
131
 
136
132
 
@@ -145,7 +141,7 @@ class CrossLibrary < OpenStruct
145
141
  end
146
142
 
147
143
  desc "compile static openssl libraries"
148
- task :openssl_libs => [ libssleay32, libeay32 ]
144
+ task :openssl_libs => [ libssl, libcrypto ]
149
145
 
150
146
  task :compile_static_openssl => openssl_makefile do |t|
151
147
  chdir( static_openssl_builddir ) do
@@ -156,14 +152,14 @@ class CrossLibrary < OpenStruct
156
152
  end
157
153
  end
158
154
 
159
- desc "compile static #{libeay32}"
160
- file libeay32 => :compile_static_openssl do |t|
161
- FileUtils.cp( static_openssl_builddir + 'libcrypto.a', libeay32.to_s )
155
+ desc "compile static #{libssl}"
156
+ file libssl => :compile_static_openssl do |t|
157
+ rm t.name.gsub(/\.a$/, ".dll.a")
162
158
  end
163
159
 
164
- desc "compile static #{libssleay32}"
165
- file libssleay32 => :compile_static_openssl do |t|
166
- FileUtils.cp( static_openssl_builddir + 'libssl.a', libssleay32.to_s )
160
+ desc "compile static #{libcrypto}"
161
+ file libcrypto => :compile_static_openssl do |t|
162
+ rm t.name.gsub(/\.a$/, ".dll.a")
167
163
  end
168
164
 
169
165
 
@@ -207,7 +203,7 @@ class CrossLibrary < OpenStruct
207
203
  cmd << "CFLAGS=-L#{static_openssl_builddir}"
208
204
  cmd << "LDFLAGS=-L#{static_openssl_builddir}"
209
205
  cmd << "LDFLAGS_SL=-L#{static_openssl_builddir}"
210
- cmd << "LIBS=-lwsock32 -lgdi32"
206
+ cmd << "LIBS=-lwsock32 -lgdi32 -lws2_32"
211
207
  cmd << "CPPFLAGS=-I#{static_openssl_builddir}/include"
212
208
 
213
209
  run( *cmd )
@@ -217,11 +213,16 @@ class CrossLibrary < OpenStruct
217
213
 
218
214
  # make libpq.dll
219
215
  task postgresql_lib => [ postgresql_global_makefile ] do |t|
216
+ # Work around missing dependency to libcommon in PostgreSQL-9.4.0
217
+ chdir( static_postgresql_srcdir + "common" ) do
218
+ sh 'make', "-j#{NUM_CPUS}"
219
+ end
220
+
220
221
  chdir( postgresql_lib.dirname ) do
221
222
  sh 'make',
222
223
  "-j#{NUM_CPUS}",
223
224
  postgresql_lib.basename.to_s,
224
- 'SHLIB_LINK=-lssleay32 -leay32 -lcrypt32 -lgdi32 -lsecur32 -lwsock32 -lws2_32'
225
+ 'SHLIB_LINK=-lssl -lcrypto -lcrypt32 -lgdi32 -lsecur32 -lwsock32 -lws2_32'
225
226
  end
226
227
  end
227
228
 
@@ -230,7 +231,7 @@ class CrossLibrary < OpenStruct
230
231
  task :libpq => postgresql_lib
231
232
 
232
233
  # copy libpq.dll to lib dir
233
- dest_libpq = "lib/#{for_platform}/#{postgresql_lib.basename}"
234
+ dest_libpq = "lib/#{postgresql_lib.basename}"
234
235
  directory File.dirname(dest_libpq)
235
236
  file dest_libpq => [postgresql_lib, File.dirname(dest_libpq)] do
236
237
  cp postgresql_lib, dest_libpq
@@ -246,10 +247,10 @@ end
246
247
 
247
248
  if File.exist?(File.expand_path("~/.rake-compiler/config.yml"))
248
249
  CrossLibraries = [
249
- ['i386-mingw32', 'mingw'],
250
- ['x64-mingw32', 'mingw64'],
251
- ].map do |platform, openssl_config|
252
- CrossLibrary.new platform, openssl_config
250
+ ['i386-mingw32', 'mingw', 'i686-w64-mingw32'],
251
+ ['x64-mingw32', 'mingw64', 'x86_64-w64-mingw32'],
252
+ ].map do |platform, openssl_config, toolchain|
253
+ CrossLibrary.new platform, openssl_config, toolchain
253
254
  end
254
255
  else
255
256
  $stderr.puts "Cross-compilation disabled -- rake-compiler not properly installed"
@@ -278,3 +279,20 @@ ENV['RUBY_CC_VERSION'].to_s.split(':').each do |ruby_version|
278
279
  sh "x86_64-w64-mingw32-strip -S tmp/x64-mingw32/stage/lib/#{ruby_version[/^\d+\.\d+/]}/pg_ext.so"
279
280
  end
280
281
  end
282
+
283
+ desc "Build the windows binary gems"
284
+ task 'gem:windows' => ['ChangeLog'] do
285
+ require 'rake_compiler_dock'
286
+
287
+ # Copy gem signing key and certs to be accessable from the docker container
288
+ mkdir_p 'build/gem'
289
+ sh "cp ~/.gem/gem-*.pem build/gem/ || true"
290
+ sh "bundle package"
291
+
292
+ RakeCompilerDock.sh <<-EOT
293
+ mkdir ~/.gem &&
294
+ (cp build/gem/gem-*.pem ~/.gem/ || true) &&
295
+ bundle install --local &&
296
+ rake cross native gem RUBY_CC_VERSION=2.5.0:2.4.0:2.3.0:2.2.2:2.1.6:2.0.0
297
+ EOT
298
+ end