Skip to content

Commit

Permalink
wip: use mini_portile 2.9.0.rc1 to simplify extconf
Browse files Browse the repository at this point in the history
note we drop ruby_memcheck for now because it depends on nokogiri
which (on platforms for which precompiled gems aren't available)
transitively depends on a different version of mini_portile
  • Loading branch information
flavorjones committed Sep 13, 2023
1 parent a16fa1b commit 7532dad
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 24 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ gem("rake-compiler-dock", "1.3.0")
gem("rdoc", "6.5.0")
gem("psych", "5.1.0")

gem("ruby_memcheck", "2.1.2") if Gem::Platform.local.os == "linux"
#gem("ruby_memcheck", "2.1.2") if Gem::Platform.local.os == "linux"
25 changes: 3 additions & 22 deletions ext/sqlite3/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,29 +65,8 @@ def configure_packaged_libraries
unless File.exist?(File.join(recipe.target, recipe.host, recipe.name, recipe.version))
recipe.cook
end
recipe.activate

# on macos, pkg-config will not return --cflags without this
ENV["PKG_CONFIG_ALLOW_SYSTEM_CFLAGS"] = "t"

# only needed for Ruby 3.1.3, see https://bugs.ruby-lang.org/issues/19233
RbConfig::CONFIG["PKG_CONFIG"] = config_string("PKG_CONFIG") || "pkg-config"

lib_path = File.join(recipe.path, "lib")
pcfile = File.join(lib_path, "pkgconfig", "sqlite3.pc")
abort_pkg_config("pkg_config") unless pkg_config(pcfile)

# see https://bugs.ruby-lang.org/issues/18490
ldflags = xpopen(["pkg-config", "--libs", "--static", pcfile], err: [:child, :out], &:read)
abort_pkg_config("xpopen") unless $?.success?
ldflags = ldflags.split

# see https://github.com/flavorjones/mini_portile/issues/118
"-L#{lib_path}".tap do |lib_path_flag|
ldflags.prepend(lib_path_flag) unless ldflags.include?(lib_path_flag)
end

ldflags.each { |ldflag| append_ldflags(ldflag) }
recipe.mkmf_config(pkg: "sqlite3")
end
end

Expand Down Expand Up @@ -131,6 +110,8 @@ def configure_extension
end

def minimal_recipe
require "rubygems"
gem "mini_portile2", "2.9.0.rc1" # gemspec is not respected at install time
require "mini_portile2"

MiniPortile.new(libname, sqlite3_config[:version]).tap do |recipe|
Expand Down
2 changes: 1 addition & 1 deletion sqlite3.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ Gem::Specification.new do |s|
]
s.rdoc_options = ["--main", "README.md"]

s.add_dependency("mini_portile2", "~> 2.8.0")
s.add_dependency("mini_portile2", "2.9.0.rc1")

s.extensions << "ext/sqlite3/extconf.rb"
end

0 comments on commit 7532dad

Please sign in to comment.