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

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41777 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2013-07-04 15:25:46 +00:00
Родитель 4e681d978a
Коммит 5d57230959
3 изменённых файлов: 43 добавлений и 2 удалений

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

@ -1,3 +1,8 @@
Fri Jul 5 00:25:39 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
* 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@ruby-lang.org>
* object.c (rb_obj_equal): Fixed an rb_obj_equal documentation typo

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

@ -1081,9 +1081,13 @@ SRC
# 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))

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

@ -2,6 +2,24 @@ require_relative 'base'
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
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