@@ -76,107 +76,107 @@ 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
82
-
83
- asplode ( "mysql client" ) unless found
79
+ exit 1 if libs . empty?
80
+ found ||= have_library ( libs . shift )
81
+ end
84
82
85
- rpath_dir = lib
86
- end
83
+ asplode ( "mysql client" ) unless found
87
84
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
95
87
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
100
95
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
115
99
end
116
- end
117
100
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
135
115
end
136
116
end
137
117
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'
140
140
141
- # Make sure the generated interface library works (if cross-compiling, trust without verifying)
142
- unless RbConfig ::CONFIG [ 'host_os' ] =~ /mswin|mingw/
143
- abort "-----\n Cannot find libmysql.a\n ----" unless have_library ( 'libmysql' )
144
- abort "-----\n Cannot 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 "-----\n Cannot find libmysql.a\n ----" unless have_library ( 'libmysql' )
144
+ abort "-----\n Cannot link to libmysql.a (my_init)\n ----" unless have_func ( 'my_init' )
145
+ end
146
146
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
150
150
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
156
157
end
157
- end
158
158
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 "-----\n Option --with-mysql-rpath must have an argument\n -----"
171
- when false
172
- warn "-----\n Option --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 "-----\n Setting 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
178
167
else
179
- if libdir = rpath_dir [ %r{(-L)?(/[^ ]+)} , 2 ]
168
+ case explicit_rpath = with_config ( 'mysql-rpath' )
169
+ when true
170
+ abort "-----\n Option --with-mysql-rpath must have an argument\n -----"
171
+ when false
172
+ warn "-----\n Option --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 "-----\n Setting mysql rpath to #{ explicit_rpath } \n -----"
177
+ $LDFLAGS << rpath_flags
178
+ else
179
+ if libdir = rpath_dir [ %r{(-L)?(/[^ ]+)} , 2 ]
180
180
rpath_flags = " -Wl,-rpath,#{ libdir } "
181
181
if RbConfig ::CONFIG [ "RPATHFLAG" ] . to_s . empty? && try_link ( 'int main() {return 0;}' , rpath_flags )
182
182
# Usually Ruby sets RPATHFLAG the right way for each system, but not on OS X.
0 commit comments