pg 0.11.0-x86-mingw32 → 0.12.0-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. data/.gemtest +0 -0
  2. data/ChangeLog +1647 -462
  3. data/Contributors.rdoc +39 -0
  4. data/History.rdoc +61 -0
  5. data/Manifest.txt +43 -0
  6. data/README.OS_X.rdoc +68 -0
  7. data/README.ja.rdoc +7 -0
  8. data/{README → README.rdoc} +38 -18
  9. data/{README.windows → README.windows.rdoc} +23 -31
  10. data/Rakefile +104 -318
  11. data/Rakefile.cross +234 -0
  12. data/ext/compat.c +2 -2
  13. data/ext/extconf.rb +10 -2
  14. data/ext/pg.c +223 -43
  15. data/ext/vc/pg.sln +26 -0
  16. data/ext/vc/pg_18/pg.vcproj +216 -0
  17. data/ext/vc/pg_19/pg_19.vcproj +209 -0
  18. data/lib/1.8/pg_ext.so +0 -0
  19. data/lib/1.9/pg_ext.so +0 -0
  20. data/lib/pg.rb +5 -7
  21. data/misc/openssl-pg-segfault.rb +31 -0
  22. data/sample/async_api.rb +109 -0
  23. data/sample/async_copyto.rb +39 -0
  24. data/sample/copyfrom.rb +81 -0
  25. data/sample/copyto.rb +19 -0
  26. data/sample/cursor.rb +21 -0
  27. data/sample/losample.rb +69 -0
  28. data/sample/notify_wait.rb +43 -0
  29. data/sample/psql.rb +1181 -0
  30. data/sample/psqlHelp.rb +158 -0
  31. data/sample/test1.rb +60 -0
  32. data/sample/test2.rb +44 -0
  33. data/sample/test4.rb +71 -0
  34. data/sample/test_binary_values.rb +35 -0
  35. data/spec/lib/helpers.rb +6 -4
  36. data/spec/m17n_spec.rb +2 -2
  37. data/spec/pgconn_spec.rb +51 -6
  38. data/spec/pgresult_spec.rb +30 -4
  39. metadata +147 -86
  40. data.tar.gz.sig +0 -3
  41. data/Contributors +0 -32
  42. data/README.OS_X +0 -19
  43. data/README.ja +0 -183
  44. data/Rakefile.local +0 -312
  45. data/rake/191_compat.rb +0 -26
  46. data/rake/dependencies.rb +0 -76
  47. data/rake/documentation.rb +0 -123
  48. data/rake/helpers.rb +0 -502
  49. data/rake/hg.rb +0 -318
  50. data/rake/manual.rb +0 -787
  51. data/rake/packaging.rb +0 -129
  52. data/rake/publishing.rb +0 -341
  53. data/rake/style.rb +0 -62
  54. data/rake/svn.rb +0 -668
  55. data/rake/testing.rb +0 -152
  56. data/rake/verifytask.rb +0 -64
  57. metadata.gz.sig +0 -3
