Skip to content

Commit

Permalink
Merge pull request #355 from sparklemotion/354-work-around-fedora-pkg…
Browse files Browse the repository at this point in the history
…conf-library-path

Work around Fedora pkgconf issue
  • Loading branch information
flavorjones authored Oct 11, 2022
2 parents 5c443e2 + c0b1bae commit 5ec7855
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 8 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/sqlite3-ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,21 @@ jobs:
- run: bundle exec rake compile -- --enable-system-libraries
- run: bundle exec rake test

# reported at https://github.com/sparklemotion/sqlite3-ruby/issues/354
# TODO remove once https://github.com/flavorjones/mini_portile/issues/118 is fixed
fedora:
runs-on: ubuntu-latest
container:
image: fedora:35
steps:
- run: |
dnf group install -y "C Development Tools and Libraries"
dnf install -y ruby ruby-devel
- uses: actions/checkout@v3
- run: bundle install
- run: bundle exec rake compile -- --disable-system-libraries
- run: bundle exec rake test

sqlcipher:
strategy:
fail-fast: false
Expand Down
29 changes: 21 additions & 8 deletions ext/sqlite3/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,24 @@ def configure_packaged_libraries
end
recipe.activate

ENV["PKG_CONFIG_ALLOW_SYSTEM_CFLAGS"] = "t" # on macos, pkg-config will not return --cflags without this
pcfile = File.join(recipe.path, "lib", "pkgconfig", "sqlite3.pc")
if pkg_config(pcfile)
# see https://bugs.ruby-lang.org/issues/18490
libs = xpopen(["pkg-config", "--libs", "--static", pcfile], err: [:child, :out], &:read)
libs.split.each { |lib| append_ldflags(lib) } if $?.success?
else
abort("\nCould not configure the build properly. Please install either the `pkg-config` utility or the `pkg-config` rubygem.\n\n")
# on macos, pkg-config will not return --cflags without this
ENV["PKG_CONFIG_ALLOW_SYSTEM_CFLAGS"] = "t"

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
flags = xpopen(["pkg-config", "--libs", "--static", pcfile], err: [:child, :out], &:read)
abort_pkg_config("xpopen") unless $?.success?
flags = flags.split

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

flags.each { |flag| append_ldflags(flag) }
end
end

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

def abort_pkg_config(id)
abort("\nCould not configure the build properly (#{id}). Please install either the `pkg-config` utility or the `pkg-config` rubygem.\n\n")
end

def cross_build?
enable_config("cross-build")
end
Expand Down

0 comments on commit 5ec7855

Please sign in to comment.