Top Level Namespace

Defined Under Namespace

Modules: RubyQt6

Constant Summary collapse

IS_MSWIN =
/mswin/ =~ RUBY_PLATFORM
IS_MINGW =
/mingw/ =~ RUBY_PLATFORM
IS_DARWIN =
RbConfig::CONFIG['host_os'].match?(/darwin/)

Instance Method Summary collapse

Instance Method Details

#have_libffiObject



96
97
98
99
100
101
# File 'lib/qt6/mkmf-rice.rb', line 96

def have_libffi
  # Check for libffi to support C style callacks.
  libffi_usable = system_libffi_usable?
  $CPPFLAGS += " -DHAVE_LIBFFI" if libffi_usable
  libffi_usable
end

#qmakeObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/mkmf-rubyqt6.rb', line 5

def qmake
  return @qmake if @qmake

  r = (ENV["QMAKE"] || "").strip
  return @qmake = r if r != ""

  ["qmake6", "qmake"].each do |qmake|
    `#{qmake} -v`
    return @qmake = qmake if $?.success?
  end

  raise "Could not find qmake, " \
    "please add qmake to your PATH environment variable"
end

#rubyqt6_extconf(mod, depends:) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/mkmf-rubyqt6.rb', line 35

def rubyqt6_extconf(mod, depends:)
  # Add custom cxxflags
  r = (ENV["RUBYQT6_CXXFLAGS"] || "").strip
  append_cppflags(r) if r != ""

  # Add rubyqt6 cxxflag
  r = "RUBYQT6_BUILD_#{mod.upcase}_LIB"
  append_cppflags("-D#{r}")

  # Add included directories
  append_cppflags("-I#{qt_install_headers}")
  (Array(depends) + Array(mod)).each do |name|
    if name.start_with?("Qt")
      includedir = File.join(qt_install_headers, name)
      append_cppflags("-I#{includedir}")
    elsif name.start_with?("K")
      includedir = File.join("/usr/include/KF6", name)
      append_cppflags("-I#{includedir}")
    end
  end

  # Add libraries
  (Array(depends) + Array(mod)).each do |name|
    if name.start_with?("Qt")
      library = name.sub("Qt", "Qt6")
      message = "Could not find lib#{library}, please install qt6 package"
      raise message unless find_library(library, nil, qt_install_libs)
    elsif name.start_with?("K")
      library = name.sub("K", "KF6")
      message = "Could not find lib#{library}, please install kf6 package"
      raise message unless find_library(library, nil, "/usr/lib")
    end
  end

  # Add rice library
  if mod != "Rice"
    spec = Gem::Specification.find_by_name("ruby-qt6-rice")
    rice_so = File.join(spec.full_gem_path, "lib/qt6/rice/rice.so")
    rice_so = File.join(spec.extension_dir, "qt6/rice/rice.so") unless File.exist?(rice_so)
    append_ldflags(rice_so)
  end

  # Create Makefile
  name = mod.downcase
  create_makefile("qt6/#{name}/#{name}")
end

#system_libffi_usable?Boolean

Returns:

  • (Boolean)


74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/qt6/mkmf-rice.rb', line 74

def system_libffi_usable?
  # We need pkg_config or ffi.h
  libffi_ok = pkg_config("libffi") ||
      have_header("ffi.h") ||
      find_header("ffi.h", "/usr/local/include", "/usr/include/ffi",
                  "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/ffi",
                  "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/ffi") ||
      (find_header("ffi.h", `xcrun --sdk macosx --show-sdk-path`.strip + "/usr/include/ffi") rescue false)

  # Ensure we can link to ffi_prep_closure_loc
  libffi_ok &&= have_library("ffi", "ffi_prep_closure_loc", [ "ffi.h" ]) ||
                have_library("libffi", "ffi_prep_closure_loc", [ "ffi.h" ]) ||
                have_library("libffi-8", "ffi_prep_closure_loc", [ "ffi.h" ])

  if RbConfig::CONFIG['host_os'] =~ /mswin/
    have_library('libffi_convenience')
    have_library('shlwapi')
  end

  libffi_ok
end