@@ -76,109 +76,109 @@ def asplode lib
76
76
libs = [ 'm' , 'z' , 'socket' , 'nsl' , 'mygcc' ]
77
77
found = false
78
78
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
79
+ exit 1 if libs . empty?
80
+ found ||= have_library ( libs . shift )
81
+ end
82
82
83
- asplode ( "mysql client" ) unless found
83
+ asplode ( "mysql client" ) unless found
84
84
85
- rpath_dir = lib
86
- end
85
+ rpath_dir = lib
86
+ end
87
87
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
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
95
95
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
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
100
100
101
- # This is our wishlist. We use whichever flags work on the host.
102
- # -Wall and -Wextra are included by default.
103
- # TODO: fix statement.c and remove -Wno-error=declaration-after-statement
104
- %w(
105
- -Werror
106
- -Weverything
107
- -fsanitize=address
108
- -fsanitize=integer
109
- -fsanitize=thread
110
- -fsanitize=memory
111
- -fsanitize=undefined
112
- -fsanitize=cfi
113
- -Wno-error=declaration-after-statement
114
- ) . each do |flag |
115
- if try_link ( 'int main() {return 0;}' , flag )
116
- $CFLAGS << ' ' << flag
117
- end
101
+ # This is our wishlist. We use whichever flags work on the host.
102
+ # -Wall and -Wextra are included by default.
103
+ # TODO: fix statement.c and remove -Wno-error=declaration-after-statement
104
+ %w(
105
+ -Werror
106
+ -Weverything
107
+ -fsanitize=address
108
+ -fsanitize=integer
109
+ -fsanitize=thread
110
+ -fsanitize=memory
111
+ -fsanitize=undefined
112
+ -fsanitize=cfi
113
+ -Wno-error=declaration-after-statement
114
+ ) . each do |flag |
115
+ if try_link ( 'int main() {return 0;}' , flag )
116
+ $CFLAGS << ' ' << flag
118
117
end
118
+ end
119
119
120
- if RUBY_PLATFORM =~ /mswin|mingw/
121
- # Build libmysql.a interface link library
122
- require 'rake'
123
-
124
- # Build libmysql.a interface link library
125
- # Use rake to rebuild only if these files change
126
- deffile = File . expand_path ( '../../../support/libmysql.def' , __FILE__ )
127
- libfile = File . expand_path ( File . join ( rpath_dir , 'libmysql.lib' ) )
128
- file 'libmysql.a' => [ deffile , libfile ] do |t |
129
- when_writing 'building libmysql.a' do
130
- # Ruby kindly shows us where dllwrap is, but that tool does more than we want.
131
- # Maybe in the future Ruby could provide RbConfig::CONFIG['DLLTOOL'] directly.
132
- dlltool = RbConfig ::CONFIG [ 'DLLWRAP' ] . gsub ( 'dllwrap' , 'dlltool' )
133
- sh dlltool , '--kill-at' ,
134
- '--dllname' , 'libmysql.dll' ,
135
- '--output-lib' , 'libmysql.a' ,
136
- '--input-def' , deffile , libfile
137
- end
120
+ if RUBY_PLATFORM =~ /mswin|mingw/
121
+ # Build libmysql.a interface link library
122
+ require 'rake'
123
+
124
+ # Build libmysql.a interface link library
125
+ # Use rake to rebuild only if these files change
126
+ deffile = File . expand_path ( '../../../support/libmysql.def' , __FILE__ )
127
+ libfile = File . expand_path ( File . join ( rpath_dir , 'libmysql.lib' ) )
128
+ file 'libmysql.a' => [ deffile , libfile ] do |t |
129
+ when_writing 'building libmysql.a' do
130
+ # Ruby kindly shows us where dllwrap is, but that tool does more than we want.
131
+ # Maybe in the future Ruby could provide RbConfig::CONFIG['DLLTOOL'] directly.
132
+ dlltool = RbConfig ::CONFIG [ 'DLLWRAP' ] . gsub ( 'dllwrap' , 'dlltool' )
133
+ sh dlltool , '--kill-at' ,
134
+ '--dllname' , 'libmysql.dll' ,
135
+ '--output-lib' , 'libmysql.a' ,
136
+ '--input-def' , deffile , libfile
138
137
end
138
+ end
139
139
140
- Rake ::Task [ 'libmysql.a' ] . invoke
141
- $LOCAL_LIBS << ' ' << 'libmysql.a'
140
+ Rake ::Task [ 'libmysql.a' ] . invoke
141
+ $LOCAL_LIBS << ' ' << 'libmysql.a'
142
142
143
- # Make sure the generated interface library works (if cross-compiling, trust without verifying)
144
- unless RbConfig ::CONFIG [ 'host_os' ] =~ /mswin|mingw/
145
- abort "-----\n Cannot find libmysql.a\n ----" unless have_library ( 'libmysql' )
146
- abort "-----\n Cannot link to libmysql.a (my_init)\n ----" unless have_func ( 'my_init' )
147
- end
143
+ # Make sure the generated interface library works (if cross-compiling, trust without verifying)
144
+ unless RbConfig ::CONFIG [ 'host_os' ] =~ /mswin|mingw/
145
+ abort "-----\n Cannot find libmysql.a\n ----" unless have_library ( 'libmysql' )
146
+ abort "-----\n Cannot link to libmysql.a (my_init)\n ----" unless have_func ( 'my_init' )
147
+ end
148
148
149
- # Vendor libmysql.dll
150
- vendordir = File . expand_path ( '../../../vendor/' , __FILE__ )
151
- directory vendordir
149
+ # Vendor libmysql.dll
150
+ vendordir = File . expand_path ( '../../../vendor/' , __FILE__ )
151
+ directory vendordir
152
152
153
- vendordll = File . join ( vendordir , 'libmysql.dll' )
154
- dllfile = File . expand_path ( File . join ( rpath_dir , 'libmysql.dll' ) )
155
- file vendordll => [ dllfile , vendordir ] do |t |
156
- when_writing 'copying libmysql.dll' do
157
- cp dllfile , vendordll
158
- end
153
+ vendordll = File . join ( vendordir , 'libmysql.dll' )
154
+ dllfile = File . expand_path ( File . join ( rpath_dir , 'libmysql.dll' ) )
155
+ file vendordll => [ dllfile , vendordir ] do |t |
156
+ when_writing 'copying libmysql.dll' do
157
+ cp dllfile , vendordll
159
158
end
159
+ end
160
160
161
- # Copy libmysql.dll to the local vendor directory by default
162
- if arg_config ( '--no-vendor-libmysql' )
163
- # Fine, don't.
164
- puts "--no-vendor-libmysql"
165
- else # Default: arg_config('--vendor-libmysql')
166
- # Let's do it!
167
- Rake ::Task [ vendordll ] . invoke
168
- end
161
+ # Copy libmysql.dll to the local vendor directory by default
162
+ if arg_config ( '--no-vendor-libmysql' )
163
+ # Fine, don't.
164
+ puts "--no-vendor-libmysql"
165
+ else # Default: arg_config('--vendor-libmysql')
166
+ # Let's do it!
167
+ Rake ::Task [ vendordll ] . invoke
168
+ end
169
+ else
170
+ case explicit_rpath = with_config ( 'mysql-rpath' )
171
+ when true
172
+ abort "-----\n Option --with-mysql-rpath must have an argument\n -----"
173
+ when false
174
+ warn "-----\n Option --with-mysql-rpath has been disabled at your request\n -----"
175
+ when String
176
+ # The user gave us a value so use it
177
+ rpath_flags = " -Wl,-rpath,#{ explicit_rpath } "
178
+ warn "-----\n Setting mysql rpath to #{ explicit_rpath } \n -----"
179
+ $LDFLAGS << rpath_flags
169
180
else
170
- case explicit_rpath = with_config ( 'mysql-rpath' )
171
- when true
172
- abort "-----\n Option --with-mysql-rpath must have an argument\n -----"
173
- when false
174
- warn "-----\n Option --with-mysql-rpath has been disabled at your request\n -----"
175
- when String
176
- # The user gave us a value so use it
177
- rpath_flags = " -Wl,-rpath,#{ explicit_rpath } "
178
- warn "-----\n Setting mysql rpath to #{ explicit_rpath } \n -----"
179
- $LDFLAGS << rpath_flags
180
- else
181
- if libdir = rpath_dir [ %r{(-L)?(/[^ ]+)} , 2 ]
181
+ if libdir = rpath_dir [ %r{(-L)?(/[^ ]+)} , 2 ]
182
182
rpath_flags = " -Wl,-rpath,#{ libdir } "
183
183
if RbConfig ::CONFIG [ "RPATHFLAG" ] . to_s . empty? && try_link ( 'int main() {return 0;}' , rpath_flags )
184
184
# Usually Ruby sets RPATHFLAG the right way for each system, but not on OS X.
0 commit comments