You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by sh...@apache.org on 2019/03/23 12:03:36 UTC

[arrow] branch master updated: ARROW-4977: [Ruby] Add support for building on Windows

This is an automated email from the ASF dual-hosted git repository.

shiro pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/master by this push:
     new 87e9ec3  ARROW-4977: [Ruby] Add support for building on Windows
87e9ec3 is described below

commit 87e9ec305454609ac8664409885b6a9b93e891e2
Author: Kouhei Sutou <ko...@clear-code.com>
AuthorDate: Sat Mar 23 21:03:21 2019 +0900

    ARROW-4977: [Ruby] Add support for building on Windows
    
    Author: Kouhei Sutou <ko...@clear-code.com>
    
    Closes #3994 from kou/ruby-windows and squashes the following commits:
    
    60add6e6 <Kouhei Sutou>  Run tests on AppVeyor
    d17cc34e <Kouhei Sutou>  Add support for building on Windows
---
 ci/appveyor-cpp-build-mingw.bat        |  6 ++++++
 ruby/red-arrow/ext/arrow/extconf.rb    |  6 ++++++
 ruby/red-arrow/ext/arrow/red-arrow.hpp |  8 ++++++++
 ruby/red-arrow/lib/arrow.rb            |  1 +
 ruby/red-arrow/red-arrow.gemspec       |  2 +-
 ruby/red-arrow/test/run-test.rb        | 12 +++++++-----
 ruby/red-arrow/test/test-group.rb      |  4 ++--
 7 files changed, 31 insertions(+), 8 deletions(-)

diff --git a/ci/appveyor-cpp-build-mingw.bat b/ci/appveyor-cpp-build-mingw.bat
index cca9877..c92b8eb 100644
--- a/ci/appveyor-cpp-build-mingw.bat
+++ b/ci/appveyor-cpp-build-mingw.bat
@@ -26,6 +26,7 @@ set PKG_CONFIG_PATH=%INSTALL_DIR%\lib\pkgconfig
 set GI_TYPELIB_PATH=%INSTALL_DIR%\lib\girepository-1.0
 set ARROW_DLL_PATH=%MINGW_PREFIX%\bin
 set ARROW_DLL_PATH=%INSTALL_DIR%\bin;%ARROW_DLL_PATH%
