@@ -5,21 +5,31 @@ def gemspec
5
5
end
6
6
7
7
Rake ::ExtensionTask . new ( "mysql2" , gemspec ) do |ext |
8
- # Expand the path because the build dir is 3-4 levels deep in tmp/platform/version/
9
- connector_dir = File . expand_path ( "../../vendor/#{ CONNECTOR_DIR } " , __FILE__ )
10
- windows_options = [ "--with-mysql-dir=#{ connector_dir } " ]
8
+ # put binaries into lib/mysql2/ or lib/mysql2/x.y/
9
+ ext . lib_dir = File . join 'lib' , 'mysql2'
10
+
11
+ # clean compiled extension
12
+ CLEAN . include "#{ ext . lib_dir } /*.#{ RbConfig ::CONFIG [ 'DLEXT' ] } "
11
13
12
- # automatically add build options to avoid need of manual input
13
14
if RUBY_PLATFORM =~ /mswin|mingw/ then
14
- ext . config_options = windows_options
15
+ Rake ::Task [ 'vendor:mysql' ] . invoke
16
+ # Expand the path because the build dir is 3-4 levels deep in tmp/platform/version/
17
+ connector_dir = File . expand_path ( "../../vendor/#{ CONNECTOR_DIR } " , __FILE__ )
18
+ ext . config_options = [ "--with-mysql-dir=#{ connector_dir } " ]
15
19
else
16
20
ext . cross_compile = true
17
- ext . cross_platform = [ 'x86-mingw32' , 'x86-mswin32-60' ]
18
- ext . cross_config_options = windows_options
21
+ ext . cross_platform = [ 'x86-mingw32' , 'x86-mswin32-60' , 'x64-mingw32' ]
22
+ ext . cross_config_options = {
23
+ 'x86-mingw32' => [ "--with-mysql-dir=" + File . expand_path ( "../../vendor/mysql-connector-c-#{ CONNECTOR_VERSION } -win32" , __FILE__ ) ] ,
24
+ 'x86-mswin32-60' => [ "--with-mysql-dir=" + File . expand_path ( "../../vendor/mysql-connector-c-#{ CONNECTOR_VERSION } -win32" , __FILE__ ) ] ,
25
+ 'x64-mingw32' => [ "--with-mysql-dir=" + File . expand_path ( "../../vendor/mysql-connector-c-#{ CONNECTOR_VERSION } -winx64" , __FILE__ ) ] ,
26
+ }
19
27
20
- # inject 1.8/1.9 pure-ruby entry point when cross compiling only
21
28
ext . cross_compiling do |spec |
29
+ Rake ::Task [ 'lib/mysql2/mysql2.rb' ] . invoke
30
+ Rake ::Task [ 'vendor:mysql' ] . invoke ( spec . platform )
22
31
spec . files << 'lib/mysql2/mysql2.rb'
32
+ spec . files << 'vendor/libmysql.dll'
23
33
spec . post_install_message = <<-POST_INSTALL_MESSAGE
24
34
25
35
======================================================================================================
@@ -28,7 +38,7 @@ Rake::ExtensionTask.new("mysql2", gemspec) do |ext|
28
38
It was built using MySQL Connector/C version #{ CONNECTOR_VERSION } .
29
39
It's recommended to use the exact same version to avoid potential issues.
30
40
31
- At the time of building this gem, the necessary DLL files where available
41
+ At the time of building this gem, the necessary DLL files were available
32
42
in the following download:
33
43
34
44
http://dev.mysql.com/get/Downloads/Connector-C/#{ CONNECTOR_ZIP } /from/pick
@@ -40,11 +50,6 @@ Rake::ExtensionTask.new("mysql2", gemspec) do |ext|
40
50
POST_INSTALL_MESSAGE
41
51
end
42
52
end
43
-
44
- ext . lib_dir = File . join 'lib' , 'mysql2'
45
-
46
- # clean compiled extension
47
- CLEAN . include "#{ ext . lib_dir } /*.#{ RbConfig ::CONFIG [ 'DLEXT' ] } "
48
53
end
49
54
Rake ::Task [ :spec ] . prerequisites << :compile
50
55
@@ -58,10 +63,6 @@ require "#{name}/\#{$1}/#{name}"
58
63
end
59
64
end
60
65
61
- if Rake ::Task . task_defined? ( :cross )
62
- Rake ::Task [ :cross ] . prerequisites << "lib/mysql2/mysql2.rb"
63
- end
64
-
65
66
# DevKit task following the example of Luis Lavena's test-ruby-c-extension
66
67
task :devkit do
67
68
begin
74
75
if RUBY_PLATFORM =~ /mingw|mswin/ then
75
76
Rake ::Task [ 'compile' ] . prerequisites . unshift 'vendor:mysql'
76
77
Rake ::Task [ 'compile' ] . prerequisites . unshift 'devkit'
77
- else
78
- if Rake ::Task . tasks . map { |t | t . name } . include? 'cross'
79
- Rake ::Task [ 'cross' ] . prerequisites . unshift 'vendor:mysql'
80
- end
81
78
end
0 commit comments