Sha256: 6a1d2b17fe1ad46eae2fc133f067a3b4f51ecd6b35b3fdc913382004c3ff810d

Contents?: true

Size: 1.96 KB

Versions: 1

Compression:

Stored size: 1.96 KB

Contents

# frozen_string_literal: true

require 'rubygems'
require 'mkmf'
require 'rbconfig'

dir_config 'um_ext'

KERNEL_INFO_RE = /Linux (\d)\.(\d+)(?:\.)?((?:\d+\.?)*)(?:\-)?([\w\-]+)?/
def get_config
  config = { linux: !!(RUBY_PLATFORM =~ /linux/) }
  raise "UringMachine only works on Linux!" if !config[:linux]

  kernel_info = `uname -sr`
  m = kernel_info.match(KERNEL_INFO_RE)
  raise "Could not parse Linux kernel information (#{kernel_info.inspect})" if !m

  version, major_revision, distribution = m[1].to_i, m[2].to_i, m[4]

  combined_version = version.to_i * 100 + major_revision.to_i
  raise "UringMachine requires kernel version 6.4 or newer!" if combined_version < 604

  config[:kernel_version]     = combined_version
  config[:submit_all_flag]    = combined_version >= 518
  config[:coop_taskrun_flag]  = combined_version >= 519
  config[:single_issuer_flag] = combined_version >= 600
  config[:prep_bind]          = combined_version >= 611
  config[:prep_listen]        = combined_version >= 611

  config
end

config = get_config
puts "Building UringMachine (\n#{config.map { |(k, v)| "  #{k}: #{v}\n"}.join})"

# require_relative 'zlib_conf'

liburing_path = File.expand_path('../../vendor/liburing', __dir__)
FileUtils.cd liburing_path do
  system('./configure', exception: true)
  FileUtils.cd File.join(liburing_path, 'src') do
    system('make', 'liburing.a', exception: true)
  end
end

if !find_header 'liburing.h', File.join(liburing_path, 'src/include')
  raise "Couldn't find liburing.h"
end

if !find_library('uring', nil, File.join(liburing_path, 'src'))
  raise "Couldn't find liburing.a"
end

$defs << '-DHAVE_IORING_SETUP_SUBMIT_ALL'   if config[:submit_all_flag]
$defs << '-DHAVE_IORING_SETUP_COOP_TASKRUN' if config[:coop_taskrun_flag]
$defs << '-DHAVE_IO_URING_PREP_BIND'        if config[:prep_bind]
$defs << '-DHAVE_IO_URING_PREP_LISTEN'      if config[:prep_listen]
$CFLAGS << ' -Wno-pointer-arith'

CONFIG['optflags'] << ' -fno-strict-aliasing'

create_makefile 'um_ext'

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
uringmachine-0.4 ext/um/extconf.rb