Inject 1.8/1.9 pure-ruby entry point during xcompile
The original problem of .so files not included in the final gemspec is because rake-compiler put files in lib_dir/X.Y/extension while the pure-ruby entry point was looking for lib_dir/XY/extension
This commit is contained in:
parent
95db3c74df
commit
553c9a77c3
@ -21,6 +21,11 @@ Rake::ExtensionTask.new("mysql2", gemspec) do |ext|
|
||||
ext.cross_platform = ['x86-mingw32', 'x86-mswin32-60']
|
||||
ext.cross_config_options << "--with-mysql-include=#{mysql_lib}/include"
|
||||
ext.cross_config_options << "--with-mysql-lib=#{mysql_lib}/lib/opt"
|
||||
|
||||
# inject 1.8/1.9 pure-ruby entry point when cross compiling only
|
||||
ext.cross_compiling do |spec|
|
||||
spec.files << 'lib/mysql2/mysql2.rb'
|
||||
end
|
||||
end
|
||||
|
||||
ext.lib_dir = File.join 'lib', 'mysql2'
|
||||
@ -30,25 +35,16 @@ Rake::ExtensionTask.new("mysql2", gemspec) do |ext|
|
||||
end
|
||||
Rake::Task[:spec].prerequisites << :compile
|
||||
|
||||
namespace :cross do
|
||||
task :file_list do
|
||||
gemspec.extensions = []
|
||||
gemspec.files += Dir["lib/#{gemspec.name}/#{gemspec.name}.rb"]
|
||||
gemspec.files += Dir["lib/#{gemspec.name}/1.{8,9}/#{gemspec.name}.so"]
|
||||
# gemspec.files += Dir["ext/mysql2/*.dll"]
|
||||
end
|
||||
end
|
||||
|
||||
file 'lib/mysql2/mysql2.rb' do
|
||||
file 'lib/mysql2/mysql2.rb' do |t|
|
||||
name = gemspec.name
|
||||
File.open("lib/#{name}/#{name}.rb", 'wb') do |f|
|
||||
File.open(t.name, 'wb') do |f|
|
||||
f.write <<-eoruby
|
||||
require "#{name}/\#{RUBY_VERSION.sub(/\\.\\d+$/, '')}/#{name}"
|
||||
RUBY_VERSION =~ /(\\d+.\\d+)/
|
||||
require "#{name}/\#{$1}/#{name}"
|
||||
eoruby
|
||||
end
|
||||
end
|
||||
|
||||
if Rake::Task.task_defined?(:cross)
|
||||
Rake::Task[:cross].prerequisites << "lib/mysql2/mysql2.rb"
|
||||
Rake::Task[:cross].prerequisites << "cross:file_list"
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user