From 321df4ecf2c2ac08c2f67bf76c8d94b3a1660650 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Mon, 10 Oct 2022 19:16:39 -0400 Subject: [PATCH 1/2] ci: reproduce fedora pkgconf issue --- .github/workflows/sqlite3-ruby.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.github/workflows/sqlite3-ruby.yml b/.github/workflows/sqlite3-ruby.yml index c2495f5a..2e1edbc5 100644 --- a/.github/workflows/sqlite3-ruby.yml +++ b/.github/workflows/sqlite3-ruby.yml @@ -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 From c0b1bae9c3734969629ba99dfb694745259a8033 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Mon, 10 Oct 2022 19:21:41 -0400 Subject: [PATCH 2/2] ext: work around fedora pkgconf issue Closes #354 --- ext/sqlite3/extconf.rb | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/ext/sqlite3/extconf.rb b/ext/sqlite3/extconf.rb index 9a9a7caf..a47849fe 100644 --- a/ext/sqlite3/extconf.rb +++ b/ext/sqlite3/extconf.rb @@ -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 @@ -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