Top Level Namespace

Defined Under Namespace

Modules: Qt

Constant Summary collapse

ROOT =
File.expand_path('../..', __dir__)
GENERATOR =
File.join(ROOT, 'scripts/generate_bridge.rb')
GENERATED_DIR =
File.join(ROOT, 'build', 'generated')
GENERATED_WIDGETS =
File.join(GENERATED_DIR, 'widgets.rb')
GENERATED_API =
File.join(GENERATED_DIR, 'bridge_api.rb')
GENERATED_CONSTANTS =
File.join(GENERATED_DIR, 'constants.rb')
GENERATED_EVENT_PAYLOADS =
File.join(ROOT, 'build/generated/event_payloads.inc')
PKG_CONFIG =
RbConfig::CONFIG['PKG_CONFIG'] || 'pkg-config'
QT_PACKAGES =
%w[Qt6Core Qt6Gui Qt6Widgets].freeze
MINIMUM_QT_VERSION =
Gem::Version.new('6.4.2')
GENERATED_CPP =
File.join(ROOT, 'build/generated/qt_ruby_bridge.cpp')
LOCAL_CPP =
File.expand_path('qt_ruby_bridge.cpp')

Instance Method Summary collapse

Instance Method Details

#ensure_generated_bridge_inputs!Object



32
33
34
35
36
37
38
39
# File 'ext/qt_ruby_bridge/extconf.rb', line 32

def ensure_generated_bridge_inputs!
  return false if generated_bridge_inputs_available?

  abort "Generator script not found: #{GENERATOR}" unless File.exist?(GENERATOR)
  abort 'Failed to generate Qt bridge files.' unless system(generator_env, RbConfig.ruby, GENERATOR)

  true
end

#generated_bridge_inputs_available?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'ext/qt_ruby_bridge/extconf.rb', line 23

def generated_bridge_inputs_available?
  (File.exist?(LOCAL_CPP) || File.exist?(GENERATED_CPP)) && File.exist?(GENERATED_EVENT_PAYLOADS)
end

#generator_envObject



27
28
29
30
# File 'ext/qt_ruby_bridge/extconf.rb', line 27

def generator_env
  scope = ENV.fetch('QT_RUBY_SCOPE', nil)
  scope && !scope.empty? ? { 'QT_RUBY_SCOPE' => scope } : {}
end

#pkg_configObject



15
16
17
# File 'ext/qt_ruby_bridge/extconf.rb', line 15

def pkg_config(*)
  system(PKG_CONFIG, *, out: File::NULL, err: File::NULL)
end

#pkg_config_capture(*args) ⇒ Object



19
20
21
# File 'ext/qt_ruby_bridge/extconf.rb', line 19

def pkg_config_capture(*args)
  `#{[PKG_CONFIG, *args].join(' ')}`.strip
end