[前][次][番号順一覧][スレッド一覧]

ruby-changes:28028

From: akr <ko1@a...>
Date: Wed, 3 Apr 2013 19:01:56 +0900 (JST)
Subject: [ruby-changes:28028] akr:r40080 (trunk): * ext/extmk.rb (extmake): Use Logging.open to switch stdout and

akr	2013-04-03 19:00:49 +0900 (Wed, 03 Apr 2013)

  New Revision: 40080

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=40080

  Log:
    * ext/extmk.rb (extmake): Use Logging.open to switch stdout and
      stderr.  Delay Logging::log_close until the failure message is
      written.  Write the failure message only if log file is opened.
    
    * lib/mkmf.rb (Logging.log_opened?): New method.
    
      [ruby-dev:47215] [Bug #8209]

  Modified files:
    trunk/ChangeLog
    trunk/ext/extmk.rb
    trunk/lib/mkmf.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 40079)
+++ ChangeLog	(revision 40080)
@@ -1,3 +1,13 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Apr  3 18:53:58 2013  Tanaka Akira  <akr@f...>
+
+	* ext/extmk.rb (extmake): Use Logging.open to switch stdout and
+	  stderr.  Delay Logging::log_close until the failure message is
+	  written.  Write the failure message only if log file is opened.
+
+	* lib/mkmf.rb (Logging.log_opened?): New method.
+
+	  [ruby-dev:47215] [Bug #8209]
+
 Wed Apr  3 17:11:15 2013  Nobuyoshi Nakada  <nobu@r...>
 
 	* win32/win32.c (constat_apply): pass through unknown sequence which
Index: lib/mkmf.rb
===================================================================
--- lib/mkmf.rb	(revision 40079)
+++ lib/mkmf.rb	(revision 40080)
@@ -310,6 +310,10 @@ module MakeMakefile https://github.com/ruby/ruby/blob/trunk/lib/mkmf.rb#L310
       @log.sync = true
     end
 
+    def self::log_opened?
+      @log and not @log.closed?
+    end
+
     def self::open
       log_open
       $stderr.reopen(@log)
Index: ext/extmk.rb
===================================================================
--- ext/extmk.rb	(revision 40079)
+++ ext/extmk.rb	(revision 40080)
@@ -193,19 +193,11 @@ def extmake(target) https://github.com/ruby/ruby/blob/trunk/ext/extmk.rb#L193
 	  Logging::logfile 'mkmf.log'
 	  rm_f makefile
 	  if conf
-            stdout = $stdout.dup
-            stderr = $stderr.dup
-            unless verbose?
-              $stderr.reopen($stdout.reopen(@null))
-            end
-            begin
+            Logging.open do
+              unless verbose?
+                $stderr.reopen($stdout.reopen(@null))
+              end
               load $0 = conf
-            ensure
-              Logging::log_close
-              $stderr.reopen(stderr)
-              $stdout.reopen(stdout)
-              stdout.close
-              stderr.close
             end
 	  else
 	    create_makefile(target)
@@ -235,11 +227,13 @@ def extmake(target) https://github.com/ruby/ruby/blob/trunk/ext/extmk.rb#L227
         mess = "#{error}\n#{mess}"
       end
 
-      Logging::message(mess)
+      Logging::message(mess) if Logging.log_opened?
       print(mess)
       $stdout.flush
+      Logging::log_close
       return true
     end
+    Logging::log_close
     args = sysquote($mflags)
     unless $destdir.to_s.empty? or $mflags.defined?("DESTDIR")
       args += [sysquote("DESTDIR=" + relative_from($destdir, "../"+prefix))]

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]