* 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.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30107 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2010-12-06 23:00:47 +00:00
Родитель 75877a30a4
Коммит e806b0fed7
4 изменённых файлов: 63 добавлений и 20 удалений

Просмотреть файл

@ -1,3 +1,22 @@
Tue Dec 7 08:00:44 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* 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@fsij.org> Sun Dec 5 10:32:11 2010 Tanaka Akira <akr@fsij.org>
* cont.c: parenthesize macro arguments. * cont.c: parenthesize macro arguments.

Просмотреть файл

@ -454,8 +454,7 @@ if test "$GCC:${warnflags+set}:no" = yes::no; then
fi fi
if test "$GCC" = yes; then if test "$GCC" = yes; then
RUBY_TRY_CFLAGS(-fvisibility=hidden, [RUBY_APPEND_OPTION(XCFLAGS, -fvisibility=hidden)]) RUBY_TRY_CFLAGS(-fvisibility=hidden, [RUBY_APPEND_OPTION(XCFLAGS, -fvisibility=hidden)])
fi AC_SUBST(WERRORFLAG, "-Werror")
if test "$GCC" = yes; then
if test "$visibility_option" = yes; then if test "$visibility_option" = yes; then
RUBY_APPEND_OPTION(XCFLAGS, -fvisibility=hidden) RUBY_APPEND_OPTION(XCFLAGS, -fvisibility=hidden)
else else

Просмотреть файл

