Class: HiredisConnectionExtconf
- Inherits:
-
Object
- Object
- HiredisConnectionExtconf
- Defined in:
- ext/redis_client/hiredis/extconf.rb
Instance Method Summary collapse
- #build_hiredis ⇒ Object
- #configure ⇒ Object
- #configure_extension ⇒ Object
- #configure_openssl(original_env) ⇒ Object
-
#initialize(debug) ⇒ HiredisConnectionExtconf
constructor
A new instance of HiredisConnectionExtconf.
Constructor Details
#initialize(debug) ⇒ HiredisConnectionExtconf
Returns a new instance of HiredisConnectionExtconf.
6 7 8 |
# File 'ext/redis_client/hiredis/extconf.rb', line 6 def initialize(debug) @debug = debug end |
Instance Method Details
#build_hiredis ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'ext/redis_client/hiredis/extconf.rb', line 39 def build_hiredis env = { "USE_SSL" => 1, "CFLAGS" => concat_flags(ENV["CFLAGS"], "-fvisibility=hidden"), } env["OPTIMIZATION"] = "-g" if @debug env = configure_openssl(env) env_args = env.map { |k, v| "#{k}=#{v}" } Dir.chdir(hiredis_dir) do unless system(*Shellwords.split(make_program), "static", *env_args) raise "Building hiredis failed" end end $LDFLAGS = concat_flags($LDFLAGS, "-lssl", "-lcrypto") $libs = concat_flags($libs, "#{hiredis_dir}/libhiredis.a", "#{hiredis_dir}/libhiredis_ssl.a") end |
#configure ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'ext/redis_client/hiredis/extconf.rb', line 10 def configure if RUBY_ENGINE == "ruby" && !Gem.win_platform? configure_extension create_makefile("redis_client/hiredis_connection") else File.write("Makefile", dummy_makefile($srcdir).join) end end |
#configure_extension ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'ext/redis_client/hiredis/extconf.rb', line 19 def configure_extension build_hiredis have_func("rb_hash_new_capa", "ruby.h") $CFLAGS = concat_flags($CFLAGS, "-I#{hiredis_dir}", "-std=c99", "-fvisibility=hidden") $CFLAGS = if @debug concat_flags($CFLAGS, "-Werror", "-g", RbConfig::CONFIG["debugflags"]) else concat_flags($CFLAGS, "-O3") end if @debug $CPPFLAGS = concat_flags($CPPFLAGS, "-DRUBY_DEBUG=1") end append_cflags("-Wno-declaration-after-statement") # Older compilers append_cflags("-Wno-compound-token-split-by-macro") # Older rubies on macos end |
#configure_openssl(original_env) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'ext/redis_client/hiredis/extconf.rb', line 59 def configure_openssl(original_env) original_env.dup.tap do |env| config = dir_config("openssl") if config.none? config = dir_config("opt").map { |c| detect_openssl_dir(c) } end unless have_header("openssl/ssl.h") = "ERROR: OpenSSL library could not be found." if config.none? += "\nUse --with-openssl-dir=<dir> option to specify the prefix where OpenSSL is installed." end abort end if config.any? env["CFLAGS"] = concat_flags(env["CFLAGS"], "-I#{config.first}") env["SSL_LDFLAGS"] = "-L#{config.last}" end end end |