Skip to content

Commit 5ec7855

Browse files
authored
Merge pull request #355 from sparklemotion/354-work-around-fedora-pkgconf-library-path
Work around Fedora pkgconf issue
2 parents 5c443e2 + c0b1bae commit 5ec7855

File tree

2 files changed

+36
-8
lines changed

2 files changed

+36
-8
lines changed

.github/workflows/sqlite3-ruby.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,21 @@ jobs:
7676
- run: bundle exec rake compile -- --enable-system-libraries
7777
- run: bundle exec rake test
7878

79+
# reported at https://github.com/sparklemotion/sqlite3-ruby/issues/354
80+
# TODO remove once https://github.com/flavorjones/mini_portile/issues/118 is fixed
81+
fedora:
82+
runs-on: ubuntu-latest
83+
container:
84+
image: fedora:35
85+
steps:
86+
- run: |
87+
dnf group install -y "C Development Tools and Libraries"
88+
dnf install -y ruby ruby-devel
89+
- uses: actions/checkout@v3
90+
- run: bundle install
91+
- run: bundle exec rake compile -- --disable-system-libraries
92+
- run: bundle exec rake test
93+
7994
sqlcipher:
8095
strategy:
8196
fail-fast: false

ext/sqlite3/extconf.rb

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,24 @@ def configure_packaged_libraries
6666
end
6767
recipe.activate
6868

69-
ENV["PKG_CONFIG_ALLOW_SYSTEM_CFLAGS"] = "t" # on macos, pkg-config will not return --cflags without this
70-
pcfile = File.join(recipe.path, "lib", "pkgconfig", "sqlite3.pc")
71-
if pkg_config(pcfile)
72-
# see https://bugs.ruby-lang.org/issues/18490
73-
libs = xpopen(["pkg-config", "--libs", "--static", pcfile], err: [:child, :out], &:read)
74-
libs.split.each { |lib| append_ldflags(lib) } if $?.success?
75-
else
76-
abort("\nCould not configure the build properly. Please install either the `pkg-config` utility or the `pkg-config` rubygem.\n\n")
69+
# on macos, pkg-config will not return --cflags without this
70+
ENV["PKG_CONFIG_ALLOW_SYSTEM_CFLAGS"] = "t"
71+
72+
lib_path = File.join(recipe.path, "lib")
73+
pcfile = File.join(lib_path, "pkgconfig", "sqlite3.pc")
74+
abort_pkg_config("pkg_config") unless pkg_config(pcfile)
75+
76+
# see https://bugs.ruby-lang.org/issues/18490
77+
flags = xpopen(["pkg-config", "--libs", "--static", pcfile], err: [:child, :out], &:read)
78+
abort_pkg_config("xpopen") unless $?.success?
79+
flags = flags.split
80+
81+
# see https://github.com/flavorjones/mini_portile/issues/118
82+
"-L#{lib_path}".tap do |lib_path_flag|
83+
flags.prepend(lib_path_flag) unless flags.include?(lib_path_flag)
7784
end
85+
86+
flags.each { |flag| append_ldflags(flag) }
7887
end
7988
end
8089

@@ -140,6 +149,10 @@ def abort_could_not_find(missing)
140149
abort("\nCould not find #{missing}.\nPlease visit https://github.com/sparklemotion/sqlite3-ruby for installation instructions.\n\n")
141150
end
142151

152+
def abort_pkg_config(id)
153+
abort("\nCould not configure the build properly (#{id}). Please install either the `pkg-config` utility or the `pkg-config` rubygem.\n\n")
154+
end
155+
143156
def cross_build?
144157
enable_config("cross-build")
145158
end

0 commit comments

Comments
 (0)