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

ruby-changes:29725

From: nobu <ko1@a...>
Date: Fri, 5 Jul 2013 00:25:57 +0900 (JST)
Subject: [ruby-changes:29725] nobu:r41777 (trunk): mkmf.rb: header in framework

nobu	2013-07-05 00:25:46 +0900 (Fri, 05 Jul 2013)

  New Revision: 41777

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

  Log:
    mkmf.rb: header in framework
    
    * lib/mkmf.rb (have_framework): allow header file to check.
      [ruby-core:55745] [Bug #8593]

  Modified files:
    trunk/ChangeLog
    trunk/lib/mkmf.rb
    trunk/test/mkmf/test_framework.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 41776)
+++ ChangeLog	(revision 41777)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Jul  5 00:25:39 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* lib/mkmf.rb (have_framework): allow header file to check.
+	  [ruby-core:55745] [Bug #8593]
+
 Thu Jul  4 22:31:00 2013  Charlie Somerville  <charliesome@r...>
 
 	* object.c (rb_obj_equal): Fixed an rb_obj_equal documentation typo
Index: lib/mkmf.rb
===================================================================
--- lib/mkmf.rb	(revision 41776)
+++ lib/mkmf.rb	(revision 41777)
@@ -1081,9 +1081,13 @@ SRC https://github.com/ruby/ruby/blob/trunk/lib/mkmf.rb#L1081
   # the +HAVE_FRAMEWORK_RUBY+ preprocessor macro would be passed to the
   # compiler.
   #
-  def have_framework(fw, &b)
+  # If +fw+ is a pair of the framework name and its header file name
+  # that header file is checked, instead of the normally used header
+  # file which is named same as the framework.
+  def have_framework((fw, header), &b)
+    header ||= "#{fw}.h"
     checking_for fw do
-      src = cpp_include("#{fw}/#{fw}.h") << "\n" "int main(void){return 0;}"
+      src = cpp_include("#{fw}/#{header}") << "\n" "int main(void){return 0;}"
       opt = " -framework #{fw}"
       if try_link(src, "-ObjC#{opt}", &b)
         $defs.push(format("-DHAVE_FRAMEWORK_%s", fw.tr_cpp))
Index: test/mkmf/test_framework.rb
===================================================================
--- test/mkmf/test_framework.rb	(revision 41776)
+++ test/mkmf/test_framework.rb	(revision 41777)
@@ -2,6 +2,24 @@ require_relative 'base' https://github.com/ruby/ruby/blob/trunk/test/mkmf/test_framework.rb#L2
 
 class TestMkmf
   class TestHaveFramework < TestMkmf
+    def create_framework(fw, hdrname = "#{fw}.h")
+      Dir.mktmpdir("frameworks") do |dir|
+        fwdir = "#{dir}/#{fw}.framework"
+        hdrdir = "#{fwdir}/Headers"
+        FileUtils.mkdir_p(hdrdir)
+        File.write("#{hdrdir}/#{hdrname}", "")
+        src = "#{fwdir}/main.c"
+        File.write(src, "void #{fw}(void) {}")
+        cmd = LINK_SO.dup
+        RbConfig.expand(cmd, RbConfig::CONFIG.merge("OBJS"=>src))
+        cmd.sub!("$@", "#{fwdir}/#{fw}")
+        cmd.sub!(/ -bundle /, ' -dynamiclib ')
+        assert(xsystem(cmd), MKMFLOG)
+        $INCFLAGS << " " << "-F#{dir}".quote
+        yield fw, hdrname
+      end
+    end
+
     def test_core_foundation_framework
       assert(have_framework("CoreFoundation"), mkmflog("try as Objective-C"))
     end
@@ -10,5 +28,19 @@ class TestMkmf https://github.com/ruby/ruby/blob/trunk/test/mkmf/test_framework.rb#L28
       assert(have_framework("CoreFoundation"), mkmflog("try as Objective-C"))
       assert(have_framework("Cocoa"), mkmflog("try as Objective-C"))
     end
+
+    def test_empty_framework
+      create_framework("MkmfTest") do |fw|
+        assert(have_framework(fw), MKMFLOG)
+      end
+    end
+
+    def test_different_name_header
+      bug8593 = '[ruby-core:55745] [Bug #8593]'
+      create_framework("MkmfTest", "test_mkmf.h") do |fw, hdrname|
+        assert(!have_framework(fw), MKMFLOG)
+        assert(have_framework([fw, hdrname]), MKMFLOG)
+      end
+    end
   end
 end if /darwin/ =~ RUBY_PLATFORM

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

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