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

ruby-changes:24867

From: nobu <ko1@a...>
Date: Fri, 7 Sep 2012 01:22:11 +0900 (JST)
Subject: [ruby-changes:24867] nobu:r36918 (trunk): mkmf.rb: fix splitting options with an argument

nobu	2012-09-07 01:21:57 +0900 (Fri, 07 Sep 2012)

  New Revision: 36918

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

  Log:
    mkmf.rb: fix splitting options with an argument
    
    * ext/extmk.rb (extmake), lib/mkmf.rb (have_framework): fix splitting
      options with an argument, not using NUL as special character.
      [ruby-core:47447] [Bug #6987]

  Modified files:
    trunk/ChangeLog
    trunk/ext/extmk.rb
    trunk/ext/tk/extconf.rb
    trunk/lib/mkmf.rb
    trunk/test/mkmf/test_framework.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 36917)
+++ ChangeLog	(revision 36918)
@@ -1,3 +1,9 @@
+Fri Sep  7 01:21:51 2012  Nobuyoshi Nakada  <nobu@r...>
+
+	* ext/extmk.rb (extmake), lib/mkmf.rb (have_framework): fix splitting
+	  options with an argument, not using NUL as special character.
+	  [ruby-core:47447] [Bug #6987]
+
 Thu Sep  6 14:49:49 2012  Nobuyoshi Nakada  <nobu@r...>
 
 	* .gdbinit (rp): FLONUM support.
Index: lib/mkmf.rb
===================================================================
--- lib/mkmf.rb	(revision 36917)
+++ lib/mkmf.rb	(revision 36918)
@@ -234,6 +234,10 @@
     t if times.all? {|n| n <= t}
   end
 
+  def split_libs(*strs)
+    strs.map {|s| s.split(/\s+(?=-|\z)/)}.flatten
+  end
+
   def merge_libs(*libs)
     libs.inject([]) do |x, y|
       xy = x & y
@@ -1018,11 +1022,10 @@
   def have_framework(fw, &b)
     checking_for fw do
       src = cpp_include("#{fw}/#{fw}.h") << "\n" "int main(void){return 0;}"
-      if try_link(src, "-ObjC -framework #{fw}", &b)
+      if try_link(src, opt = "-ObjC -framework #{fw}", &b)
         $defs.push(format("-DHAVE_FRAMEWORK_%s", fw.tr_cpp))
 	# TODO: non-worse way than this hack, to get rid of separating
 	# option and its argument.
-	opt = " -ObjC -framework\0#{fw}"
         $LDFLAGS << opt
         true
       else
@@ -1804,7 +1807,7 @@
 DEFS     = #{CONFIG['DEFS']}
 CPPFLAGS = #{extconf_h}#{$CPPFLAGS}
 CXXFLAGS = $(CFLAGS) #{CONFIG['CXXFLAGS']}
-ldflags  = #{$LDFLAGS.tr("\0", " ")}
+ldflags  = #{$LDFLAGS}
 dldflags = #{$DLDFLAGS} #{CONFIG['EXTDLDFLAGS']}
 ARCH_FLAG = #{$ARCH_FLAG}
 DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
Index: ext/tk/extconf.rb
===================================================================
--- ext/tk/extconf.rb	(revision 36917)
+++ ext/tk/extconf.rb	(revision 36918)
@@ -1995,7 +1995,7 @@
       end
     end
   end
-  $LDFLAGS << ' ' << libs.gsub(/((?:\A|\s)-framework)\s/, "\\1\0")
+  $LDFLAGS << ' ' << libs
   $libs << ' -ltk -ltcl'
   setup_for_macosx_framework(tclver, tkver) if tcl_cfg_dir && tk_cfg_dir
 end
Index: ext/extmk.rb
===================================================================
--- ext/extmk.rb	(revision 36917)
+++ ext/extmk.rb	(revision 36918)
@@ -258,9 +258,9 @@
       $extlibs ||= []
       $extpath ||= []
       unless $mswin
-        $extflags = ($extflags.split | $DLDFLAGS.split | $LDFLAGS.split).join(" ")
+        $extflags = split_libs($extflags, $DLDFLAGS, $LDFLAGS).uniq.join(" ")
       end
-      $extlibs = merge_libs($extlibs, $libs.split(/\s+(?=-|\z)/), $LOCAL_LIBS.split(/\s+(?=-|\z)/))
+      $extlibs = merge_libs($extlibs, split_libs($libs), split_libs($LOCAL_LIBS))
       $extpath |= $LIBPATH
     end
   ensure
Index: test/mkmf/test_framework.rb
===================================================================
--- test/mkmf/test_framework.rb	(revision 36917)
+++ test/mkmf/test_framework.rb	(revision 36918)
@@ -5,5 +5,10 @@
     def test_core_foundation_framework
       assert(have_framework("CoreFoundation"), mkmflog("try as Objective-C"))
     end
+
+    def test_multi_frameworks
+      assert(have_framework("CoreFoundation"), mkmflog("try as Objective-C"))
+      assert(have_framework("Cocoa"), mkmflog("try as Objective-C"))
+    end
   end
 end if /darwin/ =~ RUBY_PLATFORM

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

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