ruby-changes:37482
From: nobu <ko1@a...>
Date: Wed, 11 Feb 2015 11:09:00 +0900 (JST)
Subject: [ruby-changes:37482] nobu:r49563 (trunk): digest: common configurations
nobu 2015-02-11 11:08:50 +0900 (Wed, 11 Feb 2015) New Revision: 49563 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=49563 Log: digest: common configurations * ext/digest/digest_conf.rb (digest_conf): extract common configurations. Added files: trunk/ext/digest/digest_conf.rb Modified files: trunk/ChangeLog trunk/ext/digest/md5/extconf.rb trunk/ext/digest/md5/md5init.c trunk/ext/digest/rmd160/extconf.rb trunk/ext/digest/rmd160/rmd160init.c trunk/ext/digest/sha1/extconf.rb trunk/ext/digest/sha1/sha1init.c trunk/ext/digest/sha2/extconf.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 49562) +++ ChangeLog (revision 49563) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Wed Feb 11 11:08:48 2015 Nobuyoshi Nakada <nobu@r...> + + * ext/digest/digest_conf.rb (digest_conf): extract common + configurations. + Wed Feb 11 11:01:33 2015 Nobuyoshi Nakada <nobu@r...> * ext/json/generator/generator.c (generate_json): get rid of Index: ext/digest/md5/extconf.rb =================================================================== --- ext/digest/md5/extconf.rb (revision 49562) +++ ext/digest/md5/extconf.rb (revision 49563) @@ -3,22 +3,14 @@ https://github.com/ruby/ruby/blob/trunk/ext/digest/md5/extconf.rb#L3 # $Id$ require "mkmf" +require File.expand_path("../../digest_conf", __FILE__) $defs << "-DHAVE_CONFIG_H" $INCFLAGS << " -I$(srcdir)/.." $objs = [ "md5init.#{$OBJEXT}" ] -if !with_config("bundled-md5") && - (dir_config("openssl") - pkg_config("openssl") - require File.expand_path('../../../openssl/deprecation', __FILE__) - have_library("crypto")) && - OpenSSL.check_func("MD5_Transform", "openssl/md5.h") - $objs << "md5ossl.#{$OBJEXT}" -else - $objs << "md5.#{$OBJEXT}" -end +digest_conf("md5") have_header("sys/cdefs.h") Index: ext/digest/md5/md5init.c =================================================================== --- ext/digest/md5/md5init.c (revision 49562) +++ ext/digest/md5/md5init.c (revision 49563) @@ -2,7 +2,7 @@ https://github.com/ruby/ruby/blob/trunk/ext/digest/md5/md5init.c#L2 /* $Id$ */ #include "digest.h" -#if defined(HAVE_OPENSSL_MD5_H) +#if defined(MD5_USE__OPENSSL) #include "md5ossl.h" #else #include "md5.h" Index: ext/digest/digest_conf.rb =================================================================== --- ext/digest/digest_conf.rb (revision 0) +++ ext/digest/digest_conf.rb (revision 49563) @@ -0,0 +1,20 @@ https://github.com/ruby/ruby/blob/trunk/ext/digest/digest_conf.rb#L1 +def digest_conf(name, hdr = name, funcs = nil) + unless with_config("bundled-#{name}") + dir_config("openssl") + pkg_config("openssl") + require File.expand_path('../../openssl/deprecation', __FILE__) + if have_library("crypto") + funcs ||= name.upcase + funcs = Array(funcs) + hdr = "openssl/#{hdr}.h" + if funcs.all? {|func| OpenSSL.check_func("#{func}_Transform", hdr)} && + funcs.all? {|func| have_type("#{func}_CTX", hdr)} + $defs << "-D#{name.upcase}_USE_OPENSSL" + $objs << "#{name}ossl.#{$OBJEXT}" + return :ossl + end + end + end + $objs << "#{name}.#{$OBJEXT}" + return +end Property changes on: ext/digest/digest_conf.rb ___________________________________________________________________ Added: svn:eol-style + LF Index: ext/digest/rmd160/extconf.rb =================================================================== --- ext/digest/rmd160/extconf.rb (revision 49562) +++ ext/digest/rmd160/extconf.rb (revision 49563) @@ -3,22 +3,14 @@ https://github.com/ruby/ruby/blob/trunk/ext/digest/rmd160/extconf.rb#L3 # $Id$ require "mkmf" +require File.expand_path("../../digest_conf", __FILE__) $defs << "-DNDEBUG" << "-DHAVE_CONFIG_H" $INCFLAGS << " -I$(srcdir)/.." $objs = [ "rmd160init.#{$OBJEXT}" ] -if !with_config("bundled-rmd160") && - (dir_config("openssl") - pkg_config("openssl") - require File.expand_path('../../../openssl/deprecation', __FILE__) - have_library("crypto")) && - OpenSSL.check_func("RIPEMD160_Transform", "openssl/ripemd.h") - $objs << "rmd160ossl.#{$OBJEXT}" -else - $objs << "rmd160.#{$OBJEXT}" -end +digest_conf("rmd160", "ripemd", "RIPEMD160") have_header("sys/cdefs.h") Index: ext/digest/rmd160/rmd160init.c =================================================================== --- ext/digest/rmd160/rmd160init.c (revision 49562) +++ ext/digest/rmd160/rmd160init.c (revision 49563) @@ -2,7 +2,7 @@ https://github.com/ruby/ruby/blob/trunk/ext/digest/rmd160/rmd160init.c#L2 /* $Id$ */ #include "digest.h" -#if defined(HAVE_OPENSSL_RIPEMD_H) +#if defined(RMD160_USE_OPENSSL) #include "rmd160ossl.h" #else #include "rmd160.h" Index: ext/digest/sha1/sha1init.c =================================================================== --- ext/digest/sha1/sha1init.c (revision 49562) +++ ext/digest/sha1/sha1init.c (revision 49563) @@ -2,7 +2,7 @@ https://github.com/ruby/ruby/blob/trunk/ext/digest/sha1/sha1init.c#L2 /* $Id$ */ #include "digest.h" -#if defined(HAVE_OPENSSL_SHA_H) +#if defined(SHA1_USE_OPENSSL) #include "sha1ossl.h" #else #include "sha1.h" Index: ext/digest/sha1/extconf.rb =================================================================== --- ext/digest/sha1/extconf.rb (revision 49562) +++ ext/digest/sha1/extconf.rb (revision 49563) @@ -3,22 +3,14 @@ https://github.com/ruby/ruby/blob/trunk/ext/digest/sha1/extconf.rb#L3 # $Id$ require "mkmf" +require File.expand_path("../../digest_conf", __FILE__) $defs << "-DHAVE_CONFIG_H" $INCFLAGS << " -I$(srcdir)/.." $objs = [ "sha1init.#{$OBJEXT}" ] -if !with_config("bundled-sha1") && - (dir_config("openssl") - pkg_config("openssl") - require File.expand_path('../../../openssl/deprecation', __FILE__) - have_library("crypto")) && - OpenSSL.check_func("SHA1_Transform", "openssl/sha.h") - $objs << "sha1ossl.#{$OBJEXT}" -else - $objs << "sha1.#{$OBJEXT}" -end +digest_conf("sha1", "sha") have_header("sys/cdefs.h") Index: ext/digest/sha2/extconf.rb =================================================================== --- ext/digest/sha2/extconf.rb (revision 49562) +++ ext/digest/sha2/extconf.rb (revision 49563) @@ -3,24 +3,15 @@ https://github.com/ruby/ruby/blob/trunk/ext/digest/sha2/extconf.rb#L3 # $Id$ require "mkmf" +require File.expand_path("../../digest_conf", __FILE__) $defs << "-DHAVE_CONFIG_H" $INCFLAGS << " -I$(srcdir)/.." $objs = [ "sha2init.#{$OBJEXT}" ] -if !with_config("bundled-sha2") && - (dir_config("openssl") - pkg_config("openssl") - require File.expand_path('../../../openssl/deprecation', __FILE__) - have_library("crypto")) && - %w[SHA256 SHA512].all? {|d| OpenSSL.check_func("#{d}_Transform", "openssl/sha.h")} && - %w[SHA256 SHA512].all? {|d| have_type("#{d}_CTX", "openssl/sha.h")} - $objs << "sha2ossl.#{$OBJEXT}" - $defs << "-DSHA2_USE_OPENSSL" -else +unless digest_conf("sha2", "sha", %w[SHA256 SHA512]) have_type("u_int8_t") - $objs << "sha2.#{$OBJEXT}" end have_header("sys/cdefs.h") -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/