diff --git a/ChangeLog b/ChangeLog index 606cf291dd..9af75f0b22 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +Tue Dec 7 08:00:44 2010 Nobuyoshi Nakada + + * configure.in, win32/Makefile.sub (WERRORFLAG): flag to treat + warnings as errors. + + * lib/mkmf.rb (Logging.postpone): yield log file object. + + * lib/mkmf.rb (xsystem): add options, :werror only right now. + + * lib/mkmf.rb (with_werror): check as if warnings are errors. + + * lib/mkmf.rb (convertible_int): make declaration conflict + warnings errors not to pass wrong type. [ruby-dev:42684] + + * lib/mkmf.rb (COMMON_MACROS): get rid of conflicts. + + * win32/Makefile.sub (WARNFLAGS): make declaration conflict + warnings errors if possible. + Sun Dec 5 10:32:11 2010 Tanaka Akira * cont.c: parenthesize macro arguments. diff --git a/configure.in b/configure.in index a80241b4e7..26ab9749aa 100644 --- a/configure.in +++ b/configure.in @@ -454,8 +454,7 @@ if test "$GCC:${warnflags+set}:no" = yes::no; then fi if test "$GCC" = yes; then RUBY_TRY_CFLAGS(-fvisibility=hidden, [RUBY_APPEND_OPTION(XCFLAGS, -fvisibility=hidden)]) -fi -if test "$GCC" = yes; then + AC_SUBST(WERRORFLAG, "-Werror") if test "$visibility_option" = yes; then RUBY_APPEND_OPTION(XCFLAGS, -fvisibility=hidden) else diff --git a/lib/mkmf.rb b/lib/mkmf.rb index 02e0b4bc2b..3e02886f67 100644 --- a/lib/mkmf.rb +++ b/lib/mkmf.rb @@ -277,9 +277,9 @@ module Logging log, *save = @log, @logfile, @orgout, @orgerr @log, @logfile, @orgout, @orgerr = nil, tmplog, log, log begin - log.print(open {yield}) + log.print(open {yield @log}) ensure - @log.close if @log + @log.close if @log and not @log.closed? File::open(tmplog) {|t| FileUtils.copy_stream(t, log)} @log, @logfile, @orgout, @orgerr = log, *save @postpone -= 1 @@ -293,7 +293,7 @@ module Logging end end -def xsystem command +def xsystem command, opts = nil varpat = /\$\((\w+)\)|\$\{(\w+)\}/ if varpat =~ command vars = Hash.new {|h, k| h[k] = ''; ENV[k]} @@ -302,7 +302,16 @@ def xsystem command end Logging::open do puts command.quote - system(command) + if opts and opts[:werror] + result = nil + Logging.postpone do |log| + result = (system(command) and File.zero?(log.path)) + "" + end + result + else + system(command) + end end end @@ -360,7 +369,7 @@ def have_devel? $have_devel end -def try_do(src, command, &b) +def try_do(src, command, *opts, &b) unless have_devel? raise < 0 prelude << "extern rbcv_typedef_ foo();" compat = UNIVERSAL_INTS.find {|t| - try_compile([prelude, "extern #{u}#{t} foo();"].join("\n"), opts, &b) + try_compile([prelude, "extern #{u}#{t} foo();"].join("\n"), opts, :werror=>true, &b) } if compat macname ||= type.sub(/_(?=t\z)/, '').tr_cpp @@ -2184,7 +2204,10 @@ EXPORT_PREFIX = config_string('EXPORT_PREFIX') {|s| s.strip} hdr = ['#include "ruby.h"' "\n"] config_string('COMMON_MACROS') do |s| Shellwords.shellwords(s).each do |w| - hdr << "#define " + w.split(/=/, 2).join(" ") + w, v = w.split(/=/, 2) + hdr << "#ifndef #{w}" + hdr << "#define #{[w, v].compact.join(" ")}" + hdr << "#endif /* #{w} */" end end config_string('COMMON_HEADERS') do |s| diff --git a/win32/Makefile.sub b/win32/Makefile.sub index 704d9609b3..134cd424c8 100644 --- a/win32/Makefile.sub +++ b/win32/Makefile.sub @@ -189,11 +189,12 @@ COMPILERFLAG = -Zm600 !endif !if !defined(WARNFLAGS) !if $(MSC_VER) >= 1400 -WARNFLAGS = -W2 -wd4996 +WARNFLAGS = -W2 -wd4996 -we4028 -we4142 !else WARNFLAGS = -W2 !endif !endif +WERRORFLAG = -WX !if !defined(CFLAGS) CFLAGS = $(RUNTIMEFLAG) $(DEBUGFLAGS) $(WARNFLAGS) $(OPTFLAGS) $(PROCESSOR_FLAG) $(COMPILERFLAG) !endif @@ -679,6 +680,7 @@ s,@SHELL@,$$(COMSPEC),;t t s,@BUILD_FILE_SEPARATOR@,\,;t t s,@PATH_SEPARATOR@,;,;t t s,@CFLAGS@,$(CFLAGS),;t t +s,@WERRORFLAG@,$(WERRORFLAG),;t t s,@DEFS@,$(DEFS),;t t s,@CPPFLAGS@,$(CPPFLAGS),;t t s,@CXXFLAGS@,$(CXXFLAGS),;t t