Top Level Namespace

Defined Under Namespace

Modules: Libvirt

Instance Method Summary collapse

Instance Method Details

#have_const(const, headers = nil, opt = "", &b) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'ext/libvirt/extconf.rb', line 22

def have_const(const, headers = nil, opt = "", &b)
  checking_for libvirt_checking_message(const, headers, opt) do
    headers = cpp_include(headers)
    if try_compile(<<"SRC", opt, &b)
#{COMMON_HEADERS}
#{headers}
/*top*/
static int t = #{const};
SRC
      $defs.push(format("-DHAVE_CONST_%s", const.strip.upcase.tr_s("^A-Z0-9_", "_")))
      true
    else
      false
    end
  end
end

#libvirt_checking_message(target, place = nil, opt = nil) ⇒ Object

older mkmf does not have checking_message, so implement our own here



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'ext/libvirt/extconf.rb', line 8

def libvirt_checking_message(target, place = nil, opt = nil)
  [["in", place], ["with", opt]].inject("#{target}") do |msg, (pre, noun)|
    if noun
      [[:to_str], [:join, ","], [:to_s]].each do |meth, *args|
        if noun.respond_to?(meth)
          break noun = noun.send(meth, *args)
        end
      end
      msg << " #{pre} #{noun}" unless noun.empty?
    end
    msg
  end
end