Skip to content

Commit af040c9

Browse files
committed
Reindent
1 parent d5c3f66 commit af040c9

File tree

1 file changed

+86
-86
lines changed

1 file changed

+86
-86
lines changed

ext/mysql2/extconf.rb

Lines changed: 86 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -76,107 +76,107 @@ def asplode lib
7676
libs = ['m', 'z', 'socket', 'nsl', 'mygcc']
7777
found = false
7878
while not find_library('mysqlclient', 'mysql_query', lib, "#{lib}/mysql") do
79-
exit 1 if libs.empty?
80-
found ||= have_library(libs.shift)
81-
end
82-
83-
asplode("mysql client") unless found
79+
exit 1 if libs.empty?
80+
found ||= have_library(libs.shift)
81+
end
8482

85-
rpath_dir = lib
86-
end
83+
asplode("mysql client") unless found
8784

88-
if have_header('mysql.h')
89-
prefix = nil
90-
elsif have_header('mysql/mysql.h')
91-
prefix = 'mysql'
92-
else
93-
asplode 'mysql.h'
94-
end
85+
rpath_dir = lib
86+
end
9587

96-
%w{ errmsg.h mysqld_error.h }.each do |h|
97-
header = [prefix, h].compact.join '/'
98-
asplode h unless have_header h
99-
end
88+
if have_header('mysql.h')
89+
prefix = nil
90+
elsif have_header('mysql/mysql.h')
91+
prefix = 'mysql'
92+
else
93+
asplode 'mysql.h'
94+
end
10095

101-
# This is our wishlist. We use whichever flags work on the host.
102-
# -Wall and -Wextra are included by default.
103-
%w(
104-
-Werror
105-
-Weverything
106-
-fsanitize=address
107-
-fsanitize=integer
108-
-fsanitize=thread
109-
-fsanitize=memory
110-
-fsanitize=undefined
111-
-fsanitize=cfi
112-
).each do |flag|
113-
if try_link('int main() {return 0;}', flag)
114-
$CFLAGS << ' ' << flag
96+
%w{ errmsg.h mysqld_error.h }.each do |h|
97+
header = [prefix, h].compact.join '/'
98+
asplode h unless have_header h
11599
end
116-
end
117100

118-
if RUBY_PLATFORM =~ /mswin|mingw/
119-
# Build libmysql.a interface link library
120-
require 'rake'
121-
122-
# Build libmysql.a interface link library
123-
# Use rake to rebuild only if these files change
124-
deffile = File.expand_path('../../../support/libmysql.def', __FILE__)
125-
libfile = File.expand_path(File.join(rpath_dir, 'libmysql.lib'))
126-
file 'libmysql.a' => [deffile, libfile] do |t|
127-
when_writing 'building libmysql.a' do
128-
# Ruby kindly shows us where dllwrap is, but that tool does more than we want.
129-
# Maybe in the future Ruby could provide RbConfig::CONFIG['DLLTOOL'] directly.
130-
dlltool = RbConfig::CONFIG['DLLWRAP'].gsub('dllwrap', 'dlltool')
131-
sh dlltool, '--kill-at',
132-
'--dllname', 'libmysql.dll',
133-
'--output-lib', 'libmysql.a',
134-
'--input-def', deffile, libfile
101+
# This is our wishlist. We use whichever flags work on the host.
102+
# -Wall and -Wextra are included by default.
103+
%w(
104+
-Werror
105+
-Weverything
106+
-fsanitize=address
107+
-fsanitize=integer
108+
-fsanitize=thread
109+
-fsanitize=memory
110+
-fsanitize=undefined
111+
-fsanitize=cfi
112+
).each do |flag|
113+
if try_link('int main() {return 0;}', flag)
114+
$CFLAGS << ' ' << flag
135115
end
136116
end
137117

138-
Rake::Task['libmysql.a'].invoke
139-
$LOCAL_LIBS << ' ' << 'libmysql.a'
118+
if RUBY_PLATFORM =~ /mswin|mingw/
119+
# Build libmysql.a interface link library
120+
require 'rake'
121+
122+
# Build libmysql.a interface link library
123+
# Use rake to rebuild only if these files change
124+
deffile = File.expand_path('../../../support/libmysql.def', __FILE__)
125+
libfile = File.expand_path(File.join(rpath_dir, 'libmysql.lib'))
126+
file 'libmysql.a' => [deffile, libfile] do |t|
127+
when_writing 'building libmysql.a' do
128+
# Ruby kindly shows us where dllwrap is, but that tool does more than we want.
129+
# Maybe in the future Ruby could provide RbConfig::CONFIG['DLLTOOL'] directly.
130+
dlltool = RbConfig::CONFIG['DLLWRAP'].gsub('dllwrap', 'dlltool')
131+
sh dlltool, '--kill-at',
132+
'--dllname', 'libmysql.dll',
133+
'--output-lib', 'libmysql.a',
134+
'--input-def', deffile, libfile
135+
end
136+
end
137+
138+
Rake::Task['libmysql.a'].invoke
139+
$LOCAL_LIBS << ' ' << 'libmysql.a'
140140

