ruby-changes:18527
From: nobu <ko1@a...>
Date: Sat, 15 Jan 2011 12:05:46 +0900 (JST)
Subject: [ruby-changes:18527] Ruby:r30550 (trunk): * configure.in (warnflags): add -Werror=implicit-function-declaration
nobu 2011-01-15 11:57:36 +0900 (Sat, 15 Jan 2011) New Revision: 30550 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=30550 Log: * configure.in (warnflags): add -Werror=implicit-function-declaration if available. * lib/mkmf.rb (init_mkmf): ignore warnings in mkmf tests. * test/mkmf/base.rb (setup, teardown): restore config values. * test/mkmf/test_flags.rb: split from test_find_executable.rb. Added files: trunk/test/mkmf/test_flags.rb Modified files: trunk/ChangeLog trunk/configure.in trunk/lib/mkmf.rb trunk/test/mkmf/base.rb trunk/test/mkmf/test_find_executable.rb Index: configure.in =================================================================== --- configure.in (revision 30549) +++ configure.in (revision 30550) @@ -450,8 +450,14 @@ -Werror=pointer-arith \ -Werror=write-strings \ -Werror=declaration-after-statement \ - -Werror=shorten-64-to-32; do - test "$particular_werror_flags" = yes || wflag=`echo x$wflag | sed 's/^x-Werror=/-W/'` + -Werror=shorten-64-to-32 \ + -Werror-implicit-function-declaration \ + ; do + if test "$particular_werror_flags" = yes; then + wflag=`echo x$wflag | sed 's/^x-Werror-/-Werror=/;s/^x//'` + else + wflag=`echo x$wflag | sed 's/^x-Werror=/-W/;s/^x//'` + fi ok=no RUBY_TRY_CFLAGS($wflag, [warnflags="${warnflags+$warnflags }$wflag" ok=yes]) AS_CASE([$ok:$wflag], [no:-Werror=*], [ Index: ChangeLog =================================================================== --- ChangeLog (revision 30549) +++ ChangeLog (revision 30550) @@ -1,3 +1,14 @@ +Sat Jan 15 11:57:30 2011 Nobuyoshi Nakada <nobu@r...> + + * configure.in (warnflags): add -Werror=implicit-function-declaration + if available. + + * lib/mkmf.rb (init_mkmf): ignore warnings in mkmf tests. + + * test/mkmf/base.rb (setup, teardown): restore config values. + + * test/mkmf/test_flags.rb: split from test_find_executable.rb. + Sat Jan 15 10:04:14 2011 Nobuyoshi Nakada <nobu@r...> * ruby.c (process_options): autoload rubygems. Index: lib/mkmf.rb =================================================================== --- lib/mkmf.rb (revision 30549) +++ lib/mkmf.rb (revision 30550) @@ -1658,10 +1658,6 @@ end possible_command = (proc {|s| s if /top_srcdir/ !~ s} unless $extmk) extconf_h = $extconf_h ? "-DRUBY_EXTCONF_H=\\\"$(RUBY_EXTCONF_H)\\\" " : $defs.join(" ") << " " - if warnflags = CONFIG['warnflags'] and CONFIG['GCC'] == 'yes' and !$extmk - # turn warnings into errors only for bundled extensions. - warnflags = warnflags.gsub(/(\A|\s)-Werror=/, '\1-W') - end mk << %{ CC = #{CONFIG['CC']} CXX = #{CONFIG['CXX']} @@ -1676,7 +1672,7 @@ cflags = #{CONFIG['cflags']} optflags = #{CONFIG['optflags']} debugflags = #{CONFIG['debugflags']} -warnflags = #{warnflags} +warnflags = #{$warnflags} CFLAGS = #{$static ? '' : CONFIG['CCDLFLAGS']} #$CFLAGS #$ARCH_FLAG INCFLAGS = -I. #$INCFLAGS DEFS = #{CONFIG['DEFS']} @@ -2107,12 +2103,21 @@ # :stopdoc: -def init_mkmf(config = CONFIG) +def init_mkmf(config = CONFIG, rbconfig = RbConfig::CONFIG) $makefile_created = false $arg_config = [] $enable_shared = config['ENABLE_SHARED'] == 'yes' $defs = [] $extconf_h = nil + if $warnflags = CONFIG['warnflags'] and CONFIG['GCC'] == 'yes' + # turn warnings into errors only for bundled extensions. + config['warnflags'] = $warnflags.gsub(/(\A|\s)-Werror[-=]/, '\1-W') + RbConfig.expand(rbconfig['warnflags'] = config['warnflags'].dup) + config.each do |key, val| + RbConfig.expand(rbconfig[key] = val.dup) if /warnflags/ =~ val + end + $warnflags = config['warnflags'] unless $extmk + end $CFLAGS = with_config("cflags", arg_config("CFLAGS", config["CFLAGS"])).dup $ARCH_FLAG = with_config("arch_flag", arg_config("ARCH_FLAG", config["ARCH_FLAG"])).dup $CPPFLAGS = with_config("cppflags", arg_config("CPPFLAGS", config["CPPFLAGS"])).dup Index: test/mkmf/test_find_executable.rb =================================================================== --- test/mkmf/test_find_executable.rb (revision 30549) +++ test/mkmf/test_find_executable.rb (revision 30550) @@ -2,22 +2,6 @@ class TestMkmf class TestFindExecutable < TestMkmf - def test_valid_warnflags - val = $extmk - begin - makefile = mkmf do - $extmk = false - self.class::CONFIG['warnflags'] = "-Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Werror=pointer-arith -Werror=write-strings -Werror=declaration-after-statement -Werror=shorten-64-to-32" - self.class::CONFIG['GCC'] = 'yes' - configuration '.' - end - generated_flags = makefile.grep(/warnflags/).first[/^warnflags = .*$/] - assert_equal "warnflags = -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32", generated_flags - ensure - $extmk = val - end - end - def test_find_executable bug2669 = '[ruby-core:27912]' path, ENV["PATH"] = ENV["PATH"], path Index: test/mkmf/base.rb =================================================================== --- test/mkmf/base.rb (revision 30549) +++ test/mkmf/base.rb (revision 30550) @@ -58,15 +58,53 @@ end def setup + @rbconfig = rbconfig0 = RbConfig::CONFIG + @mkconfig = mkconfig0 = RbConfig::MAKEFILE_CONFIG + rbconfig = { + "hdrdir" => $hdrdir, + "srcdir" => $srcdir, + "topdir" => $topdir, + } + mkconfig = { + "hdrdir" => "$(top_srcdir)/include", + "srcdir" => "$(top_srcdir)/ext/#{$mdir}", + "topdir" => $topdir, + } + rbconfig0.each_pair {|key, val| rbconfig[key] ||= val.dup} + mkconfig0.each_pair {|key, val| mkconfig[key] ||= val.dup} + RbConfig.module_eval { + remove_const(:CONFIG) + const_set(:CONFIG, rbconfig) + remove_const(:MAKEFILE_CONFIG) + const_set(:MAKEFILE_CONFIG, mkconfig) + } + Object.class_eval { + remove_const(:CONFIG) + const_set(:CONFIG, mkconfig) + } @tmpdir = Dir.mktmpdir @curdir = Dir.pwd @mkmfobj = Object.new @stdout = Capture.new Dir.chdir(@tmpdir) @quiet, Logging.quiet = Logging.quiet, true + init_mkmf + $INCFLAGS[0, 0] = "-I. " end def teardown + rbconfig0 = @rbconfig + mkconfig0 = @mkconfig + RbConfig.module_eval { + remove_const(:CONFIG) + const_set(:CONFIG, rbconfig0) + remove_const(:MAKEFILE_CONFIG) + const_set(:MAKEFILE_CONFIG, mkconfig0) + } + Object.class_eval { + remove_const(:CONFIG) + const_set(:CONFIG, mkconfig0) + } Logging.quiet = @quiet Logging.log_close Dir.chdir(@curdir) Index: test/mkmf/test_flags.rb =================================================================== --- test/mkmf/test_flags.rb (revision 0) +++ test/mkmf/test_flags.rb (revision 30550) @@ -0,0 +1,35 @@ +require_relative 'base' + +class TestMkmf + class TestFlags < TestMkmf + def test_valid_warnflags + val = $extmk + warnflags = $warnflags + makefile = mkmf do + $extmk = false + self.class::CONFIG['warnflags'] = %w"-Wextra + -Wno-unused-parameter -Wno-parentheses -Wno-long-long + -Wno-missing-field-initializers -Werror=pointer-arith + -Werror=write-strings -Werror=declaration-after-statement + -Werror=shorten-64-to-32 + -Werror-implicit-function-declaration + ".join(' ') + self.class::CONFIG['GCC'] = 'yes' + init_mkmf(self.class::CONFIG) + configuration '.' + end + generated_flags = makefile.grep(/warnflags/).first[/^warnflags = (.*)$/, 1].split + + assert_equal %w" + -Wextra -Wno-unused-parameter -Wno-parentheses + -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith + -Wwrite-strings -Wdeclaration-after-statement + -Wshorten-64-to-32 -Wimplicit-function-declaration + ", generated_flags + + ensure + $warnflags = warnflags + $extmk = val + end + end +end Property changes on: test/mkmf/test_flags.rb ___________________________________________________________________ Added: svn:eol-style + LF -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/