Browse Source

Added support for binary gems.

Josh Haberman 9 years ago
parent
commit
af4aa9bd64
3 changed files with 12 additions and 3 deletions
  1. 2 2
      ruby/Gemfile.lock
  2. 5 0
      ruby/Rakefile
  3. 5 1
      ruby/lib/google/protobuf.rb

+ 2 - 2
ruby/Gemfile.lock

@@ -1,7 +1,7 @@
 PATH
   remote: .
   specs:
-    google-protobuf (3.0.0.alpha.4.0)
+    google-protobuf (3.0.0.alpha.5.0)
 
 GEM
   remote: https://rubygems.org/
@@ -25,4 +25,4 @@ DEPENDENCIES
   test-unit
 
 BUNDLED WITH
-   1.10.6
+   1.11.2

+ 5 - 0
ruby/Rakefile

@@ -21,6 +21,11 @@ else
     ext.ext_dir = "ext/google/protobuf_c"
     ext.lib_dir = "lib/google"
   end
+
+  task 'gem:windows' do
+    require 'rake_compiler_dock'
+    RakeCompilerDock.sh "bundle && rake cross native gem"
+  end
 end
 
 Gem::PackageTask.new(spec) do |pkg|

+ 5 - 1
ruby/lib/google/protobuf.rb

@@ -44,7 +44,11 @@ if RUBY_PLATFORM == "java"
   require 'json'
   require 'google/protobuf_java'
 else
-  require 'google/protobuf_c'
+  begin
+    require "google/#{RUBY_VERSION.sub(/\.\d$/, '')}/protobuf_c"
+  rescue LoadError
+    require 'google/protobuf_c'
+  end
 end
 
 require 'google/protobuf/repeated_field'