@@ -0,0 +1,39 @@
1
+
2
+ Thanks to all the great people that have contributed code, suggestions, and patches through the
3
+ years. If you contribute a patch, please include a patch for this file that adds your name to the
4
+ list.
5
+
6
+ * Dennis Vshivkov <walrus@amur.ru>
7
+ * Gabriel Emerson <gemerson@evalsoft.com>
8
+ * Noboru Saitou <noborus@netlab.jp>
9
+ * Akinori MUSHA <knu@iDaemons.org>
10
+ * Andy Yu <is@gnuchina.org>
11
+ * Ceri Storey <cez@compsoc.man.ac.uk>
12
+ * Gavin Kistner <gavin@refinery.com>
13
+ * Henry T. So Jr. <henryso@panix.com>
14
+ * Jeremy Henty <jeremy@chaos.org.uk>
15
+ * <kasa@air.linkclub.or.jp>
16
+ * Leon Brooks <leon-ruby-postgres@cyberknights.com.au>
17
+ * Martin Hedenfalk <mahe@kth.se>
18
+ * Yukihiro Matsumoto <matz@zetabits.com>
19
+ * Eiji Matsumoto <usagi@ruby.club.or.jp>
20
+ * MoonWolf <moonwolf@moonwolf.com>
21
+ * <m_seki@mva.biglobe.ne.jp>
22
+ * Nate Haggard <nate@wordplace.com>
23
+ * Neil Conway <nconway@klamath.dyndns.org>
24
+ * Noboru Matui <silicon@mx1.freemail.ne.jp>
25
+ * Okada Jun <yun@be-in.org>
26
+ * Shirai,Kaoru <shirai@p1jp.com>
27
+ * Riley <wormwood@speakeasy.org>
28
+ * shibata <kshibata@vesta.ocn.ne.jp>
29
+ * <greentea@fa2.so-net.ne.jp>
30
+ * ts <decoux@moulon.inra.fr>
31
+ * Yuta TSUBOI <yuuta-t@is.aist-nara.ac.jp>
32
+ * Lugovoi Nikolai <meadow.nnick@gmail.com>
33
+ * Jeff Davis <ruby@j-davis.com>
34
+ * Bertram Scharpf <software@bertram-scharpf.de>
35
+ * Michael Granger <ged@FaerieMUD.org>
36
+ * Mahlon E. Smith <mahlon@martini.nu>
37
+ * Lars Kanis <kanis@comcard.de>
38
+ * Jason Yanowitz <me-bitbucket@jasonyanowitz.com>
39
+
@@ -0,0 +1,61 @@
1
+ == v0.12.0 [2011-12-07] Michael Granger <ged@FaerieMUD.org>
2
+
3
+ - PGconn#wait_for_notify
4
+ * send nil as the payload argument if the NOTIFY didn't have one.
5
+ * accept a nil argument for no timeout (Sequel support)
6
+ * Fixed API docs
7
+ * Taint and encode event name and payload
8
+ - Handle errors while rb_thread_select()ing in PGconn#block.
9
+ (Brian Weaver).
10
+ - Fixes for Win32 async queries (Rafał Bigaj)
11
+ - Memory leak fixed: Closing opened WSA event. (rafal)
12
+ - Fixes for #66 Win32 asynchronous queries hang on connection
13
+ error. (rafal)
14
+ - Fixed a typo in PGconn#error_message's documentation
15
+ - fixing unused variable warnings for ruby 1.9.3 (Aaron Patterson)
16
+ - Build system bugfixes
17
+ - Converted to Hoe
18
+ - Updates for the Win32 binary gem builds (Lars Kanis)
19
+
20
+
21
+ == v0.11.0 [2011-02-09] Michael Granger <ged@FaerieMUD.org>
22
+
23
+ Enhancements:
24
+
25
+ * Added a PGresult#values method to fetch all result rows as an Array of
26
+ Arrays. Thanks to Jason Yanowitz (JYanowitz at enovafinancial dot com) for
27
+ the patch.
28
+
29
+
30
+ == v0.10.1 [2011-01-19] Michael Granger <ged@FaerieMUD.org>
31
+
32
+ Bugfixes:
33
+
34
+ * Add an include guard for pg.h
35
+ * Simplify the common case require of the ext
36
+ * Include the extconf header
37
+ * Fix compatibility with versions of PostgreSQL without PQgetCancel. (fixes #36)
38
+ * Fix require for natively-compiled extension under Windows. (fixes #55)
39
+ * Change rb_yield_splat() to rb_yield_values() for compatibility with Rubinius. (fixes #54)
40
+
41
+
42
+ == v0.10.0 [2010-12-01] Michael Granger <ged@FaerieMUD.org>
43
+
44
+ Enhancements:
45
+
46
+ * Added support for the payload of NOTIFY events (w/Mahlon E. Smith)
47
+ * Updated the build system with Rubygems suggestions from RubyConf 2010
48
+
49
+ Bugfixes:
50
+
51
+ * Fixed issue with PGconn#wait_for_notify that caused it to miss notifications that happened after
52
+ the LISTEN but before the wait_for_notify.
53
+
54
+ == v0.9.0 [2010-02-28] Michael Granger <ged@FaerieMUD.org>
55
+
56
+ Bugfixes.
57
+
58
+ == v0.8.0 [2009-03-28] Jeff Davis <davis.jeffrey@gmail.com>
59
+
60
+ Bugfixes, better Windows support.
61
+
@@ -0,0 +1,43 @@
1
+ .gemtest
2
+ BSD
3
+ ChangeLog
4
+ Contributors.rdoc
5
+ GPL
6
+ History.rdoc
7
+ LICENSE
8
+ Manifest.txt
9
+ README.OS_X.rdoc
10
+ README.ja.rdoc
11
+ README.rdoc
12
+ README.windows.rdoc
13
+ Rakefile
14
+ Rakefile.cross
15
+ ext/compat.c
16
+ ext/compat.h
17
+ ext/extconf.rb
18
+ ext/pg.c
19
+ ext/pg.h
20
+ ext/vc/pg.sln
21
+ ext/vc/pg_18/pg.vcproj
22
+ ext/vc/pg_19/pg_19.vcproj
23
+ lib/pg.rb
24
+ misc/openssl-pg-segfault.rb
25
+ sample/async_api.rb
26
+ sample/async_copyto.rb
27
+ sample/copyfrom.rb
28
+ sample/copyto.rb
29
+ sample/cursor.rb
30
+ sample/losample.rb
31
+ sample/notify_wait.rb
32
+ sample/psql.rb
33
+ sample/psqlHelp.rb
34
+ sample/test1.rb
35
+ sample/test2.rb
36
+ sample/test4.rb
37
+ sample/test_binary_values.rb
38
+ spec/data/expected_trace.out
39
+ spec/data/random_binary_data
40
+ spec/lib/helpers.rb
41
+ spec/m17n_spec.rb
42
+ spec/pgconn_spec.rb
43
+ spec/pgresult_spec.rb
@@ -0,0 +1,68 @@
1
+ = Compiling on MacOS X
2
+
3
+ The EnterpriseDB packages are the recommended PostgreSQL installations to use
4
+ with MacOS X. They eliminate most or all of the issues with getting 'pg'
5
+ installed, linked correctly, and running.
6
+
7
+ == Segfaults and SSL Support
8
+
9
+ If you need a custom installation of PostgreSQL, you should ensure that you
10
+ either compile it against the same version of OpenSSL as the OpenSSL extension
11
+ of the Ruby you'll be using, or compile it without SSL support. If you fail to
12
+ do this, you will likely see segfaults when you use 'pg' and the 'openssl'
13
+ extension at the same time. You can see what library it's linked against using
14
+ 'otool -L'; for example, on my 10.7 machine I use for 'pg' development:
15
+
16
+ $ otool -L /System/Library/Frameworks/Ruby.framework/Versions\
17
+ /1.8/usr/lib/ruby/1.8/universal-darwin11.0/openssl.bundle
18
+
19
+ /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/\
20
+ lib/ruby/1.8/universal-darwin11.0/openssl.bundle:
21
+ /System/Library/Frameworks/Ruby.framework/Versions/1.8/\
22
+ usr/lib/libruby.1.dylib (compatibility version 1.8.0, \
23
+ current version 1.8.7)
24
+ /usr/lib/libssl.0.9.8.dylib (compatibility version 0.9.8, \
25
+ current version 0.9.8)
26
+ /usr/lib/libcrypto.0.9.8.dylib (compatibility version 0.9.8, \
27
+ current version 0.9.8)
28
+ /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, \
29
+ current version 159.0.0)
30
+
31
+
32
+ == Dealing with Installation Problems
33
+
34
+ If you are building/installing pg on MacOS X, and the installation doesn't
35
+ work at first, here are a few things you can try.
36
+
37
+ === pg_config
38
+
39
+ The first thing you should do is ensure that the 'pg_config' tool that comes
40
+ with Postgres is in your path. If it isn't, or the one that's first in your
41
+ path isn't the one that was installed with the Postgres you want to build
42
+ against, you can specify the path to it with the --with-pg-config option.
43
+
44
+ For example, if you're using the Ruby binary that comes with OSX, and
45
+ PostgreSQL 9.0.x installed from MacPorts, do:
46
+
47
+ gem install -- --with-pg-config=/opt/local/lib/postgresql90/bin/pg_config
48
+
49
+ === ARCHFLAGS and Universal Binaries
50
+
51
+ OS X supports both architecture-specific binaries (e.g. i386), as well as
52
+ universal binaries (i.e. i386 & ppc). If Ruby is built as a universal binary
53
+ and PostgreSQL is not, you need to specify the path to the appropriate
54
+ pg_config binary or set the environment variable ARCHFLAGS appropriately.
55
+
56
+ Alternatively, if the build system can't figure out which architectures it
57
+ should include, you may need to set the 'ARCHFLAGS' environment variable
58
+ explicitly:
59
+
60
+ sudo env ARCHFLAGS='-arch x86_64' gem install pg
61
+
62
+ or, if you're building from source:
63
+
64
+ rake compile ARCHFLAGS="-arch x86_64"
65
+
66
+ Note that the recommended EnterpriseDB packages are correctly compiled as
67
+ universal binaries, and don't need any of these workarounds.
68
+
@@ -0,0 +1,7 @@
1
+ = pg
2
+
3
+ * https://bitbucket.org/ged/ruby-pg
4
+
5
+ This file needs translation. Anyone who is willing to volunteer, please
6
+ mail <ged@FaerieMUD.org>.
7
+
@@ -1,54 +1,74 @@
1
- = ruby-pg: Ruby interface to PostgreSQL RDBMS
1
+ = pg
2
+
3
+ * https://bitbucket.org/ged/ruby-pg
4
+
5
+ == Description
6
+
7
+ Pg is the Ruby interface to the {PostgreSQL RDBMS}[http://www.postgresql.org/].
8
+
9
+ It works with PostgreSQL 8.2 and later.
10
+
11
+ This will be the last minor version to support 8.2 -- 0.13 will support 8.3
12
+ and later, following the
13
+ {PostgreSQL Release Support Policy}[http://bit.ly/6AfPhm].
14
+
2
15
 
3
- This is the extension library to access a PostgreSQL database from Ruby. This
4
- library works with PostgreSQL 7.4 and later.
5
16
 
6
17
  == Requirements
7
18
 
8
- * Ruby 1.8.7-p174 or later.
9
- * PostgreSQL 7.4 or later installed.
19
+ * Ruby 1.8.7-p249 or later.
20
+ * PostgreSQL 8.2.x or later installed.
10
21
 
11
22
  It may work with earlier versions as well, but those are not regularly tested.
12
23
 
24
+
13
25
  == How To Install
14
26
 
15
27
  Install via RubyGems:
16
28
 
17
- gem install pg
18
-
19
- Or install from source:
20
-
21
- rake install
29
+ gem install pg
22
30
 
23
31
  You may need to specify the path to the 'pg_config' program installed with
24
32
  Postgres:
25
33
 
26
- rake -- --with-pg-config=<path to pg_config>
34
+ gem install pg -- --with-pg-config=<path to pg_config>
35
+
36
+ See README.OS_X.rdoc for more information about installing under MacOS X, and
37
+ README.windows.rdoc for Windows build/installation instructions.
27
38
 
28
- For example, on a Mac with PostgreSQL installed via MacPorts
29
- (<tt>port install postgresql84</tt>):
30
39
 
31
- rake install -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
40
+ == Contributing
41
+
42
+ To report bugs, suggest features, or check out the source with Mercurial,
43
+ {check out the project page}[http://bitbucket.org/ged/ruby-pg]. If you prefer
44
+ Git, there's also a {Github mirror}[https://github.com/ged/ruby-pg].
45
+
46
+ After checking out the source, run:
47
+
48
+ $ rake newb
49
+
50
+ This task will install any missing dependencies, run the tests/specs, and
51
+ generate the API documentation.
32
52
 
33
- See README.OS_X for more information about installing under MacOS X, and
34
- README.windows for Windows build/installation instructions.
35
53
 
36
54
  == Copying
37
55
 
38
56
  This library is copyrighted by the authors.
39
57
 
40
58
  Authors:
59
+
41
60
  * Yukihiro Matsumoto <matz@ruby-lang.org> - Author of Ruby.
42
61
  * Eiji Matsumoto <usagi@ruby.club.or.jp> - One of users who loves Ruby.
43
62
  * Jeff Davis <ruby-pg@j-davis.com>
44
63
 
45
64
  Thanks to:
65
+
46
66
  * Noboru Saitou <noborus@netlab.jp> - Past maintainer.
47
67
  * Dave Lee - Past maintainer.
48
68
  * Guy Decoux (ts) <decoux@moulon.inra.fr>
49
69
 
50
70
  Maintainers:
51
- * Jeff Davis <ruby-pg@j-davis.com>
71
+
52
72
  * Michael Granger <ged@FaerieMUD.org>
53
73
 
54
74
  You may redistribute this software under the terms of the Ruby license,
@@ -60,9 +80,9 @@ under the terms of the BSD license, included in the file "BSD".
60
80
 
61
81
  Portions copyright LAIKA, Inc.
62
82
 
83
+
63
84
  == Acknowledgments
64
85
 
65
86
  We are thankful to the people at the ruby-list and ruby-dev mailing lists.
66
87
  And to the people who developed PostgreSQL.
67
88
 
68
-
@@ -1,5 +1,4 @@
1
-
2
- = Compiling on MS Windows
1
+ = Compiling 'pg' on MS Windows
3
2
 
4
3
  In order to build this extension on MS Windows you will need a couple things.
5
4
 
@@ -24,7 +23,7 @@ In order to build ruby-pg, just run 'rake'. If the pg_config.exe executable
24
23
  is not in your PATH, you'll need to explicitly point ruby-pg to where your
25
24
  PostgreSQL headers and libraries are with something like this:
26
25
 
27
- rake --with-pg-dir=c:/progra~1/postgr~1/8.3
26
+ rake --with-pg-dir=c:/progra~1/postgr~1/8.3
28
27
 
29
28
  Adjust your path accordingly. BE SURE TO USE THE SHORT PATH NAMES! If you
30
29
  try to use a path with spaces in it, the nmake.exe program will choke.
@@ -32,44 +31,37 @@ try to use a path with spaces in it, the nmake.exe program will choke.
32
31
 
33
32
  == Cross compiling for mswin32
34
33
 
35
- Using rake-compiler a cross compiled pg-gem can be build on a linux host for
36
- the win32 platform. The generated gem is statically linked against libpq and
37
- libssl. OpenSSL and PostgreSQL are downloaded and compiled from the sources.
38
- There are no runtime dependencies to any but the standard Windows DLLs.
39
-
40
- Install mingw32. On a debian based system this should work:
41
-
42
- apt-get install mingw32
43
-
44
- On MacOS X, if you have MacPorts installed:
45
-
46
- port install i386-mingw32-gcc
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.
47
39
 
48
- Install the rake-compiler:
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.
49
43
 
50
- gem install rake-compiler
44
+ Download and cross compile ruby 1.8 and 1.9 for win32 with:
51
45
 
52
- Download and cross compile ruby 1.8 and 1.9 for win32:
53
-
54
- rake-compiler cross-ruby VERSION=1.8.7-p334
55
- rake-compiler cross-ruby VERSION=1.9.2-p180
46
+ rake-compiler cross-ruby VERSION=1.8.7-p352
47
+ rake-compiler cross-ruby VERSION=1.9.2-p290
56
48
 
57
49
  Download and cross compile pg for win32:
58
50
 
59
- rake cross native gem
60
- or with custom versions:
61
- rake cross native gem RUBY_CC_VERSION=1.8.7:1.9.2 OPENSSL_VERSION=1.0.0d POSTGRESQL_VERSION=9.0.3
51
+ rake cross native gem
62
52
 
63
- If everything works, there should be pg-VERSION-x86-mswin32.gem in the pkg
64
- directory.
53
+ or with custom versions:
65
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
66
57
 
67
- If you have any problems you can submit them via the project's issue-tracker:
58
+ If everything works, there should be pg-VERSION-x86-mingw32.gem in the pkg
59
+ directory.
68
60
 
69
- http://bitbucket.org/ged/ruby-pg/issues/new/
70
61
 
71
- Or you can join the mailing list:
62
+ == Reporting Problems
72
63
 
73
- ruby-pg-general@rubyforge.org
64
+ If you have any problems you can submit them via
65
+ [the project's issue-tracker][bitbucket]. And submit questions, problems, or
66
+ solutions, so that it can be improved.
74
67
 
75
- And submit questions, problems, or solutions, so that it can be improved.
data/Rakefile CHANGED
@@ -1,364 +1,150 @@
1
- #!rake -*- ruby -*-
2
- #
3
- # pg rakefile
4
- #
5
- # Based on various other Rakefiles, especially one by Ben Bleything
6
- #
7
- # Copyright (c) 2007-2010 The FaerieMUD Consortium
8
- #
9
- # Authors:
10
- # * Michael Granger <ged@FaerieMUD.org>
11
- #
12
-
13
- BEGIN {
14
- require 'rbconfig'
15
- require 'pathname'
16
- basedir = Pathname.new( __FILE__ ).dirname
17
-
18
- libdir = basedir + "lib"
19
- extdir = libdir + Config::CONFIG['sitearch']
20
-
21
- $LOAD_PATH.unshift( basedir.to_s ) unless $LOAD_PATH.include?( basedir.to_s )
22
- $LOAD_PATH.unshift( libdir.to_s ) unless $LOAD_PATH.include?( libdir.to_s )
23
- $LOAD_PATH.unshift( extdir.to_s ) unless $LOAD_PATH.include?( extdir.to_s )
24
- }
1
+ #!/usr/bin/env rake
2
+
3
+ require 'rbconfig'
4
+ require 'pathname'
5
+ require 'tmpdir'
25
6
 
26
7
  begin
27
- require 'readline'
28
- include Readline
8
+ require 'rake/extensiontask'
29
9
  rescue LoadError
30
- # Fall back to a plain prompt
31
- def readline( text )
32
- $stderr.print( text.chomp )
33
- return $stdin.gets
34
- end
10
+ abort "This Rakefile requires rake-compiler (gem install rake-compiler)"
35
11
  end
36
12
 
37
13
  begin
38
- require 'rubygems'
14
+ require 'hoe'
39
15
  rescue LoadError
40
- module Gem
41
- class Specification; end
42
- end
16
+ abort "This Rakefile requires hoe (gem install hoe)"
43
17
  end
44
18
 
45
- require 'rbconfig'
46
- require 'rake'
47
- require 'rake/testtask'
48
- require 'rake/packagetask'
49
19
  require 'rake/clean'
50
- # require 'rake/191_compat.rb'
51
-
52
- $dryrun = false
53
-
54
- ### Config constants
55
- BASEDIR = Pathname.new( __FILE__ ).dirname.relative_path_from( Pathname.getwd )
56
- BINDIR = BASEDIR + 'bin'
57
- LIBDIR = BASEDIR + 'lib'
58
- EXTDIR = BASEDIR + 'ext'
59
- DOCSDIR = BASEDIR + 'docs'
60
- PKGDIR = BASEDIR + 'pkg'
61
- DATADIR = BASEDIR + 'data'
62
-
63
- MANUALDIR = DOCSDIR + 'manual'
64
-
65
- PROJECT_NAME = 'pg'
66
- PKG_NAME = PROJECT_NAME.downcase
67
- PKG_SUMMARY = 'A Ruby interface to the PostgreSQL RDBMS'
68
-
69
- # Cruisecontrol stuff
70
- CC_BUILD_LABEL = ENV['CC_BUILD_LABEL']
71
- CC_BUILD_ARTIFACTS = ENV['CC_BUILD_ARTIFACTS'] || 'artifacts'
72
-
73
- VERSION_FILE = LIBDIR + '../ext/pg.c'
74
- if VERSION_FILE.exist? && buildrev = ENV['CC_BUILD_LABEL']
75
- PKG_VERSION = VERSION_FILE.read[ /VERSION\s*=\s*['"](\d+\.\d+\.\d+)['"]/, 1 ] + '.' + buildrev
76
- elsif VERSION_FILE.exist?
77
- PKG_VERSION = VERSION_FILE.read[ /VERSION\s*=\s*['"](\d+\.\d+\.\d+)['"]/, 1 ]
78
- end
79
20
 
80
- PKG_VERSION = '0.0.0' unless defined?( PKG_VERSION ) && !PKG_VERSION.nil?
21
+ # Build directory constants
22
+ BASEDIR = Pathname( __FILE__ ).dirname
23
+ SPECDIR = BASEDIR + 'spec'
24
+ LIBDIR = BASEDIR + 'lib'
25
+ EXTDIR = BASEDIR + 'ext'
26
+ PKGDIR = BASEDIR + 'pkg'
27
+ TMPDIR = BASEDIR + 'tmp'
81
28
 
82
- PKG_FILE_NAME = "#{PKG_NAME.downcase}-#{PKG_VERSION}"
83
- GEM_FILE_NAME = "#{PKG_FILE_NAME}.gem"
29
+ DLEXT = Config::CONFIG['DLEXT']
30
+ EXT = LIBDIR + "pg_ext.#{DLEXT}"
84
31
 
85
- # Universal VCS constants
86
- DEFAULT_EDITOR = 'vi'
87
- COMMIT_MSG_FILE = 'commit-msg.txt'
88
- FILE_INDENT = " " * 12
89
- LOG_INDENT = " " * 3
32
+ TEST_DIRECTORY = BASEDIR + "tmp_test_specs"
90
33
 
91
- EXTCONF = EXTDIR + 'extconf.rb'
34
+ CLOBBER.include( TEST_DIRECTORY.to_s )
35
+ CLEAN.include( PKGDIR.to_s, TMPDIR.to_s )
92
36
 
93
- ARTIFACTS_DIR = Pathname.new( CC_BUILD_ARTIFACTS )
37
+ # Set up Hoe plugins
38
+ Hoe.plugin :mercurial
39
+ Hoe.plugin :signing
94
40
 
95
- TEXT_FILES = Rake::FileList.new( %w[Rakefile ChangeLog README* LICENSE] )
96
- BIN_FILES = Rake::FileList.new( "#{BINDIR}/*" )
97
- LIB_FILES = Rake::FileList.new( "#{LIBDIR}/**/*.rb" )
98
- EXT_FILES = Rake::FileList.new( "#{EXTDIR}/**/*.{c,h,rb}" )
99
- DATA_FILES = Rake::FileList.new( "#{DATADIR}/**/*" )
41
+ Hoe.plugins.delete :rubyforge
42
+ Hoe.plugins.delete :compiler
100
43
 
101
- SPECDIR = BASEDIR + 'spec'
102
- SPECLIBDIR = SPECDIR + 'lib'
103
- SPEC_FILES = Rake::FileList.new( "#{SPECDIR}/**/*_spec.rb", "#{SPECLIBDIR}/**/*.rb" )
44
+ load 'Rakefile.cross'
104
45
 
105
- TESTDIR = BASEDIR + 'tests'
106
- TEST_FILES = Rake::FileList.new( "#{TESTDIR}/**/*.tests.rb" )
107
46
 
108
- RAKE_TASKDIR = BASEDIR + 'rake'
109
- RAKE_TASKLIBS = Rake::FileList.new( "#{RAKE_TASKDIR}/*.rb" )
110
- PKG_TASKLIBS = Rake::FileList.new( "#{RAKE_TASKDIR}/{191_compat,helpers,packaging,rdoc,testing}.rb" )
111
- PKG_TASKLIBS.include( "#{RAKE_TASKDIR}/manual.rb" ) if MANUALDIR.exist?
47
+ # Hoe specification
48
+ $hoespec = Hoe.spec 'pg' do
49
+ self.readme_file = 'README.rdoc'
50
+ self.history_file = 'History.rdoc'
51
+ self.extra_rdoc_files = Rake::FileList[ '*.rdoc' ]
52
+ self.extra_rdoc_files.include( 'BSD', 'GPL', 'LICENSE' )
53
+ self.extra_rdoc_files.include( 'ext/*.c' )
112
54
 
113
- RAKE_TASKLIBS_URL = 'http://repo.deveiate.org/rake-tasklibs'
55
+ self.developer 'Jeff Davis', 'ruby-pg@j-davis.com'
56
+ self.developer 'Michael Granger', 'ged@FaerieMUD.org'
114
57
 
115
- LOCAL_RAKEFILE = BASEDIR + 'Rakefile.local'
58
+ self.dependency 'rake-compiler', '~> 0.7'
59
+ self.dependency 'rspec', '~> 2.6', :developer
116
60
 
117
- EXTRA_PKGFILES = Rake::FileList.new
118
- EXTRA_PKGFILES.include( "#{BASEDIR}/README.*" )
119
- EXTRA_PKGFILES.include( "#{BASEDIR}/GPL" )
120
- EXTRA_PKGFILES.include( "#{BASEDIR}/BSD" )
121
- EXTRA_PKGFILES.include( "#{BASEDIR}/Contributors" )
61
+ self.spec_extras[:licenses] = ['BSD', 'Ruby', 'GPL']
62
+ self.spec_extras[:extensions] = [ 'ext/extconf.rb' ]
122
63
 
123
- RELEASE_FILES = TEXT_FILES +
124
- SPEC_FILES +
125
- TEST_FILES +
126
- BIN_FILES +
127
- LIB_FILES +
128
- EXT_FILES +
129
- DATA_FILES +
130
- RAKE_TASKLIBS +
131
- EXTRA_PKGFILES
64
+ self.require_ruby_version( '>= 1.8.7' )
132
65
 
66
+ self.hg_sign_tags = true if self.respond_to?( :hg_sign_tags= )
67
+ self.check_history_on_release = true if self.respond_to?( :check_history_on_release= )
133
68
 
134
- RELEASE_FILES << LOCAL_RAKEFILE.to_s if LOCAL_RAKEFILE.exist?
69
+ self.rdoc_locations << "deveiate:/usr/local/www/public/code/#{remote_rdoc_dir}"
70
+ end
135
71
 
136
- RELEASE_ANNOUNCE_ADDRESSES = [
137
- "Ruby-Talk List <ruby-talk@ruby-lang.org>",
138
- ]
72
+ ENV['VERSION'] ||= $hoespec.spec.version.to_s
139
73
 
140
- COVERAGE_MINIMUM = ENV['COVERAGE_MINIMUM'] ? Float( ENV['COVERAGE_MINIMUM'] ) : 85.0
141
- RCOV_EXCLUDES = 'spec,tests,/Library/Ruby,/var/lib,/usr/local/lib'
142
- RCOV_OPTS = [
143
- '--exclude', RCOV_EXCLUDES,
144
- '--xrefs',
145
- '--save',
146
- '--callsites',
147
- #'--aggregate', 'coverage.data' # <- doesn't work as of 0.8.1.2.0
148
- ]
74
+ # Tests should pass before checking in
75
+ task 'hg:precheckin' => [ :check_history, :check_manifest, :spec ]
149
76
 
77
+ # Support for 'rvm specs'
78
+ task :specs => :spec
150
79
 
151
- ### Load some task libraries that need to be loaded early
152
- if !RAKE_TASKDIR.exist?
153
- $stderr.puts "It seems you don't have the build task directory. Shall I fetch it "
154
- ans = readline( "for you? [y]" )
155
- ans = 'y' if !ans.nil? && ans.empty?
156
-
157
- if ans =~ /^y/i
158
- $stderr.puts "Okay, fetching #{RAKE_TASKLIBS_URL} into #{RAKE_TASKDIR}..."
159
- system 'hg', 'clone', RAKE_TASKLIBS_URL, "./#{RAKE_TASKDIR}"
160
- if ! $?.success?
161
- fail "Damn. That didn't work. Giving up; maybe try manually fetching?"
162
- end
163
- else
164
- $stderr.puts "Then I'm afraid I can't continue. Best of luck."
165
- fail "Rake tasklibs not present."
166
- end
80
+ # Compile before testing
81
+ task :spec => :compile
167
82
 
168
- RAKE_TASKLIBS.include( "#{RAKE_TASKDIR}/*.rb" )
83
+ # gem-testers support
84
+ task :test do
85
+ # rake-compiler always wants to copy the compiled extension into lib/, but
86
+ # we don't want testers to have to re-compile, especially since that
87
+ # often fails because they can't (and shouldn't have to) write to tmp/ in
88
+ # the installed gem dir. So we clear the task rake-compiler set up
89
+ # to break the dependency between :spec and :compile when running under
90
+ # rubygems-test, and then run :spec.
91
+ Rake::Task[ EXT.to_s ].clear
92
+ Rake::Task[ :spec ].execute
169
93
  end
170
94
 
171
- require RAKE_TASKDIR + 'helpers.rb'
172
- include RakefileHelpers
173
-
174
- # Set the build ID if the mercurial executable is available
175
- if hg = which( 'hg' )
176
- id = `#{hg} id -n`.chomp
177
- PKG_BUILD = (id.chomp[ /^[[:xdigit:]]+/ ] || '1')
178
- else
179
- PKG_BUILD = '0'
95
+ desc "Turn on warnings and debugging in the build."
96
+ task :maint do
97
+ ENV['MAINTAINER_MODE'] = 'yes'
180
98
  end
181
- SNAPSHOT_PKG_NAME = "#{PKG_FILE_NAME}.#{PKG_BUILD}"
182
- SNAPSHOT_GEM_NAME = "#{SNAPSHOT_PKG_NAME}.gem"
183
-
184
- # Documentation constants
185
- API_DOCSDIR = DOCSDIR + 'api'
186
- README_FILE = TEXT_FILES.find {|path| path =~ /^README/ } || 'README'
187
- RDOC_OPTIONS = [
188
- '--tab-width=4',
189
- '--show-hash',
190
- '--include', BASEDIR.to_s,
191
- "--main=#{README_FILE}",
192
- "--title=#{PKG_NAME}",
193
- ]
194
- YARD_OPTIONS = [
195
- '--use-cache',
196
- '--protected',
197
- '-r', README_FILE,
198
- '--exclude', 'extconf\\.rb',
199
- '--files', 'ChangeLog,LICENSE',
200
- '--output-dir', API_DOCSDIR.to_s,
201
- '--title', "#{PKG_NAME} #{PKG_VERSION}",
202
- ]
203
-
204
- # Release constants
205
- SMTP_HOST = "mail.faeriemud.org"
206
- SMTP_PORT = 465 # SMTP + SSL
207
-
208
- # Project constants
209
- PROJECT_HOST = 'deveiate.org'
210
- PROJECT_PUBDIR = '/usr/local/www/public/code/'
211
- PROJECT_DOCDIR = "#{PROJECT_PUBDIR}/#{PKG_NAME}"
212
- PROJECT_SCPPUBURL = "#{PROJECT_HOST}:#{PROJECT_PUBDIR}"
213
- PROJECT_SCPDOCURL = "#{PROJECT_HOST}:#{PROJECT_DOCDIR}"
214
-
215
- GEM_PUBHOST = 'rubygems.org'
216
-
217
- # Gem dependencies: gemname => version
218
- DEPENDENCIES = {
219
- }
220
-
221
- # Developer Gem dependencies: gemname => version
222
- DEVELOPMENT_DEPENDENCIES = {
223
- 'rake' => '~> 0.8.7',
224
- 'rcodetools' => '~> 0.7.0.0',
225
- 'rcov' => '~> 0.8.1.2.0',
226
- 'yard' => '~> 0.6.1',
227
- 'RedCloth' => '~> 4.2.3',
228
- 'rspec' => '~> 2.0.1',
229
- 'ruby-termios' => '~> 0.9.6',
230
- 'text-format' => '~> 1.0.0',
231
- 'tmail' => '~> 1.2.3.1',
232
- 'rake-compiler' => '~>0.7.0',
233
- }
234
-
235
- # Non-gem requirements: packagename => version
236
- REQUIREMENTS = {
237
- 'PostgreSQL' => '>=7.4',
238
- }
239
-
240
- # RubyGem specification
241
- GEMSPEC = Gem::Specification.new do |gem|
242
- gem.name = PKG_NAME.downcase
243
- gem.version = PKG_VERSION
244
-
245
- gem.summary = PKG_SUMMARY
246
- gem.description = [
247
- "This is the extension library to access a PostgreSQL database from Ruby.",
248
- "This library works with PostgreSQL 7.4 and later.",
249
- ].join( "\n" )
250
-
251
- gem.authors = ["Jeff Davis", "Michael Granger"]
252
- gem.email = ["ruby-pg@j-davis.com", "ged@FaerieMUD.org"]
253
- gem.homepage = 'http://bitbucket.org/ged/ruby-pg/'
254
- gem.licenses = ["Ruby", "GPL", "BSD"]
255
-
256
- gem.has_rdoc = true
257
- gem.rdoc_options = RDOC_OPTIONS
258
- gem.extra_rdoc_files = TEXT_FILES - [ 'Rakefile' ]
259
-
260
- gem.bindir = BINDIR.relative_path_from(BASEDIR).to_s
261
- gem.executables = BIN_FILES.select {|pn| File.executable?(pn) }.
262
- collect {|pn| File.basename(pn) }
263
- gem.require_paths << EXTDIR.relative_path_from( BASEDIR ).to_s if EXTDIR.exist?
264
-
265
- if EXTCONF.exist?
266
- gem.extensions << EXTCONF.relative_path_from( BASEDIR ).to_s
267
- end
268
-
269
- gem.files = RELEASE_FILES
270
- gem.test_files = SPEC_FILES
271
99
 
272
- # signing key and certificate chain
273
- gem.signing_key = '/Volumes/Keys/ged-private_gem_key.pem'
274
- gem.cert_chain = [File.expand_path('~/.gem/ged-public_gem_cert.pem')]
275
-
276
-
277
- gem.required_ruby_version = '>=1.8.7'
278
-
279
- DEPENDENCIES.each do |name, version|
280
- version = '>= 0' if version.length.zero?
281
- gem.add_runtime_dependency( name, version )
282
- end
283
-
284
- REQUIREMENTS.each do |name, version|
285
- gem.requirements << [ name, version ].compact.join(' ')
286
- end
100
+ ENV['RUBY_CC_VERSION'] = '1.8.7:1.9.2'
101
+
102
+ # Rake-compiler task
103
+ Rake::ExtensionTask.new do |ext|
104
+ ext.name = 'pg_ext'
105
+ ext.gem_spec = $hoespec.spec
106
+ ext.ext_dir = 'ext'
107
+ ext.lib_dir = 'lib'
108
+ ext.source_pattern = "*.{c,h}"
109
+ ext.cross_compile = true
110
+ ext.cross_platform = %w[i386-mingw32]
111
+
112
+ # configure options only for cross compile
113
+ ext.cross_config_options += [
114
+ "--with-pg-include=#{STATIC_POSTGRESQL_LIBDIR}",
115
+ "--with-opt-include=#{STATIC_POSTGRESQL_INCDIR}",
116
+ "--with-pg-lib=#{STATIC_POSTGRESQL_LIBDIR}",
117
+ "--with-opt-lib=#{STATIC_OPENSSL_BUILDDIR}",
118
+ "--enable-static-build",
119
+ ]
287
120
  end
288
121
 
289
- $trace = Rake.application.options.trace ? true : false
290
- $dryrun = Rake.application.options.dryrun ? true : false
291
- $include_dev_dependencies = false
292
122
 
293
- # Load any remaining task libraries
294
- RAKE_TASKLIBS.each do |tasklib|
295
- next if tasklib.to_s =~ %r{/helpers\.rb$}
123
+ # Make the ChangeLog update if the repo has changed since it was last built
124
+ file '.hg/branch' do
125
+ abort "You need the Mercurial repo to make packages"
126
+ end
127
+ file 'ChangeLog' => '.hg/branch' do |task|
128
+ $stderr.puts "Updating the changelog..."
296
129
  begin
297
- trace " loading tasklib %s" % [ tasklib ]
298
- import tasklib
299
- rescue ScriptError => err
300
- fail "Task library '%s' failed to load: %s: %s" %
301
- [ tasklib, err.class.name, err.message ]
302
- trace "Backtrace: \n " + err.backtrace.join( "\n " )
303
- rescue => err
304
- log "Task library '%s' failed to load: %s: %s. Some tasks may not be available." %
305
- [ tasklib, err.class.name, err.message ]
306
- trace "Backtrace: \n " + err.backtrace.join( "\n " )
130
+ include Hoe::MercurialHelpers
131
+ content = make_changelog()
132
+ rescue NameError
133
+ abort "Packaging tasks require the hoe-mercurial plugin (gem install hoe-mercurial)"
307
134
  end
308
- end
309
-
310
- # Load any project-specific rules defined in 'Rakefile.local' if it exists
311
- import LOCAL_RAKEFILE if LOCAL_RAKEFILE.exist?
312
-
313
-
314
- #####################################################################
315
- ### T A S K S
316
- #####################################################################
317
-
318
- ### Default task
319
- task :default => [:clean, :local, :spec, :apidocs, :package]
320
-
321
- ### Task the local Rakefile can append to -- no-op by default
322
- task :local
323
-
324
- ### Task: clean
325
- CLEAN.include 'coverage', '**/*.orig', '**/*.rej'
326
- CLOBBER.include 'artifacts', 'coverage.info', 'ChangeLog', PKGDIR
327
-
328
- ### Task: changelog
329
- file 'ChangeLog' do |task|
330
- log "Updating #{task.name}"
331
-
332
- changelog = make_changelog()
333
- File.open( task.name, 'w' ) do |fh|
334
- fh.print( changelog )
135
+ File.open( task.name, 'w', 0644 ) do |fh|
136
+ fh.print( content )
335
137
  end
336
138
  end
337
139
 
338
-
339
- ### Task: cruise (Cruisecontrol task)
340
- desc "Cruisecontrol build"
341
- task :cruise => [:clean, 'spec:quiet', :package] do |task|
342
- raise "Artifacts dir not set." if ARTIFACTS_DIR.to_s.empty?
343
- artifact_dir = ARTIFACTS_DIR.cleanpath + (CC_BUILD_LABEL || Time.now.strftime('%Y%m%d-%T'))
344
- artifact_dir.mkpath
345
-
346
- coverage = BASEDIR + 'coverage'
347
- if coverage.exist? && coverage.directory?
348
- $stderr.puts "Copying coverage stats..."
349
- FileUtils.cp_r( 'coverage', artifact_dir )
350
- end
351
-
352
- $stderr.puts "Copying packages..."
353
- FileUtils.cp_r( FileList['pkg/*'].to_a, artifact_dir )
354
- end
140
+ # Rebuild the ChangeLog immediately before release
141
+ task :prerelease => 'ChangeLog'
355
142
 
356
143
 
357
- desc "Update the build system to the latest version"
358
- task :update_build do
359
- log "Updating the build system"
360
- run 'hg', '-R', RAKE_TASKDIR, 'pull', '-u'
361
- log "Updating the Rakefile"
362
- sh 'rake', '-f', RAKE_TASKDIR + 'Metarakefile'
144
+ desc "Stop any Postmaster instances that remain after testing."
145
+ task :cleanup_testing_dbs do
146
+ require 'spec/lib/helpers'
147
+ PgTestingHelpers.stop_existing_postmasters()
148
+ Rake::Task[:clean].invoke
363
149
  end
364
150