Merge pull request #134 from cfallin/master

Update Ruby build setup to produce gems successfully. Include upb as a single .c / .h file.
pull/135/head
Joshua Haberman 10 years ago
commit ed52203481
  1. 3
      .gitmodules
  2. 4
      autogen.sh
  3. 22
      ruby/Rakefile
  4. 0
      ruby/ext/google/protobuf_c/defs.c
  5. 0
      ruby/ext/google/protobuf_c/encode_decode.c
  6. 10
      ruby/ext/google/protobuf_c/extconf.rb
  7. 0
      ruby/ext/google/protobuf_c/message.c
  8. 0
      ruby/ext/google/protobuf_c/protobuf.c
  9. 10
      ruby/ext/google/protobuf_c/protobuf.h
  10. 0
      ruby/ext/google/protobuf_c/repeated_field.c
  11. 0
      ruby/ext/google/protobuf_c/storage.c
  12. 10078
      ruby/ext/google/protobuf_c/upb.c
  13. 7439
      ruby/ext/google/protobuf_c/upb.h
  14. 23
      ruby/ext/protobuf_c/extconf.rb
  15. 22
      ruby/google-protobuf.gemspec
  16. 2
      ruby/lib/google/protobuf.rb
  17. 2
      ruby/tests/basic.rb
  18. 2
      ruby/tests/stress.rb
  19. 2
      src/google/protobuf/compiler/ruby/ruby_generator.cc
  20. 1
      upb

3
.gitmodules vendored

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

@ -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. # TODO(kenton): Remove the ",no-obsolete" part and fix the resulting warnings.
autoreconf -f -i -Wall,no-obsolete autoreconf -f -i -Wall,no-obsolete
# pull down git submodules.
git submodule init
git submodule update
rm -rf autom4te.cache config.h.in~ rm -rf autom4te.cache config.h.in~
exit 0 exit 0

@ -1,35 +1,19 @@
require "rake/extensiontask" require "rake/extensiontask"
require "rake/testtask" require "rake/testtask"
spec = Gem::Specification.new do |s| spec = Gem::Specification.load("google-protobuf.gemspec")
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
Rake::ExtensionTask.new("protobuf_c", spec) do |ext| Rake::ExtensionTask.new("protobuf_c", spec) do |ext|
ext.lib_dir = "lib" ext.ext_dir = "ext/google/protobuf_c"
ext.config_script = "extconf.rb" ext.lib_dir = "lib/google"
end end
Rake::TestTask.new(:test => :build) do |t| Rake::TestTask.new(:test => :build) do |t|
t.test_files = FileList["tests/*.rb"] t.test_files = FileList["tests/*.rb"]
end end
task :chmod do
File.chmod(0755, "lib/protobuf_c.so")
end
Gem::PackageTask.new(spec) do |pkg| Gem::PackageTask.new(spec) do |pkg|
end end
task :package => :chmod
task :gem => :chmod
task :build => [:clean, :compile] task :build => [:clean, :compile]
task :default => [:build] task :default => [:build]

@ -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")

@ -35,15 +35,7 @@
#include <ruby/vm.h> #include <ruby/vm.h>
#include <ruby/encoding.h> #include <ruby/encoding.h>
#include "upb/def.h" #include "upb.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"
// Forward decls. // Forward decls.
struct DescriptorPool; struct DescriptorPool;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -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")

@ -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

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

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

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

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

1
upb

@ -1 +0,0 @@
Subproject commit 56913be6bb57f81dbbf7baf9cc9a0a2cd1a36493
Loading…
Cancel
Save