aboutsummaryrefslogtreecommitdiff
path: root/ruby/ext/protobuf_c/extconf.rb
diff options
context:
space:
mode:
authorChris Fallin <cfallin@c1f.net>2014-11-18 14:19:58 -0800
committerChris Fallin <cfallin@c1f.net>2014-12-09 16:55:59 -0800
commit973f425725f1cc18211992792f2aed83d3d73831 (patch)
treeda0022d2cbe3a0700c02765a02e1be5a8b0c4f30 /ruby/ext/protobuf_c/extconf.rb
parenta0d9c59a7604139401cab78a27542b23f5724c19 (diff)
downloadprotobuf-973f425725f1cc18211992792f2aed83d3d73831.tar.gz
protobuf-973f425725f1cc18211992792f2aed83d3d73831.tar.bz2
protobuf-973f425725f1cc18211992792f2aed83d3d73831.zip
Provide a Ruby extension.
This adds a Ruby extension in ruby/ that is based on the 'upb' library (now included as a submodule), and adds support for Ruby code generation to the protoc compiler.
Diffstat (limited to 'ruby/ext/protobuf_c/extconf.rb')
-rw-r--r--ruby/ext/protobuf_c/extconf.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/ruby/ext/protobuf_c/extconf.rb b/ruby/ext/protobuf_c/extconf.rb
new file mode 100644
index 00000000..7f23b1a8
--- /dev/null
+++ b/ruby/ext/protobuf_c/extconf.rb
@@ -0,0 +1,23 @@
+#!/usr/bin/ruby
+
+require 'mkmf'
+
+upb_path = File.absolute_path(File.dirname($0)) + "/../../../upb"
+libs = ["upb_pic", "upb.pb_pic", "upb.json_pic"]
+system("cd #{upb_path}; make " + libs.map{|l| "lib/lib#{l}.a"}.join(" "))
+
+$CFLAGS += " -O3 -std=c99 -Wno-unused-function -DNDEBUG"
+
+find_header("upb/upb.h", upb_path) or
+ raise "Can't find upb headers"
+find_library("upb_pic", "upb_msgdef_new", upb_path + "/lib") or
+ raise "Can't find upb lib"
+find_library("upb.pb_pic", "upb_pbdecoder_init", upb_path + "/lib") or
+ raise "Can't find upb.pb lib"
+find_library("upb.json_pic", "upb_json_printer_init", upb_path + "/lib") or
+ raise "Can't find upb.pb lib"
+
+$objs = ["protobuf.o", "defs.o", "storage.o", "message.o",
+ "repeated_field.o", "encode_decode.o"]
+
+create_makefile("protobuf_c")