Skip to content

Commit

Permalink
Install pre-built libuv package
Browse files Browse the repository at this point in the history
  • Loading branch information
Watson1978 committed Nov 24, 2023
1 parent ff0bf9b commit a799975
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 31 deletions.
45 changes: 17 additions & 28 deletions ext/ilios/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
require 'fileutils'
require 'mini_portile2'
require 'mkmf'
require 'native-package-installer'

have_func('malloc_usable_size')
have_func('malloc_size')

CASSANDRA_CPP_DRIVER_INSTALL_PATH = File.expand_path('cpp-driver')
LIBUV_INSTALL_PATH = File.expand_path('libuv')

def num_cpu_cores
cores =
Expand All @@ -32,36 +32,26 @@ def num_cpu_cores
raise
end

unless File.exist?(LIBUV_INSTALL_PATH)
class LibuvRecipe < MiniPortileCMake
def configure_prefix
"-DCMAKE_INSTALL_PREFIX=#{LIBUV_INSTALL_PATH}"
end
end
unless NativePackageInstaller.install(
arch_linux: 'libuv',
alt_linux: 'libuv',
debian: 'libuv1-dev',
freebsd: 'libuv',
gentoo_linux: 'libuv',
homebrew: 'libuv',
macports: 'libuv',
redhat: 'libuv'
)

libuv_recipe = LibuvRecipe.new('libuv', Ilios::LIBUV_VERSION, make_command: "make -j #{num_cpu_cores}")
libuv_recipe.files << {
url: "https://github.com/libuv/libuv/archive/v#{Ilios::LIBUV_VERSION}.tar.gz"
}
libuv_recipe.cook
if RUBY_PLATFORM.include?('darwin')
unless find_executable('install_name_tool')
puts '------------------------------------------------------'
puts 'Error: install_name_tool is required to build this gem'
puts '------------------------------------------------------'
raise
end
xsystem("install_name_tool -id #{LIBUV_INSTALL_PATH}/lib/libuv.1.dylib #{LIBUV_INSTALL_PATH}/lib/libuv.1.dylib")
end
raise 'Failed to install libuv'
end

unless File.exist?(CASSANDRA_CPP_DRIVER_INSTALL_PATH)
class CassandraRecipe < MiniPortileCMake
def initialize(name, version, **kwargs)
ENV['LIBUV_ROOT_DIR'] = LIBUV_INSTALL_PATH
super(name, version, **kwargs)
end
# Install Cassandra C/C++ driver via MiniPortile2.
# It doesn't provide pre-built package in official repository at the each distributions,
# so we need to build it from source.

class CassandraRecipe < MiniPortileCMake
def configure_prefix
"-DCMAKE_INSTALL_PREFIX=#{CASSANDRA_CPP_DRIVER_INSTALL_PATH}"
end
Expand All @@ -80,8 +70,7 @@ def configure_prefix
FileUtils.rm_rf('ports')
FileUtils.rm_rf('tmp')

$CPPFLAGS += " -I#{CASSANDRA_CPP_DRIVER_INSTALL_PATH}/include -I#{LIBUV_INSTALL_PATH}/include"
$CPPFLAGS += " -I#{CASSANDRA_CPP_DRIVER_INSTALL_PATH}/include"
$LDFLAGS += " -L#{CASSANDRA_CPP_DRIVER_INSTALL_PATH}/lib -Wl,-rpath,#{CASSANDRA_CPP_DRIVER_INSTALL_PATH}/lib -lcassandra"
$LDFLAGS += " -L#{LIBUV_INSTALL_PATH}/lib -Wl,-rpath,#{LIBUV_INSTALL_PATH}/lib -luv"

create_makefile('ilios')
1 change: 1 addition & 0 deletions ilios.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ Gem::Specification.new do |spec|
spec.extensions << 'ext/ilios/extconf.rb'

spec.add_runtime_dependency('mini_portile2', '~> 2.8')
spec.add_runtime_dependency('native-package-installer', '~> 1.1')
end
3 changes: 0 additions & 3 deletions lib/ilios/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,4 @@ module Ilios

CASSANDRA_CPP_DRIVER_VERSION = '2.17.1'
public_constant :CASSANDRA_CPP_DRIVER_VERSION

LIBUV_VERSION = '1.47.0'
public_constant :LIBUV_VERSION
end

0 comments on commit a799975

Please sign in to comment.