2015-12-16 00:07:31 -05:00
|
|
|
# frozen_string_literal: false
|
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"
|
2018-02-17 05:04:22 -05:00
|
|
|
File.write(src, "void #{fw}(void) {}\n")
|
2013-07-04 11:25:46 -04:00
|
|
|
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
|
|
|
|
|
2015-09-07 04:51:01 -04:00
|
|
|
def test_single_framework
|
2017-04-21 02:12:27 -04:00
|
|
|
assert(have_framework(%w"Ruby ruby.h"), 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
|
2017-04-21 02:12:27 -04:00
|
|
|
assert(have_framework(%w"Ruby ruby.h"), mkmflog("try as Objective-C"))
|
2014-07-30 12:17:55 -04:00
|
|
|
create_framework("MkmfTest") do |fw|
|
|
|
|
assert(have_framework(fw), MKMFLOG)
|
|
|
|
end
|
2012-09-06 12:21:57 -04:00
|
|
|
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
|
2014-03-11 00:22:34 -04:00
|
|
|
_bug8593 = '[ruby-core:55745] [Bug #8593]'
|
2013-07-04 11:25:46 -04:00
|
|
|
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
|