Skip to content

Commit

Permalink
Merge pull request #381 from voxik/optional_miniportile
Browse files Browse the repository at this point in the history
Load 'mini_portile2' only when needed.
  • Loading branch information
flavorjones committed Mar 2, 2023
2 parents 1b469ed + ff5f574 commit 013f90f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
26 changes: 20 additions & 6 deletions bin/test-gem-set
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,33 @@ set -o pipefail
gems=$*
gem_platform_local=`ruby -e "puts Gem::Platform.local.to_s"`

function remove_all_sqlite3s {
yes | gem uninstall --force sqlite3 || true
function remove_all {
gem uninstall --all --force $1
}

function test_installation {
gem=$1
remove_all_sqlite3s
gem install --local $gem

# test installation
remove_all sqlite3
gem install $gem
ruby -r sqlite3 -e 'pp SQLite3::SQLITE_VERSION, SQLite3::SQLITE_LOADED_VERSION'

if [[ $gem =~ sqlite3-[^-]*\.gem ]] ; then
remove_all_sqlite3s
gem install --local $gem -- --enable-system-libraries
# test installation against system libs without mini_portile, linux distro repackagers
# (note that we don't care about running the gem in this case, just building it)
# see https://github.com/sparklemotion/sqlite3-ruby/pull/381 for background
remove_all sqlite3
remove_all mini_portile2
gem install --local --force $gem -- --enable-system-libraries
if gem list -i mini_portile2 ; then
echo "FAIL: should not have installed mini_portile2"
exit 1
fi

# test installation against system libs
remove_all sqlite3
gem install $gem -- --enable-system-libraries
ruby -r sqlite3 -e 'pp SQLite3::SQLITE_VERSION, SQLite3::SQLITE_LOADED_VERSION'
fi
}
Expand Down
3 changes: 2 additions & 1 deletion ext/sqlite3/extconf.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require "mkmf"
require "mini_portile2"
require "yaml"

module Sqlite3
Expand Down Expand Up @@ -131,6 +130,8 @@ def configure_extension
end

def minimal_recipe
require "mini_portile2"

MiniPortile.new(libname, sqlite3_config[:version]).tap do |recipe|
if sqlite_source_dir
recipe.source_directory = sqlite_source_dir
Expand Down

0 comments on commit 013f90f

Please sign in to comment.