You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildr.apache.org by dj...@apache.org on 2009/06/23 02:00:18 UTC

svn commit: r787450 - /buildr/trunk/lib/buildr/core/util.rb

Author: djspiewak
Date: Tue Jun 23 00:00:18 2009
New Revision: 787450

URL: http://svn.apache.org/viewvc?rev=787450&view=rev
Log:
Native version of Kernel#system on JRuby

Modified:
    buildr/trunk/lib/buildr/core/util.rb

Modified: buildr/trunk/lib/buildr/core/util.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/core/util.rb?rev=787450&r1=787449&r2=787450&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/core/util.rb (original)
+++ buildr/trunk/lib/buildr/core/util.rb Tue Jun 23 00:00:18 2009
@@ -278,3 +278,19 @@
   end
 
 end
+
+if Buildr::Util.java_platform?
+  require 'ffi'
+
+  module Kernel
+    extend extend FFI::Library
+    attach_function :system, [:string], :int
+    alias_method :__native_system__, :system
+    
+    def system(cmd, *args)
+      arg_str = args.map { |a| "'#{a}'" }
+      cd = "cd '#{Dir.pwd}' && "
+      __native_system__(cd + cmd + ' ' + arg_str.join(' ')) == 0
+    end
+  end
+end
\ No newline at end of file