@ -277,9 +277,9 @@ module Logging
log, *save = @log, @logfile, @orgout, @orgerr log, *save = @log, @logfile, @orgout, @orgerr
@log, @logfile, @orgout, @orgerr = nil, tmplog, log, log @log, @logfile, @orgout, @orgerr = nil, tmplog, log, log
begin begin
log.print(open {yield}) log.print(open {yield @log})
ensure ensure
@log.close if @log @log.close if @log and not @log.closed?
File::open(tmplog) {|t| FileUtils.copy_stream(t, log)} File::open(tmplog) {|t| FileUtils.copy_stream(t, log)}
@log, @logfile, @orgout, @orgerr = log, *save @log, @logfile, @orgout, @orgerr = log, *save
@postpone -= 1 @postpone -= 1
@ -293,7 +293,7 @@ module Logging
end end
end end
def xsystem command def xsystem command, opts = nil
varpat = /\$\((\w+)\)|\$\{(\w+)\}/ varpat = /\$\((\w+)\)|\$\{(\w+)\}/
if varpat =~ command if varpat =~ command
vars = Hash.new {|h, k| h[k] = ''; ENV[k]} vars = Hash.new {|h, k| h[k] = ''; ENV[k]}
@ -302,7 +302,16 @@ def xsystem command
end end
Logging::open do Logging::open do
puts command.quote 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
end end
@ -360,7 +369,7 @@ def have_devel?
$have_devel $have_devel
end end
def try_do(src, command, &b) def try_do(src, command, *opts, &b)
unless have_devel? unless have_devel?
raise <<MSG raise <<MSG
The compiler failed to generate an executable file. The compiler failed to generate an executable file.
@ -369,7 +378,7 @@ MSG
end end
begin begin
src = create_tmpsrc(src, &b) src = create_tmpsrc(src, &b)
xsystem(command) xsystem(command, *opts)
ensure ensure
log_src(src) log_src(src)
rm_rf 'conftest.dSYM' rm_rf 'conftest.dSYM'
@ -419,21 +428,32 @@ def libpathflag(libpath=$DEFLIBPATH|$LIBPATH)
}.join }.join
end 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: # :nodoc:
def try_link0(src, opt="", &b) def try_link0(src, opt="", *opts, &b)
cmd = link_command("", opt) cmd = link_command("", opt)
if $universal if $universal
require 'tmpdir' require 'tmpdir'
Dir.mktmpdir("mkmf_", oldtmpdir = ENV["TMPDIR"]) do |tmpdir| Dir.mktmpdir("mkmf_", oldtmpdir = ENV["TMPDIR"]) do |tmpdir|
begin begin
ENV["TMPDIR"] = tmpdir ENV["TMPDIR"] = tmpdir
try_do(src, cmd, &b) try_do(src, cmd, *opts, &b)
ensure ensure
ENV["TMPDIR"] = oldtmpdir ENV["TMPDIR"] = oldtmpdir
end end
end end
else else
try_do(src, cmd, &b) try_do(src, cmd, *opts, &b)
end end
end end
@ -447,8 +467,8 @@ end
# #
# [+src+] a String which contains a C source # [+src+] a String which contains a C source
# [+opt+] a String which contains linker options # [+opt+] a String which contains linker options
def try_link(src, opt="", &b) def try_link(src, opt="", *opts, &b)
try_link0(src, opt, &b) try_link0(src, opt, *opts, &b)
ensure ensure
rm_f "conftest*", "c0x32*" rm_f "conftest*", "c0x32*"
end end
@ -462,8 +482,8 @@ end
# #
# [+src+] a String which contains a C source # [+src+] a String which contains a C source
# [+opt+] a String which contains compiler options # [+opt+] a String which contains compiler options
def try_compile(src, opt="", &b) def try_compile(src, opt="", *opts, &b)
try_do(src, cc_command(opt), &b) with_werror(opt, *opts) {|_opt, *_opts| try_do(src, cc_command(_opt), *_opts, &b)}
ensure ensure
rm_f "conftest*" rm_f "conftest*"
end end
@ -477,8 +497,8 @@ end
# #
# [+src+] a String which contains a C source # [+src+] a String which contains a C source
# [+opt+] a String which contains preprocessor options # [+opt+] a String which contains preprocessor options
def try_cpp(src, opt="", &b) def try_cpp(src, opt="", *opts, &b)
try_do(src, cpp_command(CPPOUTFILE, opt), &b) try_do(src, cpp_command(CPPOUTFILE, opt), *opts, &b)
ensure ensure
rm_f "conftest*" rm_f "conftest*"
end end
@ -1185,7 +1205,7 @@ def convertible_int(type, headers = nil, opts = nil, &b)
u = "unsigned " if signed > 0 u = "unsigned " if signed > 0
prelude << "extern rbcv_typedef_ foo();" prelude << "extern rbcv_typedef_ foo();"
compat = UNIVERSAL_INTS.find {|t| 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 if compat
macname ||= type.sub(/_(?=t\z)/, '').tr_cpp 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"] hdr = ['#include "ruby.h"' "\n"]
config_string('COMMON_MACROS') do |s| config_string('COMMON_MACROS') do |s|
Shellwords.shellwords(s).each do |w| 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
end end
config_string('COMMON_HEADERS') do |s| config_string('COMMON_HEADERS') do |s|

Просмотреть файл

@ -189,11 +189,12 @@ COMPILERFLAG = -Zm600
!endif !endif
!if !defined(WARNFLAGS) !if !defined(WARNFLAGS)
!if $(MSC_VER) >= 1400 !if $(MSC_VER) >= 1400
WARNFLAGS = -W2 -wd4996 WARNFLAGS = -W2 -wd4996 -we4028 -we4142
!else !else
WARNFLAGS = -W2 WARNFLAGS = -W2
!endif !endif
!endif !endif
WERRORFLAG = -WX
!if !defined(CFLAGS) !if !defined(CFLAGS)
CFLAGS = $(RUNTIMEFLAG) $(DEBUGFLAGS) $(WARNFLAGS) $(OPTFLAGS) $(PROCESSOR_FLAG) $(COMPILERFLAG) CFLAGS = $(RUNTIMEFLAG) $(DEBUGFLAGS) $(WARNFLAGS) $(OPTFLAGS) $(PROCESSOR_FLAG) $(COMPILERFLAG)
!endif !endif
@ -679,6 +680,7 @@ s,@SHELL@,$$(COMSPEC),;t t
s,@BUILD_FILE_SEPARATOR@,\,;t t s,@BUILD_FILE_SEPARATOR@,\,;t t
s,@PATH_SEPARATOR@,;,;t t s,@PATH_SEPARATOR@,;,;t t
s,@CFLAGS@,$(CFLAGS),;t t s,@CFLAGS@,$(CFLAGS),;t t
s,@WERRORFLAG@,$(WERRORFLAG),;t t
s,@DEFS@,$(DEFS),;t t s,@DEFS@,$(DEFS),;t t
s,@CPPFLAGS@,$(CPPFLAGS),;t t s,@CPPFLAGS@,$(CPPFLAGS),;t t
s,@CXXFLAGS@,$(CXXFLAGS),;t t s,@CXXFLAGS@,$(CXXFLAGS),;t t