1 # frozen_string_literal: false
4 RbConfig.fire_update!("top_srcdir", File.expand_path("../..", __dir__))
5 File.foreach(RbConfig::CONFIG["topdir"]+"/Makefile") do |line|
6 if /^CC_WRAPPER\s*=\s*/ =~ line
7 RbConfig.fire_update!('CC_WRAPPER', $'.strip)
16 $extout = '$(topdir)/'+RbConfig::CONFIG["EXTOUT"]
17 RbConfig::CONFIG['topdir'] = CONFIG['topdir'] = File.expand_path(CONFIG['topdir'])
18 RbConfig::CONFIG["extout"] = CONFIG["extout"] = $extout
20 $extout_prefix = "$(extout)$(target_prefix)/"
22 class TestMkmf < Test::Unit::TestCase
26 MKMFLOG = proc {File.read("mkmf.log") rescue ""}
40 STDOUT.print @filter ? @filter.call(@buffer) : @buffer
49 @origin.reopen(io) if @origin
52 @origin.reopen(io) if @origin
72 proc {MKMFLOG[] << msg}
76 @rbconfig = rbconfig0 = RbConfig::CONFIG
77 @mkconfig = mkconfig0 = RbConfig::MAKEFILE_CONFIG
84 "hdrdir" => "$(top_srcdir)/include",
85 "srcdir" => "$(top_srcdir)",
88 rbconfig0.each_pair {|key, val| rbconfig[key] ||= val.dup}
89 mkconfig0.each_pair {|key, val| mkconfig[key] ||= val.dup}
90 RbConfig.module_eval {
92 const_set(:CONFIG, rbconfig)
93 remove_const(:MAKEFILE_CONFIG)
94 const_set(:MAKEFILE_CONFIG, mkconfig)
96 MakeMakefile.class_eval {
98 const_set(:CONFIG, mkconfig)
100 @tmpdir = Dir.mktmpdir
102 @mkmfobj = Object.new
103 @stdout = Capture.new
105 @quiet, Logging.quiet = Logging.quiet, true
107 $INCFLAGS[0, 0] = "-I. "
111 rbconfig0 = @rbconfig
112 mkconfig0 = @mkconfig
113 RbConfig.module_eval {
114 remove_const(:CONFIG)
115 const_set(:CONFIG, rbconfig0)
116 remove_const(:MAKEFILE_CONFIG)
117 const_set(:MAKEFILE_CONFIG, mkconfig0)
119 MakeMakefile.class_eval {
120 remove_const(:CONFIG)
121 const_set(:CONFIG, mkconfig0)
123 Logging.quiet = @quiet
125 FileUtils.rm_f("mkmf.log")
127 FileUtils.rm_rf(@tmpdir)
130 def mkmf(*args, &block)
132 stdout, @stdout.origin, $stdout = @stdout.origin, $stdout, @stdout
133 verbose, $VERBOSE = $VERBOSE, false
134 @mkmfobj.instance_eval(*args, &block)
137 $stdout, @stdout.origin = @stdout.origin, stdout
140 def config_value(name)
141 create_tmpsrc("---config-value=#{name}")
142 xpopen(cpp_command('')) do |f|
143 f.grep(/^---config-value=(.*)/) {return $1}
150 include TestMkmf::Base
152 def assert_separately(args, src, *rest, **options)
153 super(args + ["-r#{__FILE__}"], "extend TestMkmf::Base; setup\nEND{teardown}\n#{src}", *rest, **options)