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