Top Level Namespace

Defined Under Namespace

Modules: Libvirt

Instance Method Summary collapse

Instance Method Details

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



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'ext/libvirt/extconf.rb', line 28

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

#have_libvirt_consts(consts) ⇒ Object



45
46
47
# File 'ext/libvirt/extconf.rb', line 45

def have_libvirt_consts(consts)
  consts.each { |c| have_const(c, ["libvirt/libvirt.h", "libvirt/virterror.h"]) }
end

#have_libvirt_funcs(funcs) ⇒ Object



5
6
7
# File 'ext/libvirt/extconf.rb', line 5

def have_libvirt_funcs(funcs)
    funcs.each { |f| have_func(f, "libvirt/libvirt.h") }
end

#have_libvirt_types(types) ⇒ Object



9
10
11
# File 'ext/libvirt/extconf.rb', line 9

def have_libvirt_types(types)
    types.each { |t| have_type(t, "libvirt/libvirt.h") }
end

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

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



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'ext/libvirt/extconf.rb', line 14

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