+set ARROW_PKG_CONFIG_PATH=%PKG_CONFIG_PATH%
 
 for /f "usebackq" %%v in (`python3 -c "import sys; print('.'.join(map(str, sys.version_info[0:2])))"`) do (
   set PYTHON_VERSION=%%v
@@ -74,3 +75,8 @@ sed -i'' -s 's/\r//g' %C_GLIB_BUILD_DIR%/arrow-glib/version.h || exit /B
 ninja -C %C_GLIB_BUILD_DIR% || exit /B
 ninja -C %C_GLIB_BUILD_DIR% install || exit /B
 ruby c_glib\test\run-test.rb || exit /B
+
+pushd ruby\red-arrow
+ruby -S bundle install
+ruby -rdevkit test\run-test.rb
+popd
diff --git a/ruby/red-arrow/ext/arrow/extconf.rb b/ruby/red-arrow/ext/arrow/extconf.rb
index a8b9a0b..3b53a29 100644
--- a/ruby/red-arrow/ext/arrow/extconf.rb
+++ b/ruby/red-arrow/ext/arrow/extconf.rb
@@ -18,6 +18,12 @@
 require "extpp"
 require "mkmf-gnome2"
 
+arrow_pkg_config_path = ENV["ARROW_PKG_CONFIG_PATH"]
+if arrow_pkg_config_path
+  pkg_config_paths = [arrow_pkg_config_path, ENV["PKG_CONFIG_PATH"]].compact
+  ENV["PKG_CONFIG_PATH"] = pkg_config_paths.join(File::PATH_SEPARATOR)
+end
+
 unless required_pkg_config_package("arrow",
                                    debian: "libarrow-dev",
                                    redhat: "arrow-devel",
diff --git a/ruby/red-arrow/ext/arrow/red-arrow.hpp b/ruby/red-arrow/ext/arrow/red-arrow.hpp
index 5c9b846..6386d3d 100644
--- a/ruby/red-arrow/ext/arrow/red-arrow.hpp
+++ b/ruby/red-arrow/ext/arrow/red-arrow.hpp
@@ -21,6 +21,14 @@
 
 #include <arrow/api.h>
 
+#ifdef _WIN32
+#  define gmtime_r gmtime_r_ruby_win32
+#  define localtime_r localtime_r_ruby_win32
+#  include <ruby.h>
+#  undef gmtime_r
+#  undef localtime_r
+#endif
+
 #include <arrow-glib/arrow-glib.hpp>
 #include <rbgobject.h>
 
diff --git a/ruby/red-arrow/lib/arrow.rb b/ruby/red-arrow/lib/arrow.rb
index 257bd28..8fbc537 100644
--- a/ruby/red-arrow/lib/arrow.rb
+++ b/ruby/red-arrow/lib/arrow.rb
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+require "extpp/setup"
 require "gio2"
 
 require "arrow/version"
diff --git a/ruby/red-arrow/red-arrow.gemspec b/ruby/red-arrow/red-arrow.gemspec
index 317bcf2..f4fcda9 100644
--- a/ruby/red-arrow/red-arrow.gemspec
+++ b/ruby/red-arrow/red-arrow.gemspec
@@ -46,7 +46,7 @@ Gem::Specification.new do |spec|
   spec.test_files += Dir.glob("test/**/*")
   spec.extensions = ["ext/arrow/extconf.rb"]
 
-  spec.add_runtime_dependency("extpp")
+  spec.add_runtime_dependency("extpp", ">= 0.0.7")
   spec.add_runtime_dependency("gio2", ">= 3.3.6")
   spec.add_runtime_dependency("native-package-installer")
   spec.add_runtime_dependency("pkg-config")
diff --git a/ruby/red-arrow/test/run-test.rb b/ruby/red-arrow/test/run-test.rb
index 4712d49..4ed9a63 100755
--- a/ruby/red-arrow/test/run-test.rb
+++ b/ruby/red-arrow/test/run-test.rb
@@ -17,12 +17,14 @@
 # specific language governing permissions and limitations
 # under the License.
 
-ENV["TZ"] = "Asia/Tokyo"
-
 $VERBOSE = true
 
 require "pathname"
 
+(ENV["ARROW_DLL_PATH"] || "").split(File::PATH_SEPARATOR).each do |path|
+  RubyInstaller::Runtime.add_dll_directory(path)
+end
+
 base_dir = Pathname.new(__dir__).parent.expand_path
 
 lib_dir = base_dir + "lib"
@@ -33,9 +35,9 @@ make = nil
 if ENV["NO_MAKE"] != "yes"
   if ENV["MAKE"]
     make = ENV["MAKE"]
-  elsif system("type gmake > /dev/null")
+  elsif system("which gmake > #{File::NULL} 2>&1")
     make = "gmake"
-  elsif system("type make > /dev/null")
+  elsif system("which make > #{File::NULL} 2>&1")
     make = "make"
   end
 end
@@ -44,7 +46,7 @@ if make
     unless File.exist?("Makefile")
       system(RbConfig.ruby, "extconf.rb", "--enable-debug-build") or exit(false)
     end
-    system("#{make} > /dev/null") or exit(false)
+    system("#{make} > #{File::NULL}") or exit(false)
   end
 end
 
diff --git a/ruby/red-arrow/test/test-group.rb b/ruby/red-arrow/test/test-group.rb
index 5e7aabf..81edca4 100644
--- a/ruby/red-arrow/test/test-group.rb
+++ b/ruby/red-arrow/test/test-group.rb
@@ -43,8 +43,8 @@ class GroupTest < Test::Unit::TestCase
       table = Arrow::Table.new(raw_table)
       assert_equal(<<-TABLE, table.group(:time).count.to_s)
 	                     time	int
-0	2018-01-29T00:00:00+09:00	  1
-1	2018-01-30T00:00:00+09:00	  1
+0	#{time_values[0].iso8601}	  1
+1	#{time_values[1].iso8601}	  1
       TABLE
     end
   end