From 448a02373df95dafc0d4b3e4db0e77c96a09074d Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Sat, 15 Dec 2012 18:14:05 +0000 Subject: [PATCH] ruby: Enable C compiler warnings. This has the desirable side effect that the correct CFLAGS get passed to the C compiler when building the Ruby extension. --- .gitignore | 1 + configure.ac | 1 + generator/ruby.ml | 12 ++++++++++-- ruby/Makefile.am | 8 ++++---- ruby/ext/guestfs/extconf.rb | 33 --------------------------------- ruby/ext/guestfs/extconf.rb.in | 37 +++++++++++++++++++++++++++++++++++++ 6 files changed, 53 insertions(+), 39 deletions(-) delete mode 100644 ruby/ext/guestfs/extconf.rb create mode 100644 ruby/ext/guestfs/extconf.rb.in diff --git a/.gitignore b/.gitignore index 3873a19..6ee66e3 100644 --- a/.gitignore +++ b/.gitignore @@ -344,6 +344,7 @@ Makefile.in /ruby/examples/guestfs-ruby.3 /ruby/examples/stamp-guestfs-ruby.pod /ruby/ext/guestfs/extconf.h +/ruby/ext/guestfs/extconf.rb /ruby/ext/guestfs/_guestfs.bundle /ruby/ext/guestfs/_guestfs.c /ruby/ext/guestfs/_guestfs.so diff --git a/configure.ac b/configure.ac index 41f1760..8cc2fbf 100644 --- a/configure.ac +++ b/configure.ac @@ -1464,6 +1464,7 @@ AC_CONFIG_FILES([Makefile ruby/Makefile ruby/Rakefile ruby/examples/Makefile + ruby/ext/guestfs/extconf.rb sparsify/Makefile src/Makefile src/libguestfs.pc diff --git a/generator/ruby.ml b/generator/ruby.ml index daf94a5..7033713 100644 --- a/generator/ruby.ml +++ b/generator/ruby.ml @@ -413,6 +413,11 @@ ruby_user_cancel (VALUE gv) let doc = String.concat "\n * " doc in let doc = trim doc in + (* Because Ruby documentation appears as C comments, we must + * replace any instance of "/*". + *) + let doc = replace_str doc "/*" "/ *" in + let args = List.map name_of_argt args in let args = if optargs <> [] then args @ ["{optargs...}"] else args in let args = String.concat ", " args in @@ -667,15 +672,18 @@ ruby_user_cancel (VALUE gv) ) all_functions; pr "\ +extern void Init__guestfs (void); /* keep GCC warnings happy */ + /* Initialize the module. */ -void Init__guestfs () +void +Init__guestfs (void) { m_guestfs = rb_define_module (\"Guestfs\"); c_guestfs = rb_define_class_under (m_guestfs, \"Guestfs\", rb_cObject); e_Error = rb_define_class_under (m_guestfs, \"Error\", rb_eStandardError); #ifdef HAVE_RB_DEFINE_ALLOC_FUNC - rb_define_alloc_func (c_guestfs, ruby_guestfs_create); + rb_define_alloc_func (c_guestfs, (rb_alloc_func_t) ruby_guestfs_create); #endif rb_define_module_function (m_guestfs, \"create\", ruby_guestfs_create, -1); diff --git a/ruby/Makefile.am b/ruby/Makefile.am index 37eb3f3..5b755e5 100644 --- a/ruby/Makefile.am +++ b/ruby/Makefile.am @@ -47,10 +47,6 @@ CLEANFILES = \ if HAVE_RUBY -TESTS = run-bindtests run-ruby-tests - -TESTS_ENVIRONMENT = $(top_builddir)/run --test - all: $(generator_built) $(RAKE) build $(RAKE) rdoc @@ -64,4 +60,8 @@ install: $(INSTALL) -p -m 0644 $(srcdir)/lib/guestfs.rb $(DESTDIR)$(RUBY_SITELIB) $(INSTALL) -p -m 0755 $(builddir)/ext/guestfs/_guestfs.so $(DESTDIR)$(RUBY_SITEARCH) +TESTS = run-bindtests run-ruby-tests + +TESTS_ENVIRONMENT = $(top_builddir)/run --test + endif diff --git a/ruby/ext/guestfs/extconf.rb b/ruby/ext/guestfs/extconf.rb deleted file mode 100644 index d86e26d..0000000 --- a/ruby/ext/guestfs/extconf.rb +++ /dev/null @@ -1,33 +0,0 @@ -# libguestfs Ruby bindings -*- ruby -*- -# @configure_input@ -# Copyright (C) 2009 Red Hat Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -require 'mkmf' - -extension_name = '_guestfs' - -dir_config(extension_name) - -unless have_header("guestfs.h") - raise " not found" -end -unless have_library("guestfs", "guestfs_create", "guestfs.h") - raise "libguestfs not found" -end - -create_header -create_makefile(extension_name) diff --git a/ruby/ext/guestfs/extconf.rb.in b/ruby/ext/guestfs/extconf.rb.in new file mode 100644 index 0000000..15259ea --- /dev/null +++ b/ruby/ext/guestfs/extconf.rb.in @@ -0,0 +1,37 @@ +# libguestfs Ruby bindings -*- ruby -*- +# @configure_input@ +# Copyright (C) 2009-2012 Red Hat Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +require 'mkmf' + +extension_name = '_guestfs' + +dir_config(extension_name) + +unless have_header("guestfs.h") + raise " not found" +end +unless have_library("guestfs", "guestfs_create", "guestfs.h") + raise "libguestfs not found" +end + +$CFLAGS = + "#{$CFLAGS} @CFLAGS@ -DGUESTFS_PRIVATE_FUNCTIONS=1 " << + "@WARN_CFLAGS@ @WERROR_CFLAGS@" + +create_header +create_makefile(extension_name) -- 1.8.0.1