Skip to content

Commit 261fe97

Browse files
committed
Merge pull request #121 from cfallin/master
Provide a Ruby extension.
2 parents a0d9c59 + 973f425 commit 261fe97

File tree

22 files changed

+5379
-4
lines changed

22 files changed

+5379
-4
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "upb"]
2+
path = upb
3+
url = https://github.com/haberman/upb

Makefile.am

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,18 @@ python_EXTRA_DIST= \
238238
python/stubout.py \
239239
python/README.txt
240240

241-
all_EXTRA_DIST=$(java_EXTRA_DIST) $(python_EXTRA_DIST)
241+
ruby_EXTRA_DIST= \
242+
ruby/ext/defs.c \
243+
ruby/ext/encode_decode.c \
244+
ruby/ext/extconf.rb \
245+
ruby/ext/message.c \
246+
ruby/ext/protobuf.c \
247+
ruby/ext/protobuf.h \
248+
ruby/ext/repeated_field.c \
249+
ruby/ext/storage.c \
250+
ruby/ext/test.rb
251+
252+
all_EXTRA_DIST=$(java_EXTRA_DIST) $(python_EXTRA_DIST) $(ruby_EXTRA_DIST)
242253

243254
EXTRA_DIST = $(@DIST_LANG@_EXTRA_DIST) \
244255
autogen.sh \

autogen.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,9 @@ sed -i -e 's/RuntimeLibrary="5"/RuntimeLibrary="3"/g;
3737
# TODO(kenton): Remove the ",no-obsolete" part and fix the resulting warnings.
3838
autoreconf -f -i -Wall,no-obsolete
3939

40+
# pull down git submodules.
41+
git submodule init
42+
git submodule update
43+
4044
rm -rf autom4te.cache config.h.in~
4145
exit 0

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ AC_CONFIG_MACRO_DIR([m4])
2323
AC_ARG_VAR(DIST_LANG, [language to include in the distribution package (i.e., make dist)])
2424
case "$DIST_LANG" in
2525
"") DIST_LANG=cpp ;;
26-
all | cpp | java | python | javanano) ;;
26+
all | cpp | java | python | javanano | ruby) ;;
2727
*) AC_MSG_FAILURE([unknown language: $DIST_LANG]) ;;
2828
esac
2929
AC_SUBST(DIST_LANG)

ruby/README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
This directory contains the Ruby extension that implements Protocol Buffers
2+
functionality in Ruby.
3+
4+
The Ruby extension makes use of generated Ruby code that defines message and
5+
enum types in a Ruby DSL. You may write definitions in this DSL directly, but
6+
we recommend using protoc's Ruby generation support with .proto files. The
7+
build process in this directory only installs the extension; you need to
8+
install protoc as well to have Ruby code generation functionality.
9+
10+
Installation
11+
------------
12+
13+
To build this Ruby extension, you will need:
14+
15+
* Rake
16+
* Bundler
17+
* Ruby development headers
18+
* a C compiler
19+
* the upb submodule
20+
21+
First, ensure that upb/ is checked out:
22+
23+
$ cd .. # top level protobuf directory
24+
$ git submodule init
25+
$ git submodule update
26+
27+
Then install the required Ruby gems:
28+
29+
$ sudo gem install bundler rake rake-compiler rspec rubygems-tasks
30+
31+
Then build the Gem:
32+
33+
$ rake gem
34+
$ gem install pkg/protobuf-$VERSION.gem

ruby/Rakefile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
require "rake/extensiontask"
2+
require "rake/testtask"
3+
4+
spec = Gem::Specification.new do |s|
5+
s.name = "protobuf"
6+
s.version = "2.6.2"
7+
s.licenses = ["BSD"]
8+
s.summary = "Protocol Buffers"
9+
s.description = "Protocol Buffers are Google's data interchange format."
10+
s.authors = ["Protobuf Authors"]
11+
s.email = "[email protected]"
12+
13+
s.files = ["lib/protobuf_c.so", "lib/protobuf.rb"]
14+
end
15+
16+
Rake::ExtensionTask.new("protobuf_c", spec) do |ext|
17+
ext.lib_dir = "lib"
18+
ext.config_script = "extconf.rb"
19+
end
20+
21+
Rake::TestTask.new(:test => :build) do |t|
22+
t.test_files = FileList["tests/*.rb"]
23+
end
24+
25+
task :chmod do
26+
File.chmod(0755, "lib/protobuf_c.so")
27+
end
28+
29+
Gem::PackageTask.new(spec) do |pkg|
30+
end
31+
task :package => :chmod
32+
task :gem => :chmod
33+
34+
task :build => [:clean, :compile]
35+
task :default => [:build]
36+
37+
# vim:sw=2:et

0 commit comments

Comments
 (0)