diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-08-02 22:09:08 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-08-02 22:09:08 +0000 |
commit | 85925e85f4a11ab5d9348237680df8083652ad99 (patch) | |
tree | 55e33336a252078a2aed3fc8f77baac162350885 | |
parent | b0ad488a8125bdf3ff4df9e98b6dfcbad31739a2 (diff) | |
download | ruby-85925e85f4a11ab5d9348237680df8083652ad99.tar.gz ruby-85925e85f4a11ab5d9348237680df8083652ad99.tar.xz ruby-85925e85f4a11ab5d9348237680df8083652ad99.zip |
* lib/mkmf.rb (find_type): new method.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@12868 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | lib/mkmf.rb | 47 |
2 files changed, 38 insertions, 13 deletions
@@ -1,9 +1,11 @@ -Fri Aug 3 06:40:04 2007 Nobuyoshi Nakada <nobu@ruby-lang.org> +Fri Aug 3 07:09:05 2007 Nobuyoshi Nakada <nobu@ruby-lang.org> * lib/mkmf.rb: more verbose message. [ruby-Bugs-12766] * lib/mkmf.rb (have_type): suppress a warning with -Wall. + * lib/mkmf.rb (find_type): new method. + Fri Aug 3 00:00:20 2007 Nobuyoshi Nakada <nobu@ruby-lang.org> * bignum.c (big2str_table): base cannot be 0 or 1. diff --git a/lib/mkmf.rb b/lib/mkmf.rb index fbc0f5661..c2502d7d0 100644 --- a/lib/mkmf.rb +++ b/lib/mkmf.rb @@ -772,6 +772,21 @@ SRC end end +def try_type(type, headers = nil, opt = "", &b) + if try_compile(<<"SRC", opt, &b) +#{COMMON_HEADERS} +#{cpp_include(headers)} +/*top*/ +typedef #{type} conftest_type; +int conftestval[sizeof(conftest_type)?1:-1]; +SRC + $defs.push(format("-DHAVE_TYPE_%s", type.strip.upcase.tr_s("^A-Z0-9_", "_"))) + true + else + false + end +end + # Returns whether or not the static type +type+ is defined. You may # optionally pass additional +headers+ to check against in addition to the # common header files. @@ -787,18 +802,26 @@ end # def have_type(type, headers = nil, opt = "", &b) checking_for checking_message(type, headers, opt) do - headers = cpp_include(headers) - if try_compile(<<"SRC", opt, &b) -#{COMMON_HEADERS} -#{headers} -/*top*/ -typedef #{type} conftest_type; -int conftestval[sizeof(conftest_type)?1:-1]; -SRC - $defs.push(format("-DHAVE_TYPE_%s", type.strip.upcase.tr_s("^A-Z0-9_", "_"))) - true - else - false + try_type(type, headers, opt, &b) + end +end + +# Returns where the static type +type+ is defined. +# +# You may also pass additional flags to +opt+ which are then passed along to +# the compiler. +# +# See also +have_type+. +# +def find_type(type, opt, *headers, &b) + opt ||= "" + fmt = "not found" + def fmt.%(x) + x ? x.respond_to?(:join) ? x.join(",") : x : self + end + checking_for checking_message(type, nil, opt), fmt do + headers.find do |h| + try_type(type, h, opt, &b) end end end |