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 323042a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 32 deletions.
43 changes: 14 additions & 29 deletions ext/ilios/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
require File.expand_path('../../lib/ilios/version', __dir__)
require 'fileutils'
require 'mini_portile2'
require 'native-package-installer'
require 'mkmf'

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,22 @@ 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

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
unless NativePackageInstaller.install(arch_linux: 'libuv',
debian: 'libuv1',
freebsd: 'libuv',
homebrew: 'libuv',
macports: 'libuv',
redhat: 'libuv',
fedora: 'libuv')
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 +66,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 323042a

Please sign in to comment.