ruby-changes:18086
From: nobu <ko1@a...>
Date: Tue, 7 Dec 2010 08:00:59 +0900 (JST)
Subject: [ruby-changes:18086] Ruby:r30107 (trunk): * configure.in, win32/Makefile.sub (WERRORFLAG): flag to treat
nobu 2010-12-07 08:00:47 +0900 (Tue, 07 Dec 2010) New Revision: 30107 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=30107 Log: * 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. Modified files: trunk/ChangeLog trunk/configure.in trunk/lib/mkmf.rb trunk/win32/Makefile.sub Index: configure.in =================================================================== --- configure.in (revision 30106) +++ configure.in (revision 30107) @@ -454,8 +454,7 @@ 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 Index: ChangeLog =================================================================== --- ChangeLog (revision 30106) +++ ChangeLog (revision 30107) @@ -1,3 +1,22 @@ +Tue Dec 7 08:00:44 2010 Nobuyoshi Nakada <nobu@r...> + + * 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 <akr@f...> * cont.c: parenthesize macro arguments. Index: lib/mkmf.rb =================================================================== --- lib/mkmf.rb (revision 30106) +++ lib/mkmf.rb (revision 30107) @@ -277,9 +277,9 @@ 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 @@ 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 @@ 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 @@ $have_devel end -def try_do(src, command, &b) +def try_do(src, command, *opts, &b) unless have_devel? raise <<MSG The compiler failed to generate an executable file. @@ -369,7 +378,7 @@ end begin src = create_tmpsrc(src, &b) - xsystem(command) + xsystem(command, *opts) ensure log_src(src) rm_rf 'conftest.dSYM' @@ -419,21 +428,32 @@ }.join end +def with_werror(opt, opts = nil) + if opts + if opts[:werror] and config_string("WERRORFLAG") {|flag| opt = opt ? "#{opt} #{flag}" : flag} + (opts = opts.dup).delete(:werror) + end + yield(opt, opts) + else + yield(opt) + end +end + # :nodoc: -def try_link0(src, opt="", &b) +def try_link0(src, opt="", *opts, &b) cmd = link_command("", opt) if $universal require 'tmpdir' Dir.mktmpdir("mkmf_", oldtmpdir = ENV["TMPDIR"]) do |tmpdir| begin ENV["TMPDIR"] = tmpdir - try_do(src, cmd, &b) + try_do(src, cmd, *opts, &b) ensure ENV["TMPDIR"] = oldtmpdir end end else - try_do(src, cmd, &b) + try_do(src, cmd, *opts, &b) end end @@ -447,8 +467,8 @@ # # [+src+] a String which contains a C source # [+opt+] a String which contains linker options -def try_link(src, opt="", &b) - try_link0(src, opt, &b) +def try_link(src, opt="", *opts, &b) + try_link0(src, opt, *opts, &b) ensure rm_f "conftest*", "c0x32*" end @@ -462,8 +482,8 @@ # # [+src+] a String which contains a C source # [+opt+] a String which contains compiler options -def try_compile(src, opt="", &b) - try_do(src, cc_command(opt), &b) +def try_compile(src, opt="", *opts, &b) + with_werror(opt, *opts) {|_opt, *_opts| try_do(src, cc_command(_opt), *_opts, &b)} ensure rm_f "conftest*" end @@ -477,8 +497,8 @@ # # [+src+] a String which contains a C source # [+opt+] a String which contains preprocessor options -def try_cpp(src, opt="", &b) - try_do(src, cpp_command(CPPOUTFILE, opt), &b) +def try_cpp(src, opt="", *opts, &b) + try_do(src, cpp_command(CPPOUTFILE, opt), *opts, &b) ensure rm_f "conftest*" end @@ -1185,7 +1205,7 @@ u = "unsigned " if signed > 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 @@ 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| Index: win32/Makefile.sub =================================================================== --- win32/Makefile.sub (revision 30106) +++ win32/Makefile.sub (revision 30107) @@ -189,11 +189,12 @@ !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,@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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/