Skip to content

Commit 9ab0347

Browse files
committed
wip: update to latest mini_portile and drop the pkgconf hacks
See flavorjones/mini_portile#131
1 parent 5c8e329 commit 9ab0347

File tree

3 files changed

+23
-39
lines changed

3 files changed

+23
-39
lines changed

.github/workflows/sqlite3-ruby.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ jobs:
8686
steps:
8787
- run: |
8888
dnf group install -y "C Development Tools and Libraries"
89-
dnf install -y ruby ruby-devel libyaml-devel
89+
dnf install -y ruby ruby-devel libyaml-devel git-all
9090
- uses: actions/checkout@v4
9191
- run: bundle install
9292
- run: bundle exec rake compile -- --disable-system-libraries

Gemfile

+2
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ gem("rdoc", "6.5.0")
99
gem("psych", "5.1.0")
1010

1111
gem("ruby_memcheck", "2.1.2") if Gem::Platform.local.os == "linux"
12+
13+
gem "mini_portile2", git: "https://github.com/flavorjones/mini_portile", ref: "9ea08f7b"

ext/sqlite3/extconf.rb

+20-38
Original file line numberDiff line numberDiff line change
@@ -48,47 +48,29 @@ def configure_system_libraries
4848
end
4949

5050
def configure_packaged_libraries
51-
minimal_recipe.tap do |recipe|
52-
recipe.configure_options += ["--enable-shared=no", "--enable-static=yes"]
53-
ENV.to_h.tap do |env|
54-
user_cflags = with_config("sqlite-cflags")
55-
more_cflags = [
56-
"-fPIC", # needed for linking the static library into a shared library
57-
"-O2", # see https://github.com/sparklemotion/sqlite3-ruby/issues/335 for some benchmarks
58-
"-fvisibility=hidden", # see https://github.com/rake-compiler/rake-compiler-dock/issues/87
59-
]
60-
env["CFLAGS"] = [user_cflags, env["CFLAGS"], more_cflags].flatten.join(" ")
61-
recipe.configure_options += env.select { |k,v| ENV_ALLOWLIST.include?(k) }
62-
.map { |key, value| "#{key}=#{value.strip}" }
63-
end
64-
65-
unless File.exist?(File.join(recipe.target, recipe.host, recipe.name, recipe.version))
66-
recipe.cook
67-
end
68-
recipe.activate
69-
70-
# on macos, pkg-config will not return --cflags without this
71-
ENV["PKG_CONFIG_ALLOW_SYSTEM_CFLAGS"] = "t"
72-
73-
# only needed for Ruby 3.1.3, see https://bugs.ruby-lang.org/issues/19233
74-
RbConfig::CONFIG["PKG_CONFIG"] = config_string("PKG_CONFIG") || "pkg-config"
51+
recipe = minimal_recipe
52+
53+
recipe.configure_options += ["--enable-shared=no", "--enable-static=yes"]
54+
ENV.to_h.tap do |env|
55+
user_cflags = with_config("sqlite-cflags")
56+
more_cflags = [
57+
"-fPIC", # needed for linking the static library into a shared library
58+
"-O2", # see https://github.com/sparklemotion/sqlite3-ruby/issues/335 for some benchmarks
59+
"-fvisibility=hidden", # see https://github.com/rake-compiler/rake-compiler-dock/issues/87
60+
]
61+
env["CFLAGS"] = [user_cflags, env["CFLAGS"], more_cflags].flatten.join(" ")
62+
recipe.configure_options += env.select { |k,v| ENV_ALLOWLIST.include?(k) }
63+
.map { |key, value| "#{key}=#{value.strip}" }
64+
end
7565

76-
lib_path = File.join(recipe.path, "lib")
77-
pcfile = File.join(lib_path, "pkgconfig", "sqlite3.pc")
78-
abort_pkg_config("pkg_config") unless pkg_config(pcfile)
66+
unless File.exist?(File.join(recipe.target, recipe.host, recipe.name, recipe.version))
67+
recipe.cook
68+
end
7969

80-
# see https://bugs.ruby-lang.org/issues/18490
81-
ldflags = xpopen(["pkg-config", "--libs", "--static", pcfile], err: [:child, :out], &:read)
82-
abort_pkg_config("xpopen") unless $?.success?
83-
ldflags = ldflags.split
70+
lib_path = File.join(recipe.path, "lib")
71+
pcfile = File.join(lib_path, "pkgconfig", "sqlite3.pc")
8472

85-
# see https://github.com/flavorjones/mini_portile/issues/118
86-
"-L#{lib_path}".tap do |lib_path_flag|
87-
ldflags.prepend(lib_path_flag) unless ldflags.include?(lib_path_flag)
88-
end
89-
90-
ldflags.each { |ldflag| append_ldflags(ldflag) }
91-
end
73+
MiniPortile.activate_mkmf(pkgconf: pcfile)
9274
end
9375

9476
def configure_extension

0 commit comments

Comments
 (0)