forked from ged/ruby-pg
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRakefile
More file actions
217 lines (173 loc) · 5.9 KB
/
Rakefile
File metadata and controls
217 lines (173 loc) · 5.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
# -*- rake -*-
require 'rbconfig'
require 'pathname'
require 'tmpdir'
begin
require 'rake/extensiontask'
rescue LoadError
abort "This Rakefile requires rake-compiler (gem install rake-compiler)"
end
begin
require 'hoe'
rescue LoadError
abort "This Rakefile requires hoe (gem install hoe)"
end
require 'rake/clean'
# Build directory constants
BASEDIR = Pathname( __FILE__ ).dirname
SPECDIR = BASEDIR + 'spec'
LIBDIR = BASEDIR + 'lib'
EXTDIR = BASEDIR + 'ext'
PKGDIR = BASEDIR + 'pkg'
TMPDIR = BASEDIR + 'tmp'
TESTDIR = BASEDIR + "tmp_test_specs"
DLEXT = RbConfig::CONFIG['DLEXT']
EXT = LIBDIR + "pg_ext.#{DLEXT}"
GEMSPEC = 'pg.gemspec'
CLOBBER.include( TESTDIR.to_s )
CLEAN.include( PKGDIR.to_s, TMPDIR.to_s )
CLEAN.include "lib/*/libpq.dll"
CLEAN.include "lib/pg_ext.*"
# Set up Hoe plugins
Hoe.plugin :mercurial
Hoe.plugin :signing
Hoe.plugin :deveiate
Hoe.plugin :bundler
Hoe.plugins.delete :rubyforge
Hoe.plugins.delete :compiler
load 'Rakefile.cross'
# Hoe specification
$hoespec = Hoe.spec 'pg' do
self.readme_file = 'README.rdoc'
self.history_file = 'History.rdoc'
self.extra_rdoc_files = Rake::FileList[ '*.rdoc' ]
self.extra_rdoc_files.include( 'POSTGRES', 'LICENSE' )
self.extra_rdoc_files.include( 'ext/*.c' )
self.license 'BSD-2-Clause'
self.developer 'Michael Granger', 'ged@FaerieMUD.org'
self.developer 'Lars Kanis', 'lars@greiz-reinsdorf.de'
self.dependency 'rake-compiler', '~> 1.0', :developer
self.dependency 'rake-compiler-dock', ['~> 1.0'], :developer
self.dependency 'hoe-deveiate', '~> 0.9', :developer
self.dependency 'hoe-bundler', '~> 1.0', :developer
self.dependency 'rspec', '~> 3.5', :developer
self.dependency 'rdoc', '~> 5.1', :developer
self.spec_extras[:extensions] = [ 'ext/extconf.rb' ]
self.require_ruby_version( '>= 2.2' )
self.hg_sign_tags = true if self.respond_to?( :hg_sign_tags= )
self.check_history_on_release = true if self.respond_to?( :check_history_on_release= )
self.rdoc_locations << "deveiate:/usr/local/www/public/code/#{remote_rdoc_dir}"
end
ENV['VERSION'] ||= $hoespec.spec.version.to_s
# Tests should pass before checking in
task 'hg:precheckin' => [ :check_history, :check_manifest, :spec, :gemspec ]
# Support for 'rvm specs'
task :specs => :spec
# Compile before testing
task :spec => :compile
# gem-testers support
task :test do
# rake-compiler always wants to copy the compiled extension into lib/, but
# we don't want testers to have to re-compile, especially since that
# often fails because they can't (and shouldn't have to) write to tmp/ in
# the installed gem dir. So we clear the task rake-compiler set up
# to break the dependency between :spec and :compile when running under
# rubygems-test, and then run :spec.
Rake::Task[ EXT.to_s ].clear if File.exist?(EXT.to_s)
Rake::Task[ :spec ].execute
end
desc "Turn on warnings and debugging in the build."
task :maint do
ENV['MAINTAINER_MODE'] = 'yes'
end
# Rake-compiler task
Rake::ExtensionTask.new do |ext|
ext.name = 'pg_ext'
ext.gem_spec = $hoespec.spec
ext.ext_dir = 'ext'
ext.lib_dir = 'lib'
ext.source_pattern = "*.{c,h}"
ext.cross_compile = true
ext.cross_platform = CrossLibraries.map(&:for_platform)
ext.cross_config_options += CrossLibraries.map do |lib|
{
lib.for_platform => [
"--enable-windows-cross",
"--with-pg-include=#{lib.static_postgresql_incdir}",
"--with-pg-lib=#{lib.static_postgresql_libdir}",
# libpq-fe.h resides in src/interfaces/libpq/ before make install
"--with-opt-include=#{lib.static_postgresql_libdir}",
]
}
end
# Add libpq.dll to windows binary gemspec
ext.cross_compiling do |spec|
spec.files << "lib/#{spec.platform}/libpq.dll"
end
end
# Use the fivefish formatter for docs generated from development checkout
if File.directory?( '.hg' )
require 'rdoc/task'
Rake::Task[ 'docs' ].clear
RDoc::Task.new( 'docs' ) do |rdoc|
rdoc.main = "README.rdoc"
rdoc.rdoc_files.include( "*.rdoc", "ChangeLog", "lib/**/*.rb", 'ext/**/*.{c,h}' )
rdoc.generator = :fivefish
rdoc.title = "PG: The Ruby PostgreSQL Driver"
rdoc.rdoc_dir = 'doc'
end
end
# Make the ChangeLog update if the repo has changed since it was last built
file '.hg/branch' do
warn "WARNING: You need the Mercurial repo to update the ChangeLog"
end
Rake::Task["ChangeLog"].clear
file 'ChangeLog' do |task|
if File.exist?('.hg/branch')
$stderr.puts "Updating the changelog..."
begin
include Hoe::MercurialHelpers
content = make_changelog()
rescue NameError
abort "Packaging tasks require the hoe-mercurial plugin (gem install hoe-mercurial)"
end
File.open( task.name, 'w', 0644 ) do |fh|
fh.print( content )
end
else
touch 'ChangeLog'
end
end
# Rebuild the ChangeLog immediately before release
task :prerelease => 'ChangeLog'
desc "Stop any Postmaster instances that remain after testing."
task :cleanup_testing_dbs do
require_relative 'spec/helpers'
PG::TestingHelpers.stop_existing_postmasters()
Rake::Task[:clobber].invoke
end
desc "Update list of server error codes"
task :update_error_codes do
URL_ERRORCODES_TXT = "http://git.postgresql.org/gitweb/?p=postgresql.git;a=blob_plain;f=src/backend/utils/errcodes.txt;hb=refs/tags/REL_13_1"
ERRORCODES_TXT = "ext/errorcodes.txt"
sh "wget #{URL_ERRORCODES_TXT.inspect} -O #{ERRORCODES_TXT.inspect} || curl #{URL_ERRORCODES_TXT.inspect} -o #{ERRORCODES_TXT.inspect}"
ruby 'ext/errorcodes.rb', 'ext/errorcodes.txt', 'ext/errorcodes.def'
end
file 'ext/pg_errors.c' => ['ext/errorcodes.def'] do
# trigger compilation of changed errorcodes.def
touch 'ext/pg_errors.c'
end
task :gemspec => GEMSPEC
file GEMSPEC => __FILE__
task GEMSPEC do |task|
spec = $hoespec.spec
spec.files.delete( '.gemtest' )
spec.signing_key = nil
spec.version = "#{spec.version.bump}.0.pre#{Time.now.strftime("%Y%m%d%H%M%S")}"
spec.cert_chain = [ 'certs/ged.pem' ]
File.open( task.name, 'w' ) do |fh|
fh.write( spec.to_ruby )
end
end
CLOBBER.include( '*.gemspec' )
task :default => :gemspec