Skip to content

Commit

Permalink
Merge pull request #17 from redis-rb/extensions-conflict
Browse files Browse the repository at this point in the history
Fix conflict when both hiredis-rb and redis-client are loaded
  • Loading branch information
casperisfine authored Apr 28, 2022
2 parents 714ad60 + 799921b commit 353c105
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
2 changes: 2 additions & 0 deletions ext/redis_client/hiredis/export.clang
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
_Init_hiredis_connection
_ruby_abi_version
7 changes: 7 additions & 0 deletions ext/redis_client/hiredis/export.gcc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
hiredis_connection_1.0 {
global:
Init_hiredis_connection;
ruby_abi_version;
local:
*;
};
10 changes: 9 additions & 1 deletion ext/redis_client/hiredis/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,18 @@
end

$CFLAGS << " -I#{hiredis_dir}"
$LDFLAGS << " #{hiredis_dir}/libhiredis.a #{hiredis_dir}/libhiredis_ssl.a -lssl -lcrypto"
$LDFLAGS << " -lssl -lcrypto"
$libs << " #{hiredis_dir}/libhiredis.a #{hiredis_dir}/libhiredis_ssl.a "
$CFLAGS << " -O3"
$CFLAGS << " -std=c99 "

case RbConfig::CONFIG['CC']
when /gcc/i
$LDFLAGS << ' -Wl,--version-script="' << File.join(__dir__, 'export.gcc') << '"'
when /clang/i
$LDFLAGS << ' -Wl,-exported_symbols_list,"' << File.join(__dir__, 'export.clang') << '"'
end

if ENV["EXT_PEDANTIC"]
$CFLAGS << " -Werror"
end
Expand Down
9 changes: 9 additions & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,12 @@
unless ENV["REDIS_CLIENT_RESTART_SERVER"] == "0"
Minitest.after_run { Servers::ALL.shutdown }
end

if ENV["DRIVER"] == "hiredis"
# See: https://github.com/redis-rb/redis-client/issues/16
# The hiredis-rb gems expose all hiredis symbols, so we must be careful
# about how we link against it.
require "redis"
require "hiredis"
Redis.new(host: Servers::HOST, port: Servers::REDIS_TCP_PORT, driver: :hiredis).ping
end

0 comments on commit 353c105

Please sign in to comment.