Rename protobuf Ruby module to google/protobuf and rework its build

system. The Ruby module build now uses an amalgamated distribution of
upb, and successfully builds a Ruby gem called 'google-protobuf' with
module 'google/protobuf'.
pull/134/head
Chris Fallin 2014-12-12 15:58:26 -08:00
parent f473bb9903
commit 91473dcebf
20 changed files with 17557 additions and 63 deletions

3
.gitmodules vendored
View File

@ -1,3 +0,0 @@
[submodule "upb"]
path = upb
url = https://github.com/haberman/upb

View File

@ -39,9 +39,5 @@ sed -i -e 's/RuntimeLibrary="5"/RuntimeLibrary="3"/g;
# TODO(kenton): Remove the ",no-obsolete" part and fix the resulting warnings.
autoreconf -f -i -Wall,no-obsolete
# pull down git submodules.
git submodule init
git submodule update
rm -rf autom4te.cache config.h.in~
exit 0

View File

@ -1,35 +1,19 @@
require "rake/extensiontask"
require "rake/testtask"
spec = Gem::Specification.new do |s|
s.name = "protobuf"
s.version = "2.6.2"
s.licenses = ["BSD"]
s.summary = "Protocol Buffers"
s.description = "Protocol Buffers are Google's data interchange format."
s.authors = ["Protobuf Authors"]
s.email = "protobuf@googlegroups.com"
s.files = ["lib/protobuf_c.so", "lib/protobuf.rb"]
end
spec = Gem::Specification.load("google-protobuf.gemspec")
Rake::ExtensionTask.new("protobuf_c", spec) do |ext|
ext.lib_dir = "lib"
ext.config_script = "extconf.rb"
ext.ext_dir = "ext/google/protobuf_c"
ext.lib_dir = "lib/google"
end
Rake::TestTask.new(:test => :build) do |t|
t.test_files = FileList["tests/*.rb"]
end
task :chmod do
File.chmod(0755, "lib/protobuf_c.so")
end
Gem::PackageTask.new(spec) do |pkg|
end
task :package => :chmod
task :gem => :chmod
task :build => [:clean, :compile]
task :default => [:build]

View File

@ -0,0 +1,10 @@
#!/usr/bin/ruby
require 'mkmf'
$CFLAGS += " -O3 -std=c99 -Wno-unused-function -DNDEBUG "
$objs = ["protobuf.o", "defs.o", "storage.o", "message.o",
"repeated_field.o", "encode_decode.o", "upb.o"]
create_makefile("google/protobuf_c")

View File

@ -35,15 +35,7 @@
#include <ruby/vm.h>
#include <ruby/encoding.h>
#include "upb/def.h"
#include "upb/handlers.h"
#include "upb/pb/decoder.h"
#include "upb/pb/encoder.h"
#include "upb/pb/glue.h"
#include "upb/json/parser.h"
#include "upb/json/printer.h"
#include "upb/shim/shim.h"
#include "upb/symtab.h"
#include "upb.h"
// Forward decls.
struct DescriptorPool;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,23 +0,0 @@
#!/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")

View File

@ -0,0 +1,22 @@
class << Gem::Specification
def find_c_source(dir)
`cd #{dir}; git ls-files "*.c" "*.h" extconf.rb Makefile`.split
.map{|f| "#{dir}/#{f}"}
end
end
Gem::Specification.new do |s|
s.name = "google-protobuf"
s.version = "3.0.0.alpha.2"
s.licenses = ["BSD"]
s.summary = "Protocol Buffers"
s.description = "Protocol Buffers are Google's data interchange format."
s.authors = ["Protobuf Authors"]
s.email = "protobuf@googlegroups.com"
s.require_paths = ["lib"]
s.extensions = ["ext/google/protobuf_c/extconf.rb"]
s.files = ["lib/google/protobuf.rb"] +
# extension C source
find_c_source("ext/google/protobuf_c")
s.test_files = `git ls-files -- tests`.split
end

View File

@ -28,4 +28,4 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
require 'protobuf_c'
require 'google/protobuf_c'

View File

@ -1,6 +1,6 @@
#!/usr/bin/ruby
require 'protobuf'
require 'google/protobuf'
require 'test/unit'
# ------------- generated code --------------

View File

@ -1,6 +1,6 @@
#!/usr/bin/ruby
require 'protobuf'
require 'google/protobuf'
require 'test/unit'
module StressTest

View File

@ -261,7 +261,7 @@ void GenerateFile(const google::protobuf::FileDescriptor* file,
"filename", file->name());
printer->Print(
"require 'protobuf'\n\n");
"require 'google/protobuf'\n\n");
for (int i = 0; i < file->dependency_count(); i++) {
const std::string& name = file->dependency(i)->name();

1
upb

@ -1 +0,0 @@
Subproject commit 56913be6bb57f81dbbf7baf9cc9a0a2cd1a36493