pg 0.15.0.pre.454-x64-mingw32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data.tar.gz.sig +0 -0
- data/.gemtest +0 -0
- data/BSDL +22 -0
- data/ChangeLog +2945 -0
- data/Contributors.rdoc +46 -0
- data/History.rdoc +205 -0
- data/LICENSE +56 -0
- data/Manifest.txt +53 -0
- data/POSTGRES +23 -0
- data/README-OS_X.rdoc +68 -0
- data/README-Windows.rdoc +67 -0
- data/README.ja.rdoc +14 -0
- data/README.rdoc +111 -0
- data/Rakefile +156 -0
- data/Rakefile.cross +271 -0
- data/ext/extconf.rb +91 -0
- data/ext/gvl_wrappers.c +13 -0
- data/ext/gvl_wrappers.h +185 -0
- data/ext/pg.c +525 -0
- data/ext/pg.h +126 -0
- data/ext/pg_connection.c +3600 -0
- data/ext/pg_result.c +939 -0
- data/ext/vc/pg.sln +26 -0
- data/ext/vc/pg_18/pg.vcproj +216 -0
- data/ext/vc/pg_19/pg_19.vcproj +209 -0
- data/lib/2.0/pg_ext.so +0 -0
- data/lib/pg.rb +52 -0
- data/lib/pg/connection.rb +71 -0
- data/lib/pg/constants.rb +11 -0
- data/lib/pg/exceptions.rb +11 -0
- data/lib/pg/result.rb +16 -0
- data/sample/array_insert.rb +20 -0
- data/sample/async_api.rb +106 -0
- data/sample/async_copyto.rb +39 -0
- data/sample/async_mixed.rb +56 -0
- data/sample/check_conn.rb +21 -0
- data/sample/copyfrom.rb +81 -0
- data/sample/copyto.rb +19 -0
- data/sample/cursor.rb +21 -0
- data/sample/disk_usage_report.rb +186 -0
- data/sample/issue-119.rb +94 -0
- data/sample/losample.rb +69 -0
- data/sample/minimal-testcase.rb +17 -0
- data/sample/notify_wait.rb +72 -0
- data/sample/pg_statistics.rb +294 -0
- data/sample/replication_monitor.rb +231 -0
- data/sample/test_binary_values.rb +33 -0
- data/sample/wal_shipper.rb +434 -0
- data/sample/warehouse_partitions.rb +320 -0
- data/spec/data/expected_trace.out +26 -0
- data/spec/data/random_binary_data +0 -0
- data/spec/lib/helpers.rb +279 -0
- data/spec/pg/connection_spec.rb +1013 -0
- data/spec/pg/result_spec.rb +278 -0
- data/spec/pg_spec.rb +31 -0
- metadata +275 -0
- metadata.gz.sig +0 -0
data/README-Windows.rdoc
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
= Compiling 'pg' on MS Windows
|
2
|
+
|
3
|
+
In order to build this extension on MS Windows you will need a couple things.
|
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.
|
8
|
+
|
9
|
+
If you've built Ruby yourself, you should use the same compiler to build
|
10
|
+
this library that you used to build Ruby.
|
11
|
+
|
12
|
+
Second, PostgreSQL. Be sure you installed it with the development header
|
13
|
+
files if you installed it using the standard PostgreSQL installer for
|
14
|
+
Windows. If you didn't, you can run the installer again, select "modify",
|
15
|
+
and then select the 'development headers' option to install them.
|
16
|
+
|
17
|
+
I recommend making sure that 'pg_config.exe' is in your PATH. The PostgreSQL
|
18
|
+
installer for Windows does not necessarily update your PATH when it installs
|
19
|
+
itself, so you may need to do this manually. This isn't strictly necessary,
|
20
|
+
however.
|
21
|
+
|
22
|
+
In order to build ruby-pg, just run 'rake'. If the pg_config.exe executable
|
23
|
+
is not in your PATH, you'll need to explicitly point ruby-pg to where your
|
24
|
+
PostgreSQL headers and libraries are with something like this:
|
25
|
+
|
26
|
+
rake --with-pg-dir=c:/progra~1/postgr~1/8.3
|
27
|
+
|
28
|
+
Adjust your path accordingly. BE SURE TO USE THE SHORT PATH NAMES! If you
|
29
|
+
try to use a path with spaces in it, the nmake.exe program will choke.
|
30
|
+
|
31
|
+
|
32
|
+
== Cross compiling for mswin32
|
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.
|
39
|
+
|
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.
|
43
|
+
|
44
|
+
Download and cross compile ruby 1.8 and 1.9 for win32 with:
|
45
|
+
|
46
|
+
rake-compiler cross-ruby VERSION=1.8.7-p352
|
47
|
+
rake-compiler cross-ruby VERSION=1.9.2-p290
|
48
|
+
|
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.
|
60
|
+
|
61
|
+
|
62
|
+
== Reporting Problems
|
63
|
+
|
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.
|
67
|
+
|
data/README.ja.rdoc
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
= pg
|
2
|
+
|
3
|
+
home :: https://bitbucket.org/ged/ruby-pg
|
4
|
+
mirror :: https://github.com/ged/ruby-pg
|
5
|
+
docs :: http://deveiate.org/code/pg
|
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.
|
14
|
+
|
data/README.rdoc
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
= pg
|
2
|
+
|
3
|
+
home :: https://bitbucket.org/ged/ruby-pg
|
4
|
+
mirror :: https://github.com/ged/ruby-pg
|
5
|
+
docs :: http://deveiate.org/code/pg
|
6
|
+
|
7
|
+
|
8
|
+
== Description
|
9
|
+
|
10
|
+
Pg is the Ruby interface to the {PostgreSQL RDBMS}[http://www.postgresql.org/].
|
11
|
+
|
12
|
+
It works with {PostgreSQL 8.3 and later}[http://bit.ly/6AfPhm].
|
13
|
+
|
14
|
+
A small example usage:
|
15
|
+
|
16
|
+
#!/usr/bin/env ruby
|
17
|
+
|
18
|
+
require 'pg'
|
19
|
+
|
20
|
+
# Output a table of current connections to the DB
|
21
|
+
conn = PG.connect( dbname: 'sales' )
|
22
|
+
conn.exec( "SELECT * FROM pg_stat_activity" ) do |result|
|
23
|
+
puts " PID | User | Query"
|
24
|
+
result.each do |row|
|
25
|
+
puts " %7d | %-16s | %s " %
|
26
|
+
row.values_at('procpid', 'usename', 'current_query')
|
27
|
+
end
|
28
|
+
end
|
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
|
+
|
34
|
+
|
35
|
+
== Requirements
|
36
|
+
|
37
|
+
* Ruby 1.8.7-p371, 1.9.3-p392, or 2.0.0-p0.
|
38
|
+
* PostgreSQL 8.3.x (with headers, -dev packages, etc).
|
39
|
+
|
40
|
+
It may work with earlier versions of Ruby as well, but those are not regularly tested.
|
41
|
+
|
42
|
+
|
43
|
+
== How To Install
|
44
|
+
|
45
|
+
Install via RubyGems:
|
46
|
+
|
47
|
+
gem install pg
|
48
|
+
|
49
|
+
You may need to specify the path to the 'pg_config' program installed with
|
50
|
+
Postgres:
|
51
|
+
|
52
|
+
gem install pg -- --with-pg-config=<path to pg_config>
|
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
|
+
|
58
|
+
See README-OS_X.rdoc for more information about installing under MacOS X, and
|
59
|
+
README-Windows.rdoc for Windows build/installation instructions.
|
60
|
+
|
61
|
+
There's also {a Google+ group}[http://goo.gl/TFy1U] and a
|
62
|
+
{mailing list}[http://groups.google.com/group/ruby-pg] if you get stuck, or just
|
63
|
+
want to chat about something.
|
64
|
+
|
65
|
+
|
66
|
+
== Contributing
|
67
|
+
|
68
|
+
To report bugs, suggest features, or check out the source with Mercurial,
|
69
|
+
{check out the project page}[http://bitbucket.org/ged/ruby-pg]. If you prefer
|
70
|
+
Git, there's also a {Github mirror}[https://github.com/ged/ruby-pg].
|
71
|
+
|
72
|
+
After checking out the source, run:
|
73
|
+
|
74
|
+
$ rake newb
|
75
|
+
|
76
|
+
This task will install any missing dependencies, run the tests/specs, and
|
77
|
+
generate the API documentation.
|
78
|
+
|
79
|
+
The current maintainer is Michael Granger <ged@FaerieMUD.org>.
|
80
|
+
|
81
|
+
|
82
|
+
== Copying
|
83
|
+
|
84
|
+
Copyright (c) 1997-2012 by the authors.
|
85
|
+
|
86
|
+
* Jeff Davis <ruby-pg@j-davis.com>
|
87
|
+
* Guy Decoux (ts) <decoux@moulon.inra.fr>
|
88
|
+
* Michael Granger <ged@FaerieMUD.org>
|
89
|
+
* Dave Lee
|
90
|
+
* Eiji Matsumoto <usagi@ruby.club.or.jp>
|
91
|
+
* Yukihiro Matsumoto <matz@ruby-lang.org>
|
92
|
+
* Noboru Saitou <noborus@netlab.jp>
|
93
|
+
|
94
|
+
You may redistribute this software under the same terms as Ruby itself; see
|
95
|
+
http://www.ruby-lang.org/en/LICENSE.txt or the LICENSE file in the source
|
96
|
+
for details.
|
97
|
+
|
98
|
+
Portions of the code are from the PostgreSQL project, and are distributed
|
99
|
+
under the terms of the PostgreSQL license, included in the file POSTGRES.
|
100
|
+
|
101
|
+
Portions copyright LAIKA, Inc.
|
102
|
+
|
103
|
+
|
104
|
+
== Acknowledgments
|
105
|
+
|
106
|
+
See Contributors.rdoc for the many additional fine people that have contributed
|
107
|
+
to this library over the years.
|
108
|
+
|
109
|
+
We are thankful to the people at the ruby-list and ruby-dev mailing lists.
|
110
|
+
And to the people who developed PostgreSQL.
|
111
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,156 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
|
3
|
+
require 'rbconfig'
|
4
|
+
require 'pathname'
|
5
|
+
require 'tmpdir'
|
6
|
+
|
7
|
+
begin
|
8
|
+
require 'rake/extensiontask'
|
9
|
+
rescue LoadError
|
10
|
+
abort "This Rakefile requires rake-compiler (gem install rake-compiler)"
|
11
|
+
end
|
12
|
+
|
13
|
+
begin
|
14
|
+
require 'hoe'
|
15
|
+
rescue LoadError
|
16
|
+
abort "This Rakefile requires hoe (gem install hoe)"
|
17
|
+
end
|
18
|
+
|
19
|
+
require 'rake/clean'
|
20
|
+
|
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'
|
28
|
+
|
29
|
+
DLEXT = RbConfig::CONFIG['DLEXT']
|
30
|
+
EXT = LIBDIR + "pg_ext.#{DLEXT}"
|
31
|
+
|
32
|
+
TEST_DIRECTORY = BASEDIR + "tmp_test_specs"
|
33
|
+
|
34
|
+
CLOBBER.include( TEST_DIRECTORY.to_s )
|
35
|
+
CLEAN.include( PKGDIR.to_s, TMPDIR.to_s )
|
36
|
+
|
37
|
+
# Set up Hoe plugins
|
38
|
+
Hoe.plugin :mercurial
|
39
|
+
Hoe.plugin :signing
|
40
|
+
Hoe.plugin :deveiate
|
41
|
+
|
42
|
+
Hoe.plugins.delete :rubyforge
|
43
|
+
Hoe.plugins.delete :compiler
|
44
|
+
|
45
|
+
load 'Rakefile.cross'
|
46
|
+
|
47
|
+
|
48
|
+
# Hoe specification
|
49
|
+
$hoespec = Hoe.spec 'pg' do
|
50
|
+
self.readme_file = 'README.rdoc'
|
51
|
+
self.history_file = 'History.rdoc'
|
52
|
+
self.extra_rdoc_files = Rake::FileList[ '*.rdoc' ]
|
53
|
+
self.extra_rdoc_files.include( 'POSTGRES', 'LICENSE' )
|
54
|
+
self.extra_rdoc_files.include( 'ext/*.c' )
|
55
|
+
|
56
|
+
self.developer 'Michael Granger', 'ged@FaerieMUD.org'
|
57
|
+
|
58
|
+
self.dependency 'rake-compiler', '~> 0.8', :developer
|
59
|
+
self.dependency 'hoe-deveiate', '~> 0.2', :developer
|
60
|
+
|
61
|
+
self.spec_extras[:licenses] = ['BSD', 'Ruby', 'GPL']
|
62
|
+
self.spec_extras[:extensions] = [ 'ext/extconf.rb' ]
|
63
|
+
|
64
|
+
self.require_ruby_version( '>= 1.8.7' )
|
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= )
|
68
|
+
self.spec_extras[:rdoc_options] = [
|
69
|
+
'-f', 'fivefish',
|
70
|
+
'-t', 'pg: The Ruby Interface to PostgreSQL',
|
71
|
+
'-m', 'README.rdoc',
|
72
|
+
]
|
73
|
+
|
74
|
+
self.rdoc_locations << "deveiate:/usr/local/www/public/code/#{remote_rdoc_dir}"
|
75
|
+
end
|
76
|
+
|
77
|
+
ENV['VERSION'] ||= $hoespec.spec.version.to_s
|
78
|
+
|
79
|
+
# Tests should pass before checking in
|
80
|
+
task 'hg:precheckin' => [ :check_history, :check_manifest, :spec ]
|
81
|
+
|
82
|
+
# Support for 'rvm specs'
|
83
|
+
task :specs => :spec
|
84
|
+
|
85
|
+
# Compile before testing
|
86
|
+
task :spec => :compile
|
87
|
+
|
88
|
+
# gem-testers support
|
89
|
+
task :test do
|
90
|
+
# rake-compiler always wants to copy the compiled extension into lib/, but
|
91
|
+
# we don't want testers to have to re-compile, especially since that
|
92
|
+
# often fails because they can't (and shouldn't have to) write to tmp/ in
|
93
|
+
# the installed gem dir. So we clear the task rake-compiler set up
|
94
|
+
# to break the dependency between :spec and :compile when running under
|
95
|
+
# rubygems-test, and then run :spec.
|
96
|
+
Rake::Task[ EXT.to_s ].clear
|
97
|
+
Rake::Task[ :spec ].execute
|
98
|
+
end
|
99
|
+
|
100
|
+
desc "Turn on warnings and debugging in the build."
|
101
|
+
task :maint do
|
102
|
+
ENV['MAINTAINER_MODE'] = 'yes'
|
103
|
+
end
|
104
|
+
|
105
|
+
ENV['RUBY_CC_VERSION'] ||= '1.8.7:1.9.2:2.0.0'
|
106
|
+
|
107
|
+
# Rake-compiler task
|
108
|
+
Rake::ExtensionTask.new do |ext|
|
109
|
+
ext.name = 'pg_ext'
|
110
|
+
ext.gem_spec = $hoespec.spec
|
111
|
+
ext.ext_dir = 'ext'
|
112
|
+
ext.lib_dir = 'lib'
|
113
|
+
ext.source_pattern = "*.{c,h}"
|
114
|
+
ext.cross_compile = true
|
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
|
127
|
+
end
|
128
|
+
|
129
|
+
|
130
|
+
# Make the ChangeLog update if the repo has changed since it was last built
|
131
|
+
file '.hg/branch' do
|
132
|
+
abort "You need the Mercurial repo to make packages"
|
133
|
+
end
|
134
|
+
file 'ChangeLog' => '.hg/branch' do |task|
|
135
|
+
$stderr.puts "Updating the changelog..."
|
136
|
+
begin
|
137
|
+
content = make_changelog()
|
138
|
+
rescue NameError
|
139
|
+
abort "Packaging tasks require the hoe-mercurial plugin (gem install hoe-mercurial)"
|
140
|
+
end
|
141
|
+
File.open( task.name, 'w', 0644 ) do |fh|
|
142
|
+
fh.print( content )
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
# Rebuild the ChangeLog immediately before release
|
147
|
+
task :prerelease => 'ChangeLog'
|
148
|
+
|
149
|
+
|
150
|
+
desc "Stop any Postmaster instances that remain after testing."
|
151
|
+
task :cleanup_testing_dbs do
|
152
|
+
require 'spec/lib/helpers'
|
153
|
+
PgTestingHelpers.stop_existing_postmasters()
|
154
|
+
Rake::Task[:clean].invoke
|
155
|
+
end
|
156
|
+
|
data/Rakefile.cross
ADDED
@@ -0,0 +1,271 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
|
3
|
+
require 'uri'
|
4
|
+
require 'tempfile'
|
5
|
+
require 'rbconfig'
|
6
|
+
require 'rake/clean'
|
7
|
+
require 'rake/extensiontask'
|
8
|
+
require 'rake/extensioncompiler'
|
9
|
+
require 'ostruct'
|
10
|
+
|
11
|
+
MISCDIR = BASEDIR + 'misc'
|
12
|
+
|
13
|
+
NUM_CPUS = if File.exist?('/proc/cpuinfo')
|
14
|
+
File.read('/proc/cpuinfo').scan('processor').length
|
15
|
+
elsif RUBY_PLATFORM.include?( 'darwin' )
|
16
|
+
`system_profiler SPHardwareDataType | grep 'Cores' | awk '{print $5}'`.chomp
|
17
|
+
else
|
18
|
+
1
|
19
|
+
end
|
20
|
+
|
21
|
+
class CrossLibrary < OpenStruct
|
22
|
+
include Rake::DSL
|
23
|
+
|
24
|
+
def initialize(for_platform, openssl_config)
|
25
|
+
super()
|
26
|
+
|
27
|
+
self.for_platform = for_platform
|
28
|
+
self.openssl_config = openssl_config
|
29
|
+
|
30
|
+
# Cross-compilation constants
|
31
|
+
self.openssl_version = ENV['OPENSSL_VERSION'] || '1.0.1e'
|
32
|
+
self.postgresql_version = ENV['POSTGRESQL_VERSION'] || '9.2.3'
|
33
|
+
|
34
|
+
self.compile_home = Pathname( "./build" ).expand_path
|
35
|
+
self.static_sourcesdir = compile_home + 'sources'
|
36
|
+
self.static_builddir = compile_home + 'builds' + for_platform
|
37
|
+
|
38
|
+
# Static OpenSSL build vars
|
39
|
+
self.static_openssl_builddir = static_builddir + "openssl-#{openssl_version}"
|
40
|
+
|
41
|
+
self.openssl_source_uri =
|
42
|
+
URI( "http://www.openssl.org/source/openssl-#{openssl_version}.tar.gz" )
|
43
|
+
self.openssl_tarball = static_sourcesdir + File.basename( openssl_source_uri.path )
|
44
|
+
self.openssl_makefile = static_openssl_builddir + 'Makefile'
|
45
|
+
|
46
|
+
self.libssleay32 = static_openssl_builddir + 'libssleay32.a'
|
47
|
+
self.libeay32 = static_openssl_builddir + 'libeay32.a'
|
48
|
+
|
49
|
+
self.openssl_patches = Rake::FileList[ (MISCDIR + "openssl-#{openssl_version}.*.patch").to_s ]
|
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
|
77
|
+
|
78
|
+
|
79
|
+
# clean intermediate files and folders
|
80
|
+
CLEAN.include( static_builddir.to_s )
|
81
|
+
|
82
|
+
|
83
|
+
ENV['RUBY_CC_VERSION'] ||= '1.8.7:1.9.3:2.0.0'
|
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
|
90
|
+
|
91
|
+
def run(*args)
|
92
|
+
sh *args
|
93
|
+
end
|
94
|
+
|
95
|
+
#####################################################################
|
96
|
+
### C R O S S - C O M P I L A T I O N - T A S K S
|
97
|
+
#####################################################################
|
98
|
+
|
99
|
+
|
100
|
+
directory static_sourcesdir.to_s
|
101
|
+
|
102
|
+
#
|
103
|
+
# Static OpenSSL build tasks
|
104
|
+
#
|
105
|
+
directory static_openssl_builddir.to_s
|
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
|
111
|
+
|
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
|
125
|
+
|
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
|
+
|
134
|
+
|
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
|
140
|
+
|
141
|
+
run( *cmd )
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
desc "compile static openssl libraries"
|
146
|
+
task :openssl_libs => [ libssleay32, libeay32 ]
|
147
|
+
|
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'
|
152
|
+
|
153
|
+
run( *cmd )
|
154
|
+
end
|
155
|
+
end
|
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
|
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
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
#
|
170
|
+
# Static PostgreSQL build tasks
|
171
|
+
#
|
172
|
+
directory static_postgresql_builddir.to_s
|
173
|
+
|
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
|
179
|
+
|
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
|
215
|
+
end
|
216
|
+
|
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
|
228
|
+
|
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
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
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
|
257
|
+
|
258
|
+
desc 'cross compile pg for win32'
|
259
|
+
task :cross do
|
260
|
+
ENV['CROSS_COMPILING'] = 'yes'
|
261
|
+
end
|
262
|
+
task :cross => [ :mingw32, :static_libpq ]
|
263
|
+
|
264
|
+
task :mingw32 do
|
265
|
+
# Use Rake::ExtensionCompiler helpers to find the proper host
|
266
|
+
unless Rake::ExtensionCompiler.mingw_host then
|
267
|
+
warn "You need to install mingw32 cross compile functionality to be able to continue."
|
268
|
+
warn "Please refer to your distribution/package manager documentation about installation."
|
269
|
+
fail
|
270
|
+
end
|
271
|
+
end
|