Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work around Fedora pkgconf issue #355

Merged
merged 2 commits into from
Oct 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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