From b1b66cc389f72c529d3d37a5ccf0e076fcbdbcf1 Mon Sep 17 00:00:00 2001 From: Brian Lopez Date: Thu, 9 Sep 2010 07:35:31 -0700 Subject: [PATCH] enable cross-compilation --- ext/mysql2/result.c | 4 ++-- ext/mysql2/result.h | 2 +- tasks/compile.rake | 12 +++++++++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/ext/mysql2/result.c b/ext/mysql2/result.c index 7375df5..a78c9e3 100644 --- a/ext/mysql2/result.c +++ b/ext/mysql2/result.c @@ -95,7 +95,7 @@ static VALUE rb_mysql_result_fetch_row(VALUE self, ID db_timezone, ID app_timezo mysql2_result_wrapper * wrapper; MYSQL_ROW row; MYSQL_FIELD * fields = NULL; - unsigned int i = 0; + long i = 0; unsigned long * fieldLengths; void * ptr; @@ -286,7 +286,7 @@ static VALUE rb_mysql_result_fetch_row(VALUE self, ID db_timezone, ID app_timezo static VALUE rb_mysql_result_fetch_fields(VALUE self) { mysql2_result_wrapper * wrapper; - unsigned int i = 0; + long i = 0; short int symbolizeKeys = 0; VALUE defaults; diff --git a/ext/mysql2/result.h b/ext/mysql2/result.h index dd47ced..c637d9e 100644 --- a/ext/mysql2/result.h +++ b/ext/mysql2/result.h @@ -8,7 +8,7 @@ typedef struct { VALUE fields; VALUE rows; VALUE encoding; - unsigned int numberOfFields; + long numberOfFields; unsigned long numberOfRows; unsigned long lastRowProcessed; short int resultFreed; diff --git a/tasks/compile.rake b/tasks/compile.rake index d767bfe..7979ae2 100644 --- a/tasks/compile.rake +++ b/tasks/compile.rake @@ -4,7 +4,12 @@ require "rake/extensiontask" MYSQL_VERSION = "5.1.50" MYSQL_MIRROR = ENV['MYSQL_MIRROR'] || "http://mysql.mirrors.pair.com" -Rake::ExtensionTask.new("mysql2", JEWELER.gemspec) do |ext| + +def gemspec + @clean_gemspec ||= eval(File.read(File.expand_path('../../mysql2.gemspec', __FILE__))) +end + +Rake::ExtensionTask.new("mysql2", gemspec) do |ext| # reference where the vendored MySQL got extracted mysql_lib = File.expand_path(File.join(File.dirname(__FILE__), '..', 'vendor', "mysql-#{MYSQL_VERSION}-win32")) @@ -12,6 +17,11 @@ Rake::ExtensionTask.new("mysql2", JEWELER.gemspec) do |ext| if RUBY_PLATFORM =~ /mswin|mingw/ then ext.config_options << "--with-mysql-include=#{mysql_lib}/include" ext.config_options << "--with-mysql-lib=#{mysql_lib}/lib/opt" + else + ext.cross_compile = true + 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" end ext.lib_dir = File.join 'lib', 'mysql2'