mysql3 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/ext/mysql2/extconf.rb +270 -0
- metadata +54 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7b6f6990f87b0ced84ad248bae755f7fc49876da7ce0faa3e9201216ebc26d43
|
4
|
+
data.tar.gz: 17668abb2b660c6ffc759b37a10d1a76da468a6234098c19eb2011bfb2d19098
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 57cff41a7d8827e4c454880bb44eb05e99c1a1acba8612633b52c0937e24f40523c7e747599a2d12dfe11a07b9e6187ee2519bb124c092b8b91094c593c3ea15
|
7
|
+
data.tar.gz: e99c23fef385424c055fae92c7989bf9222643d54f9b111a3974ecacd97009df9a6b680f5b6c29ede99d74bb39b4dd527727314a5a06b5cc10a639c1978f272d
|
@@ -0,0 +1,270 @@
|
|
1
|
+
require 'mkmf'
|
2
|
+
require 'English'
|
3
|
+
|
4
|
+
def asplode(lib)
|
5
|
+
if RUBY_PLATFORM =~ /mingw|mswin/
|
6
|
+
abort "-----\n#{lib} is missing. Check your installation of MySQL or Connector/C, and try again.\n-----"
|
7
|
+
elsif RUBY_PLATFORM =~ /darwin/
|
8
|
+
abort "-----\n#{lib} is missing. You may need to 'brew install mysql' or 'port install mysql', and try again.\n-----"
|
9
|
+
else
|
10
|
+
abort "-----\n#{lib} is missing. You may need to 'sudo apt-get install libmariadb-dev', 'sudo apt-get install libmysqlclient-dev' or 'sudo yum install mysql-devel', and try again.\n-----"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def add_ssl_defines(header)
|
15
|
+
all_modes_found = %w[SSL_MODE_DISABLED SSL_MODE_PREFERRED SSL_MODE_REQUIRED SSL_MODE_VERIFY_CA SSL_MODE_VERIFY_IDENTITY].inject(true) do |m, ssl_mode|
|
16
|
+
m && have_const(ssl_mode, header)
|
17
|
+
end
|
18
|
+
$CFLAGS << ' -DFULL_SSL_MODE_SUPPORT' if all_modes_found
|
19
|
+
# if we only have ssl toggle (--ssl,--disable-ssl) from 5.7.3 to 5.7.10
|
20
|
+
has_no_support = all_modes_found ? false : !have_const('MYSQL_OPT_SSL_ENFORCE', header)
|
21
|
+
$CFLAGS << ' -DNO_SSL_MODE_SUPPORT' if has_no_support
|
22
|
+
end
|
23
|
+
|
24
|
+
# Homebrew openssl
|
25
|
+
$LDFLAGS << ' -L/usr/local/opt/openssl/lib' if RUBY_PLATFORM =~ /darwin/
|
26
|
+
|
27
|
+
# 2.1+
|
28
|
+
have_func('rb_absint_size')
|
29
|
+
have_func('rb_absint_singlebit_p')
|
30
|
+
|
31
|
+
# Missing in RBX (https://github.com/rubinius/rubinius/issues/3771)
|
32
|
+
have_func('rb_wait_for_single_fd')
|
33
|
+
|
34
|
+
# borrowed from mysqlplus
|
35
|
+
# http://github.com/oldmoe/mysqlplus/blob/master/ext/extconf.rb
|
36
|
+
dirs = ENV.fetch('PATH').split(File::PATH_SEPARATOR) + %w[
|
37
|
+
/opt
|
38
|
+
/opt/local
|
39
|
+
/opt/local/mysql
|
40
|
+
/opt/local/lib/mysql5*
|
41
|
+
/usr
|
42
|
+
/usr/mysql
|
43
|
+
/usr/local
|
44
|
+
/usr/local/mysql
|
45
|
+
/usr/local/mysql-*
|
46
|
+
/usr/local/lib/mysql5*
|
47
|
+
/usr/local/opt/mysql5*
|
48
|
+
/usr/local/opt/mysql@*
|
49
|
+
/usr/local/opt/mysql-client
|
50
|
+
/usr/local/opt/mysql-client@*
|
51
|
+
].map { |dir| dir << '/bin' }
|
52
|
+
|
53
|
+
# For those without HOMEBREW_ROOT in PATH
|
54
|
+
dirs << "#{ENV['HOMEBREW_ROOT']}/bin" if ENV['HOMEBREW_ROOT']
|
55
|
+
|
56
|
+
GLOB = "{#{dirs.join(',')}}/{mysql_config,mysql_config5,mariadb_config}".freeze
|
57
|
+
|
58
|
+
# If the user has provided a --with-mysql-dir argument, we must respect it or fail.
|
59
|
+
inc, lib = dir_config('mysql')
|
60
|
+
if inc && lib
|
61
|
+
# Ruby versions below 2.0 on Unix and below 2.1 on Windows
|
62
|
+
# do not properly search for lib directories, and must be corrected:
|
63
|
+
# https://bugs.ruby-lang.org/projects/ruby-trunk/repository/revisions/39717
|
64
|
+
unless lib && lib[-3, 3] == 'lib'
|
65
|
+
@libdir_basename = 'lib'
|
66
|
+
inc, lib = dir_config('mysql')
|
67
|
+
end
|
68
|
+
abort "-----\nCannot find include dir(s) #{inc}\n-----" unless inc && inc.split(File::PATH_SEPARATOR).any? { |dir| File.directory?(dir) }
|
69
|
+
abort "-----\nCannot find library dir(s) #{lib}\n-----" unless lib && lib.split(File::PATH_SEPARATOR).any? { |dir| File.directory?(dir) }
|
70
|
+
warn "-----\nUsing --with-mysql-dir=#{File.dirname inc}\n-----"
|
71
|
+
rpath_dir = lib
|
72
|
+
have_library('mysqlclient')
|
73
|
+
elsif (mc = (with_config('mysql-config') || Dir[GLOB].first))
|
74
|
+
# If the user has provided a --with-mysql-config argument, we must respect it or fail.
|
75
|
+
# If the user gave --with-mysql-config with no argument means we should try to find it.
|
76
|
+
mc = Dir[GLOB].first if mc == true
|
77
|
+
abort "-----\nCannot find mysql_config at #{mc}\n-----" unless mc && File.exist?(mc)
|
78
|
+
abort "-----\nCannot execute mysql_config at #{mc}\n-----" unless File.executable?(mc)
|
79
|
+
warn "-----\nUsing mysql_config at #{mc}\n-----"
|
80
|
+
ver = `#{mc} --version`.chomp.to_f
|
81
|
+
includes = `#{mc} --include`.chomp
|
82
|
+
abort unless $CHILD_STATUS.success?
|
83
|
+
libs = `#{mc} --libs_r`.chomp
|
84
|
+
# MySQL 5.5 and above already have re-entrant code in libmysqlclient (no _r).
|
85
|
+
libs = `#{mc} --libs`.chomp if ver >= 5.5 || libs.empty?
|
86
|
+
abort unless $CHILD_STATUS.success?
|
87
|
+
$INCFLAGS += ' ' + includes
|
88
|
+
$libs = libs + " " + $libs
|
89
|
+
rpath_dir = libs
|
90
|
+
else
|
91
|
+
_, usr_local_lib = dir_config('mysql', '/usr/local')
|
92
|
+
|
93
|
+
asplode("mysql client") unless find_library('mysqlclient', nil, usr_local_lib, "#{usr_local_lib}/mysql")
|
94
|
+
|
95
|
+
rpath_dir = usr_local_lib
|
96
|
+
end
|
97
|
+
|
98
|
+
if have_header('mysql.h')
|
99
|
+
prefix = nil
|
100
|
+
elsif have_header('mysql/mysql.h')
|
101
|
+
prefix = 'mysql'
|
102
|
+
else
|
103
|
+
asplode 'mysql.h'
|
104
|
+
end
|
105
|
+
|
106
|
+
%w[errmsg.h].each do |h|
|
107
|
+
header = [prefix, h].compact.join('/')
|
108
|
+
asplode h unless have_header header
|
109
|
+
end
|
110
|
+
|
111
|
+
mysql_h = [prefix, 'mysql.h'].compact.join('/')
|
112
|
+
add_ssl_defines(mysql_h)
|
113
|
+
have_struct_member('MYSQL', 'net.vio', mysql_h)
|
114
|
+
have_struct_member('MYSQL', 'net.pvio', mysql_h)
|
115
|
+
|
116
|
+
# These constants are actually enums, so they cannot be detected by #ifdef in C code.
|
117
|
+
have_const('MYSQL_ENABLE_CLEARTEXT_PLUGIN', mysql_h)
|
118
|
+
have_const('SERVER_QUERY_NO_GOOD_INDEX_USED', mysql_h)
|
119
|
+
have_const('SERVER_QUERY_NO_INDEX_USED', mysql_h)
|
120
|
+
have_const('SERVER_QUERY_WAS_SLOW', mysql_h)
|
121
|
+
have_const('MYSQL_OPTION_MULTI_STATEMENTS_ON', mysql_h)
|
122
|
+
have_const('MYSQL_OPTION_MULTI_STATEMENTS_OFF', mysql_h)
|
123
|
+
|
124
|
+
# my_bool is replaced by C99 bool in MySQL 8.0, but we want
|
125
|
+
# to retain compatibility with the typedef in earlier MySQLs.
|
126
|
+
have_type('my_bool', mysql_h)
|
127
|
+
|
128
|
+
# This is our wishlist. We use whichever flags work on the host.
|
129
|
+
# -Wall and -Wextra are included by default.
|
130
|
+
wishlist = [
|
131
|
+
'-Weverything',
|
132
|
+
'-Wno-bad-function-cast', # rb_thread_call_without_gvl returns void * that we cast to VALUE
|
133
|
+
'-Wno-conditional-uninitialized', # false positive in client.c
|
134
|
+
'-Wno-covered-switch-default', # result.c -- enum_field_types (when fully covered, e.g. mysql 5.5)
|
135
|
+
'-Wno-declaration-after-statement', # GET_CLIENT followed by GET_STATEMENT in statement.c
|
136
|
+
'-Wno-disabled-macro-expansion', # rubby :(
|
137
|
+
'-Wno-documentation-unknown-command', # rubby :(
|
138
|
+
'-Wno-missing-field-initializers', # gperf generates bad code
|
139
|
+
'-Wno-missing-variable-declarations', # missing symbols due to ruby native ext initialization
|
140
|
+
'-Wno-padded', # mysql :(
|
141
|
+
'-Wno-reserved-id-macro', # rubby :(
|
142
|
+
'-Wno-sign-conversion', # gperf generates bad code
|
143
|
+
'-Wno-static-in-inline', # gperf generates bad code
|
144
|
+
'-Wno-switch-enum', # result.c -- enum_field_types (when not fully covered, e.g. mysql 5.6+)
|
145
|
+
'-Wno-undef', # rubinius :(
|
146
|
+
'-Wno-unreachable-code', # rubby :(
|
147
|
+
'-Wno-used-but-marked-unused', # rubby :(
|
148
|
+
]
|
149
|
+
|
150
|
+
usable_flags = wishlist.select do |flag|
|
151
|
+
try_link('int main() {return 0;}', "-Werror #{flag}")
|
152
|
+
end
|
153
|
+
|
154
|
+
$CFLAGS << ' ' << usable_flags.join(' ')
|
155
|
+
|
156
|
+
enabled_sanitizers = disabled_sanitizers = []
|
157
|
+
# Specify a commna-separated list of sanitizers, or try them all by default
|
158
|
+
sanitizers = with_config('sanitize')
|
159
|
+
case sanitizers
|
160
|
+
when true
|
161
|
+
# Try them all, turn on whatever we can
|
162
|
+
enabled_sanitizers = %w[address cfi integer memory thread undefined].select do |s|
|
163
|
+
try_link('int main() {return 0;}', "-Werror -fsanitize=#{s}")
|
164
|
+
end
|
165
|
+
abort "-----\nCould not enable any sanitizers!\n-----" if enabled_sanitizers.empty?
|
166
|
+
when String
|
167
|
+
# Figure out which sanitizers are supported
|
168
|
+
enabled_sanitizers, disabled_sanitizers = sanitizers.split(',').partition do |s|
|
169
|
+
try_link('int main() {return 0;}', "-Werror -fsanitize=#{s}")
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
unless disabled_sanitizers.empty?
|
174
|
+
abort "-----\nCould not enable requested sanitizers: #{disabled_sanitizers.join(',')}\n-----"
|
175
|
+
end
|
176
|
+
|
177
|
+
unless enabled_sanitizers.empty?
|
178
|
+
warn "-----\nEnabling sanitizers: #{enabled_sanitizers.join(',')}\n-----"
|
179
|
+
enabled_sanitizers.each do |s|
|
180
|
+
# address sanitizer requires runtime support
|
181
|
+
if s == 'address' # rubocop:disable Style/IfUnlessModifier
|
182
|
+
have_library('asan') || $LDFLAGS << ' -fsanitize=address'
|
183
|
+
end
|
184
|
+
$CFLAGS << " -fsanitize=#{s}"
|
185
|
+
end
|
186
|
+
# Options for line numbers in backtraces
|
187
|
+
$CFLAGS << ' -g -fno-omit-frame-pointer'
|
188
|
+
end
|
189
|
+
|
190
|
+
if RUBY_PLATFORM =~ /mswin|mingw/ && !defined?(RubyInstaller)
|
191
|
+
# Build libmysql.a interface link library
|
192
|
+
require 'rake'
|
193
|
+
|
194
|
+
# Build libmysql.a interface link library
|
195
|
+
# Use rake to rebuild only if these files change
|
196
|
+
deffile = File.expand_path('../../../support/libmysql.def', __FILE__)
|
197
|
+
libfile = File.expand_path(File.join(rpath_dir, 'libmysql.lib'))
|
198
|
+
file 'libmysql.a' => [deffile, libfile] do
|
199
|
+
when_writing 'building libmysql.a' do
|
200
|
+
# Ruby kindly shows us where dllwrap is, but that tool does more than we want.
|
201
|
+
# Maybe in the future Ruby could provide RbConfig::CONFIG['DLLTOOL'] directly.
|
202
|
+
dlltool = RbConfig::CONFIG['DLLWRAP'].gsub('dllwrap', 'dlltool')
|
203
|
+
sh dlltool, '--kill-at',
|
204
|
+
'--dllname', 'libmysql.dll',
|
205
|
+
'--output-lib', 'libmysql.a',
|
206
|
+
'--input-def', deffile, libfile
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
Rake::Task['libmysql.a'].invoke
|
211
|
+
$LOCAL_LIBS << ' ' << 'libmysql.a'
|
212
|
+
|
213
|
+
# Make sure the generated interface library works (if cross-compiling, trust without verifying)
|
214
|
+
unless RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
|
215
|
+
abort "-----\nCannot find libmysql.a\n-----" unless have_library('libmysql')
|
216
|
+
abort "-----\nCannot link to libmysql.a (my_init)\n-----" unless have_func('my_init')
|
217
|
+
end
|
218
|
+
|
219
|
+
# Vendor libmysql.dll
|
220
|
+
vendordir = File.expand_path('../../../vendor/', __FILE__)
|
221
|
+
directory vendordir
|
222
|
+
|
223
|
+
vendordll = File.join(vendordir, 'libmysql.dll')
|
224
|
+
dllfile = File.expand_path(File.join(rpath_dir, 'libmysql.dll'))
|
225
|
+
file vendordll => [dllfile, vendordir] do
|
226
|
+
when_writing 'copying libmysql.dll' do
|
227
|
+
cp dllfile, vendordll
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
# Copy libmysql.dll to the local vendor directory by default
|
232
|
+
if arg_config('--no-vendor-libmysql')
|
233
|
+
# Fine, don't.
|
234
|
+
puts "--no-vendor-libmysql"
|
235
|
+
else # Default: arg_config('--vendor-libmysql')
|
236
|
+
# Let's do it!
|
237
|
+
Rake::Task[vendordll].invoke
|
238
|
+
end
|
239
|
+
else
|
240
|
+
case explicit_rpath = with_config('mysql-rpath')
|
241
|
+
when true
|
242
|
+
abort "-----\nOption --with-mysql-rpath must have an argument\n-----"
|
243
|
+
when false
|
244
|
+
warn "-----\nOption --with-mysql-rpath has been disabled at your request\n-----"
|
245
|
+
when String
|
246
|
+
# The user gave us a value so use it
|
247
|
+
rpath_flags = " -Wl,-rpath,#{explicit_rpath}"
|
248
|
+
warn "-----\nSetting mysql rpath to #{explicit_rpath}\n-----"
|
249
|
+
$LDFLAGS << rpath_flags
|
250
|
+
else
|
251
|
+
if (libdir = rpath_dir[%r{(-L)?(/[^ ]+)}, 2])
|
252
|
+
rpath_flags = " -Wl,-rpath,#{libdir}"
|
253
|
+
if RbConfig::CONFIG["RPATHFLAG"].to_s.empty? && try_link('int main() {return 0;}', rpath_flags)
|
254
|
+
# Usually Ruby sets RPATHFLAG the right way for each system, but not on OS X.
|
255
|
+
warn "-----\nSetting rpath to #{libdir}\n-----"
|
256
|
+
$LDFLAGS << rpath_flags
|
257
|
+
else
|
258
|
+
if RbConfig::CONFIG["RPATHFLAG"].to_s.empty?
|
259
|
+
# If we got here because try_link failed, warn the user
|
260
|
+
warn "-----\nDon't know how to set rpath on your system, if MySQL libraries are not in path mysql2 may not load\n-----"
|
261
|
+
end
|
262
|
+
# Make sure that LIBPATH gets set if we didn't explicitly set the rpath.
|
263
|
+
warn "-----\nSetting libpath to #{libdir}\n-----"
|
264
|
+
$LIBPATH << libdir unless $LIBPATH.include?(libdir)
|
265
|
+
end
|
266
|
+
end
|
267
|
+
end
|
268
|
+
end
|
269
|
+
|
270
|
+
create_makefile('mysql2/mysql2')
|
metadata
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mysql3
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Brian Lopez
|
8
|
+
- Aaron Stone
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2021-04-18 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description:
|
15
|
+
email:
|
16
|
+
- seniorlopez@gmail.com
|
17
|
+
- aaron@serendipity.cx
|
18
|
+
executables: []
|
19
|
+
extensions:
|
20
|
+
- ext/mysql2/extconf.rb
|
21
|
+
extra_rdoc_files: []
|
22
|
+
files:
|
23
|
+
- ext/mysql2/extconf.rb
|
24
|
+
homepage: https://github.com/brianmario/mysql2
|
25
|
+
licenses:
|
26
|
+
- MIT
|
27
|
+
metadata:
|
28
|
+
bug_tracker_uri: https://github.com/brianmario/mysql2/issues
|
29
|
+
changelog_uri: https://github.com/brianmario/mysql2/releases/tag/0.5.4
|
30
|
+
documentation_uri: https://www.rubydoc.info/gems/mysql2/0.5.4
|
31
|
+
homepage_uri: https://github.com/brianmario/mysql2
|
32
|
+
source_code_uri: https://github.com/brianmario/mysql2/tree/0.5.4
|
33
|
+
msys2_mingw_dependencies: libmariadbclient
|
34
|
+
post_install_message:
|
35
|
+
rdoc_options:
|
36
|
+
- "--charset=UTF-8"
|
37
|
+
require_paths:
|
38
|
+
- lib
|
39
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 2.0.0
|
44
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
requirements: []
|
50
|
+
rubygems_version: 3.0.3
|
51
|
+
signing_key:
|
52
|
+
specification_version: 4
|
53
|
+
summary: A simple, fast Mysql library for Ruby, binding to libmysql
|
54
|
+
test_files: []
|