-
Notifications
You must be signed in to change notification settings - Fork 550
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor extconf.rb #605
base: master
Are you sure you want to change the base?
Refactor extconf.rb #605
Conversation
Hmm, the breakage is on Ruby 1.9.1, 1.8.7, and Ruby EE because of |
Thanks for the effort on this! Will review it shortly. There's a ton of material in the merge queue at the moment. I am surprised that the Makefiles aren't correct on Windows - I spent a lot of time updating the Windows support for the 0.3.18 release, and added AppVeyor tests. What version of Windows and what compiler environment are you using? We're not removing any older Rubies just yet - the error is actually in the rm_f usage:
|
Ah yes, Windows. extconf.rb currently should work for MingW, but I compile mine using VC++. There's a ton of conditionals in extconf that test for Unixy environments (that MingW is more than VC++), and also logic for generating libmysql.a from libmysql.dll (that VC++ doesn't need, and errors out because of missing Also, because mysqlclient.lib is a static linkage version of MySQL, and that doesn't work too well with VC++ (the correct compiler version must be used -- the MySQL C connector comes with 1 mysqlclient.lib per VC++ version). libmysql.lib works better because it's a DLL and any version of VC++ (and MingW) should be able to link to it. line 300 is |
Oh, that's great. I really appreciate that you're a VC++ user and dug into the build system to make it better across all platforms / Rubies (...gotta get those 1.8.7 and 1.9.3 Rubies working though...). Very odd error with |
Hopefully with the platform code split up to various classes debugging the build system and improving it should be better in future. I'm not sure how to start fixing the old Rubies though. |
@lowjoel looks like this patch fixes it: diff --git a/ext/mysql2/extconf.rb b/ext/mysql2/extconf.rb
index 8320218..d6505e4 100644
--- a/ext/mysql2/extconf.rb
+++ b/ext/mysql2/extconf.rb
@@ -1,6 +1,12 @@
# encoding: UTF-8
require 'mkmf'
-require 'rake'
+
+# rake fucks with rm_f
+class << self
+ alias_method :rm_f_original, :rm_f
+ require 'rake'
+ alias_method :rm_f, :rm_f_original
+end
class Platform
# Gets the proper platform object for the current platform.
Maybe that should be wrapped in some condition on |
Strikes me as either a) a bug in rake, or b) newer rake doesn't work with 1.8.7 anymore. Thanks for looking at this, @tamird. Let's get that patch into this branch and it should be mergeable in the 0.4.0 queue. |
Thanks for updating the PR! Logged in my (slow) review queue. |
Thanks! |
Would you do another rebase to master now that prepared statements have landed? |
Okay, done! I'm not sure if I'm expecting merge conflicts though? It appears that this shouldn't affect what happens in the library, unless I'm missing something... |
Mostly a matter of triggering the tests to ensure that the combined code runs tests cleanly.
|
Okay, it seems to pass :) |
def detect_libraries | ||
libraries = %w{ mysqlclient libmysql } | ||
library = libraries.find do |library| | ||
have_library(library, 'mysql_query') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On my Mac, I have to remove the second argument for this to succeed.
That said, in the master extconf.rb, the output from mysql_config --libs
is used without calling have_library. This is preferred to allow the user to provide an explicit --with-mysql-config=... that points at an non-default location.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I think the problem here is that --with-mysql-config isn't properly accepted? See the other comment you made below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method only handles the detection of libraries if there is no mysql-config path specified.
@sodabrew I've added the check and rebased. Have a look. |
Thanks for updating! Please rebase again when you get a chance, and I think there may be one more rebase next before this PR is up for final review. |
Done! |
Wait, @sodabrew: this was recently added: # This is our wishlist. We use whichever flags work on the host.
# -Wall and -Wextra are included by default.
# TODO: fix statement.c and remove -Wno-error=declaration-after-statement
%w(
-Werror
-Weverything
-fsanitize=address
-fsanitize=integer
-fsanitize=thread
-fsanitize=memory
-fsanitize=undefined
-fsanitize=cfi
-Wno-error=declaration-after-statement
).each do |flag|
if try_link('int main() {return 0;}', flag)
$CFLAGS << ' ' << flag
end
end That only applies for GCC/clang? VC most definitely do not support those. My latest rebase were to pick only my changes. |
Could you rebase once more? Sorry about the ever-changing whitespace in extconf.rb this week! |
@sodabrew no problem. I've added the compile flag wishlist back to the same one as current master. Also I saw that mariadb was added to the paths to check, my branch has been fixed to support that too. |
Apologies in advance; #634 is about to drop another conflict on this |
You should preserve the entire diff from #634 because the current code results in an infinite loop if it can't find the mysql client headers. |
Why do you insist on keeping this cruft? |
Well, I'd rather not break things unnecessarily. If the decision is that we don't need this, then I'd be happy to omit it. |
0.4 is out and the rubocop PR landed earlier today. @lowjoel would you rebase this? |
… exhausted and a mysql library cannot be found.
Rebased, have a look. I've suppressed 2 classes of Rubocop warnings, they are:
I think following the recommendation would make the build script even harder to read. If you're okay with this, I'll squash it to one commit. |
Attempting to get this off my GH queue. |
Hello there.
I've made a pretty major rewrite for extconf.rb. It was generating bad makefiles for Windows (since it is not commonly tested) and while trying to fix that I felt that the flow of logic could be much better.
I've split the path detection logic into the
detect_*
functions, and the configuration logic toconfigure_*
functions. These are different depending on the platform.I've tried to be as faithful to the original implementation as possible, however I have not tested this on platforms other than Windows. Comments much appreciated.