Skip to content

Commit

Permalink
Merge pull request #1214 from haberman/binarygem
Browse files Browse the repository at this point in the history
Added support for binary gems.
  • Loading branch information
haberman committed Feb 8, 2016
2 parents 0906f5d + 6efe3aa commit bc21508
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
6 changes: 4 additions & 2 deletions 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/
Expand All @@ -10,6 +10,7 @@ GEM
rake (10.4.2)
rake-compiler (0.9.5)
rake
rake-compiler-dock (0.5.1)
rubygems-tasks (0.2.4)
test-unit (3.0.9)
power_assert
Expand All @@ -21,8 +22,9 @@ PLATFORMS
DEPENDENCIES
google-protobuf!
rake-compiler
rake-compiler-dock
rubygems-tasks
test-unit

BUNDLED WITH
1.10.6
1.11.2
11 changes: 11 additions & 0 deletions ruby/Rakefile
Expand Up @@ -20,6 +20,17 @@ else
Rake::ExtensionTask.new("protobuf_c", spec) do |ext|
ext.ext_dir = "ext/google/protobuf_c"
ext.lib_dir = "lib/google"
ext.cross_compile = true
ext.cross_platform = [
'x86-mingw32', 'x64-mingw32',
'x86_64-linux', 'x86-linux',
'universal-darwin'
]
end

task 'gem:windows' do
require 'rake_compiler_dock'
RakeCompilerDock.sh "bundle && rake cross native gem RUBY_CC_VERSION=2.3.0:2.2.2:2.1.6"
end
end

Expand Down
11 changes: 6 additions & 5 deletions ruby/google-protobuf.gemspec
Expand Up @@ -8,12 +8,13 @@ Gem::Specification.new do |s|
s.authors = ["Protobuf Authors"]
s.email = "protobuf@googlegroups.com"
s.require_paths = ["lib"]
s.files = `git ls-files -z`.split("\x0").find_all{|f| f =~ /lib\/.+\.rb/}
unless RUBY_PLATFORM == "java"
s.files += `git ls-files "*.c" "*.h" extconf.rb Makefile`.split
s.extensions= ["ext/google/protobuf_c/extconf.rb"]
else
s.files = Dir.glob('lib/**/*.rb')
if RUBY_PLATFORM == "java"
s.files += ["lib/google/protobuf_java.jar"]
else
s.files += Dir.glob('ext/**/*')
s.extensions= ["ext/google/protobuf_c/extconf.rb"]
s.add_development_dependency "rake-compiler-dock"
end
s.test_files = ["tests/basic.rb",
"tests/stress.rb",
Expand Down
6 changes: 5 additions & 1 deletion ruby/lib/google/protobuf.rb
Expand Up @@ -44,7 +44,11 @@ class ParseError < Error; end
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'
Expand Down

0 comments on commit bc21508

Please sign in to comment.