ruby-changes:37401
From: nobu <ko1@a...>
Date: Tue, 3 Feb 2015 17:16:00 +0900 (JST)
Subject: [ruby-changes:37401] nobu:r49482 (trunk): mkmf.rb: avoid interference
nobu 2015-02-03 17:15:47 +0900 (Tue, 03 Feb 2015) New Revision: 49482 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=49482 Log: mkmf.rb: avoid interference * lib/mkmf.rb (try_cppflags, try_cflags, try_ldflags): get rid of interference by modifying global variables in have_devel? method. [ruby-core:67962] [Bug #10821] Modified files: trunk/ChangeLog trunk/lib/mkmf.rb trunk/test/mkmf/base.rb trunk/test/mkmf/test_flags.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 49481) +++ ChangeLog (revision 49482) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Tue Feb 3 17:15:45 2015 Nobuyoshi Nakada <nobu@r...> + + * lib/mkmf.rb (try_cppflags, try_cflags, try_ldflags): get rid of + interference by modifying global variables in have_devel? method. + [ruby-core:67962] [Bug #10821] + Tue Feb 3 15:23:58 2015 Shugo Maeda <shugo@r...> * vm_method.c (remove_method): When remove refined Index: lib/mkmf.rb =================================================================== --- lib/mkmf.rb (revision 49481) +++ lib/mkmf.rb (revision 49482) @@ -610,9 +610,7 @@ MSG https://github.com/ruby/ruby/blob/trunk/lib/mkmf.rb#L610 end def try_cppflags(flags) - with_cppflags(flags) do - try_header("int main() {return 0;}") - end + try_header(MAIN_DOES_NOTHING, flags) end def with_cflags(flags) @@ -624,9 +622,7 @@ MSG https://github.com/ruby/ruby/blob/trunk/lib/mkmf.rb#L622 end def try_cflags(flags) - with_cflags(flags) do - try_compile("int main() {return 0;}") - end + try_compile(MAIN_DOES_NOTHING, flags) end def with_ldflags(flags) @@ -638,9 +634,7 @@ MSG https://github.com/ruby/ruby/blob/trunk/lib/mkmf.rb#L634 end def try_ldflags(flags) - with_ldflags(flags) do - try_link("int main() {return 0;}") - end + try_link(MAIN_DOES_NOTHING, flags) end def try_static_assert(expr, headers = nil, opt = "", &b) Index: test/mkmf/base.rb =================================================================== --- test/mkmf/base.rb (revision 49481) +++ test/mkmf/base.rb (revision 49482) @@ -49,7 +49,9 @@ class TestMkmf < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/mkmf/base.rb#L49 @buffer << s if @out end end +end +module TestMkmf::Base attr_reader :stdout def mkmflog(msg) @@ -84,7 +86,7 @@ class TestMkmf < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/mkmf/base.rb#L86 @tmpdir = Dir.mktmpdir @curdir = Dir.pwd @mkmfobj = Object.new - @stdout = Capture.new + @stdout = TestMkmf::Capture.new Dir.chdir(@tmpdir) @quiet, Logging.quiet = Logging.quiet, true init_mkmf @@ -127,3 +129,11 @@ class TestMkmf < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/mkmf/base.rb#L129 nil end end + +class TestMkmf + include TestMkmf::Base + + def assert_separately(args, src, *rest) + super(args + ["-r#{__FILE__}"], "extend TestMkmf::Base; setup\n#{src}", *rest) + end +end Index: test/mkmf/test_flags.rb =================================================================== --- test/mkmf/test_flags.rb (revision 49481) +++ test/mkmf/test_flags.rb (revision 49482) @@ -31,5 +31,26 @@ class TestMkmf https://github.com/ruby/ruby/blob/trunk/test/mkmf/test_flags.rb#L31 $warnflags = warnflags $extmk = val end + + def test_try_ldflag_invalid_opt + assert_separately([], <<-'end;') #do + assert(!try_ldflags("----------")) + assert(have_devel?, TestMkmf::MKMFLOG) + end; + end + + def test_try_cflag_invalid_opt + assert_separately([], <<-'end;') #do + assert(!try_cflags("----------")) + assert(have_devel?, TestMkmf::MKMFLOG) + end; + end + + def test_try_cppflag_invalid_opt + assert_separately([], <<-'end;') #do + assert(!try_cppflags("----------")) + assert(have_devel?, TestMkmf::MKMFLOG) + end; + end end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/