2011-10-01 21:27:00 -04:00
|
|
|
require_relative 'base'
|
|
|
|
|
|
|
|
class TestMkmf
|
|
|
|
class TestHaveFramework < TestMkmf
|
2013-07-04 11:25:46 -04:00
|
|
|
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))
|
2013-07-29 01:52:53 -04:00
|
|
|
cmd.gsub!("$@", "#{fwdir}/#{fw}")
|
|
|
|
cmd.gsub!(/ -bundle /, ' -dynamiclib ')
|
2013-07-04 11:25:46 -04:00
|
|
|
assert(xsystem(cmd), MKMFLOG)
|
|
|
|
$INCFLAGS << " " << "-F#{dir}".quote
|
|
|
|
yield fw, hdrname
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-02-21 20:32:14 -05:00
|
|
|
def test_core_foundation_framework
|
2012-08-01 18:29:58 -04:00
|
|
|
assert(have_framework("CoreFoundation"), mkmflog("try as Objective-C"))
|
2011-10-01 21:27:00 -04:00
|
|
|
end
|
2012-09-06 12:21:57 -04:00
|
|
|
|
|
|
|
def test_multi_frameworks
|
|
|
|
assert(have_framework("CoreFoundation"), mkmflog("try as Objective-C"))
|
|
|
|
assert(have_framework("Cocoa"), mkmflog("try as Objective-C"))
|
|
|
|
end
|
2013-07-04 11:25:46 -04:00
|
|
|
|
|
|
|
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
|
2011-10-01 21:27:00 -04:00
|
|
|
end
|
|
|
|
end if /darwin/ =~ RUBY_PLATFORM
|