141-
# Make sure the generated interface library works (if cross-compiling, trust without verifying)
142-
unless RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
143-
abort "-----\nCannot find libmysql.a\n----" unless have_library('libmysql')
144-
abort "-----\nCannot link to libmysql.a (my_init)\n----" unless have_func('my_init')
145-
end
141+
# Make sure the generated interface library works (if cross-compiling, trust without verifying)
142+
unless RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
143+
abort "-----\nCannot find libmysql.a\n----" unless have_library('libmysql')
144+
abort "-----\nCannot link to libmysql.a (my_init)\n----" unless have_func('my_init')
145+
end
146146

147-
# Vendor libmysql.dll
148-
vendordir = File.expand_path('../../../vendor/', __FILE__)
149-
directory vendordir
147+
# Vendor libmysql.dll
148+
vendordir = File.expand_path('../../../vendor/', __FILE__)
149+
directory vendordir
150150

151-
vendordll = File.join(vendordir, 'libmysql.dll')
152-
dllfile = File.expand_path(File.join(rpath_dir, 'libmysql.dll'))
153-
file vendordll => [dllfile, vendordir] do |t|
154-
when_writing 'copying libmysql.dll' do
155-
cp dllfile, vendordll
151+
vendordll = File.join(vendordir, 'libmysql.dll')
152+
dllfile = File.expand_path(File.join(rpath_dir, 'libmysql.dll'))
153+
file vendordll => [dllfile, vendordir] do |t|
154+
when_writing 'copying libmysql.dll' do
155+
cp dllfile, vendordll
156+
end
156157
end
157-
end
158158

159-
# Copy libmysql.dll to the local vendor directory by default
160-
if arg_config('--no-vendor-libmysql')
161-
# Fine, don't.
162-
puts "--no-vendor-libmysql"
163-
else # Default: arg_config('--vendor-libmysql')
164-
# Let's do it!
165-
Rake::Task[vendordll].invoke
166-
end
167-
else
168-
case explicit_rpath = with_config('mysql-rpath')
169-
when true
170-
abort "-----\nOption --with-mysql-rpath must have an argument\n-----"
171-
when false
172-
warn "-----\nOption --with-mysql-rpath has been disabled at your request\n-----"
173-
when String
174-
# The user gave us a value so use it
175-
rpath_flags = " -Wl,-rpath,#{explicit_rpath}"
176-
warn "-----\nSetting mysql rpath to #{explicit_rpath}\n-----"
177-
$LDFLAGS << rpath_flags
159+
# Copy libmysql.dll to the local vendor directory by default
160+
if arg_config('--no-vendor-libmysql')
161+
# Fine, don't.
162+
puts "--no-vendor-libmysql"
163+
else # Default: arg_config('--vendor-libmysql')
164+
# Let's do it!
165+
Rake::Task[vendordll].invoke
166+
end
178167
else
179-
if libdir = rpath_dir[%r{(-L)?(/[^ ]+)}, 2]
168+
case explicit_rpath = with_config('mysql-rpath')
169+
when true
170+
abort "-----\nOption --with-mysql-rpath must have an argument\n-----"
171+
when false
172+
warn "-----\nOption --with-mysql-rpath has been disabled at your request\n-----"
173+
when String
174+
# The user gave us a value so use it
175+
rpath_flags = " -Wl,-rpath,#{explicit_rpath}"
176+
warn "-----\nSetting mysql rpath to #{explicit_rpath}\n-----"
177+
$LDFLAGS << rpath_flags
178+
else
179+
if libdir = rpath_dir[%r{(-L)?(/[^ ]+)}, 2]
180180
rpath_flags = " -Wl,-rpath,#{libdir}"
181181
if RbConfig::CONFIG["RPATHFLAG"].to_s.empty? && try_link('int main() {return 0;}', rpath_flags)
182182
# Usually Ruby sets RPATHFLAG the right way for each system, but not on OS X.

0 commit comments

Comments
 (0)