ruby-changes:4235
From: ko1@a...
Date: Fri, 7 Mar 2008 19:56:38 +0900 (JST)
Subject: [ruby-changes:4235] nobu - Ruby:r15725 (ruby_1_8, trunk): * lib/mkmf.rb: rdoc added. [ruby-Patches-9762]
nobu 2008-03-07 19:56:13 +0900 (Fri, 07 Mar 2008)
New Revision: 15725
Modified files:
branches/ruby_1_8/ChangeLog
branches/ruby_1_8/lib/mkmf.rb
branches/ruby_1_8/version.h
trunk/ChangeLog
trunk/lib/mkmf.rb
Log:
* lib/mkmf.rb: rdoc added. [ruby-Patches-9762]
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8/lib/mkmf.rb?r1=15725&r2=15724&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8/ChangeLog?r1=15725&r2=15724&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=15725&r2=15724&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/mkmf.rb?r1=15725&r2=15724&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8/version.h?r1=15725&r2=15724&diff_format=u
Index: ChangeLog
===================================================================
--- ChangeLog (revision 15724)
+++ ChangeLog (revision 15725)
@@ -1,3 +1,7 @@
+Fri Mar 7 19:56:10 2008 Nobuyoshi Nakada <nobu@r...>
+
+ * lib/mkmf.rb: rdoc added. [ruby-Patches-9762]
+
Thu Mar 6 17:26:53 2008 Nobuyoshi Nakada <nobu@r...>
* sprintf.c (rb_str_format): space flag is in effect for Inf/NaN too.
Index: lib/mkmf.rb
===================================================================
--- lib/mkmf.rb (revision 15724)
+++ lib/mkmf.rb (revision 15725)
@@ -66,6 +66,8 @@
$solaris = /solaris/ =~ RUBY_PLATFORM
$dest_prefix_pattern = (File::PATH_SEPARATOR == ';' ? /\A([[:alpha:]]:)?/ : /\A/)
+# :stopdoc:
+
def config_string(key, config = CONFIG)
s = config[key] and !s.empty? and block_given? ? yield(s) : s
end
@@ -171,14 +173,18 @@
CONFTEST_C = "conftest.c".freeze
class String
+ # Wraps a string in escaped quotes if it contains whitespace.
def quote
/\s/ =~ self ? "\"#{self}\"" : "#{self}"
end
+
+ # Generates a string used as cpp macro name.
def tr_cpp
strip.upcase.tr_s("^A-Z0-9_", "_")
end
end
class Array
+ # Wraps all strings in escaped quotes if they contain whitespace.
def quote
map {|s| s.quote}
end
@@ -188,6 +194,8 @@
FileUtils.rm_f(Dir[*files])
end
+# Returns time stamp of the +target+ file if it exists and is newer
+# than or equal to all of +times+.
def modified?(target, times)
(t = File.mtime(target)) rescue return nil
Array === times or times = [times]
@@ -210,6 +218,12 @@
end
end
+# This is a custom logging module. It generates an mkmf.log file when you
+# run your extconf.rb script. This can be useful for debugging unexpected
+# failures.
+#
+# This module and its associated methods are meant for internal use only.
+#
module Logging
@log = nil
@logfile = 'mkmf.log'
@@ -538,6 +552,7 @@
log_src(src)
end
+# This is used internally by the have_macro? method.
def macro_defined?(macro, src, opt = "", &b)
src = src.sub(/[^\n]\z/, "\\&\n")
try_compile(src + <<"SRC", opt, &b)
@@ -606,7 +621,7 @@
install_files(mfile, [["lib/**/*.rb", dest, "lib"]], nil, srcdir)
end
-def append_library(libs, lib)
+def append_library(libs, lib) # :no-doc:
format(LIBARG, lib) + " " + libs
end
@@ -617,6 +632,11 @@
end
end
+# This emits a string to stdout that allows users to see the results of the
+# various have* and find* methods as they are tested.
+#
+# Internal use only.
+#
def checking_for(m, fmt = nil)
f = caller[0][/in `(.*)'$/, 1] and f << ": " #` for vim #'
m = "checking #{/\Acheck/ =~ f ? '' : 'for '}#{m}... "
@@ -646,6 +666,8 @@
end
end
+# :startdoc:
+
# Returns whether or not +macro+ is defined either in the common header
# files or within any +headers+ you provide.
#
@@ -665,7 +687,7 @@
# If +headers+ are provided, it will include those header files as the
# header files it looks in when searching for +func+.
#
-# Real name of the library to be linked can be altered by
+# The real name of the library to be linked can be altered by
# '--with-FOOlib' configuration option.
#
def have_library(lib, func = nil, headers = nil, &b)
@@ -945,6 +967,10 @@
end
end
+# :stopdoc:
+
+# Used internally by the what_type? method to determine if +type+ is a scalar
+# pointer.
def scalar_ptr_type?(type, member = nil, headers = nil, &b)
try_compile(<<"SRC", &b) # pointer
#{COMMON_HEADERS}
@@ -956,6 +982,8 @@
SRC
end
+# Used internally by the what_type? method to determine if +type+ is a scalar
+# pointer.
def scalar_type?(type, member = nil, headers = nil, &b)
try_compile(<<"SRC", &b) # pointer
#{COMMON_HEADERS}
@@ -999,6 +1027,10 @@
end
end
+# This method is used internally by the find_executable method.
+#
+# Internal use only.
+#
def find_executable0(bin, path = nil)
ext = config_string('EXEEXT')
if File.expand_path(bin) == bin
@@ -1019,12 +1051,25 @@
nil
end
+# :startdoc:
+
+# Searches for the executable +bin+ on +path+. The default path is your
+# PATH environment variable. If that isn't defined, it will resort to
+# searching /usr/local/bin, /usr/ucb, /usr/bin and /bin.
+#
+# If found, it will return the full path, including the executable name,
+# of where it was found.
+#
+# Note that this method does not actually affect the generated Makefile.
+#
def find_executable(bin, path = nil)
checking_for checking_message(bin, path) do
find_executable0(bin, path)
end
end
+# :stopdoc:
+
def arg_config(config, default=nil, &block)
$arg_config << [config, default]
defaults = []
@@ -1036,6 +1081,20 @@
$configure_args.fetch(config.tr('_', '-'), *defaults, &block)
end
+# :startdoc:
+
+# Tests for the presence of a --with-<tt>config</tt> or --without-<tt>config</tt>
+# option. Returns true if the with option is given, false if the without
+# option is given, and the default value otherwise.
+#
+# This can be useful for adding custom definitions, such as debug information.
+#
+# Example:
+#
+# if with_config("debug")
+# $defs.push("-DOSSL_DEBUG") unless $defs.include? "-DOSSL_DEBUG"
+# end
+#
def with_config(config, default=nil)
config = config.sub(/^--with[-_]/, '')
val = arg_config("--with-"+config) do
@@ -1057,6 +1116,18 @@
end
end
+# Tests for the presence of an --enable-<tt>config</tt> or
+# --disable-<tt>config</tt> option. Returns true if the enable option is given,
+# false if the disable option is given, and the default value otherwise.
+#
+# This can be useful for adding custom definitions, such as debug information.
+#
+# Example:
+#
+# if enable_config("debug")
+# $defs.push("-DOSSL_DEBUG") unless $defs.include? "-DOSSL_DEBUG"
+# end
+#
def enable_config(config, default=nil)
if arg_config("--enable-"+config)
true
@@ -1069,6 +1140,32 @@
end
end
+# Generates a header file consisting of the various macro definitions generated
+# by other methods such as have_func and have_header. These are then wrapped in
+# a custom #ifndef based on the +header+ file name, which defaults to
+# 'extconf.h'.
+#
+# For example:
+#
+# # extconf.rb
+# require 'mkmf'
+# have_func('realpath')
+# have_header('sys/utime.h')
+# create_header
+# create_makefile('foo')
+#
+# The above script would generate the following extconf.h file:
+#
+# #ifndef EXTCONF_H
+# #define EXTCONF_H
+# #define HAVE_REALPATH 1
+# #define HAVE_SYS_UTIME_H 1
+# #endif
+#
+# Given that the create_header method generates a file based on definitions
+# set earlier in your extconf.rb file, you will probably want to make this
+# one of the last methods you call in your script.
+#
def create_header(header = "extconf.h")
message "creating %s\n", header
sym = header.tr("a-z./\055", "A-Z___")
@@ -1136,6 +1233,10 @@
[idir, ldir]
end
+# :stopdoc:
+
+# Handles meta information about installed libraries. Uses your platform's
+# pkg-config program if it has one.
def pkg_config(pkg)
if pkgconfig = with_config("#{pkg}-config") and find_executable0(pkgconfig)
# iff package specific config command is given
@@ -1173,6 +1274,10 @@
/\A\$[\(\{]/ =~ dir ? dir : "$(DESTDIR)"+dir
end
+# Converts forward slashes to backslashes. Aimed at MS Windows.
+#
+# Internal use only.
+#
def winsep(s)
s.tr('/', '\\')
end
@@ -1283,6 +1388,7 @@
end
mk
end
+# :startdoc:
def dummy_makefile(srcdir)
configuration(srcdir) << <<RULES << CLEANINGS
@@ -1398,6 +1504,10 @@
# instead of copying files around manually, because some third party
# libraries may depend on the +target_prefix+ being set properly.
#
+# The +srcprefix+ argument can be used to override the default source
+# directory, i.e. the current directory . It is included as part of the VPATH
+# and added to the list of INCFLAGS.
+#
def create_makefile(target, srcprefix = nil)
$target = target
libpath = $DEFLIBPATH|$LIBPATH
@@ -1629,6 +1739,8 @@
mfile.close if mfile
end
+# :stopdoc:
+
def init_mkmf(config = CONFIG)
$makefile_created = false
$arg_config = []
@@ -1682,6 +1794,11 @@
Provided configuration options:
MESSAGE
+# Returns whether or not the Makefile was successfully generated. If not,
+# the script will abort with an error message.
+#
+# Internal use only.
+#
def mkmf_failed(path)
unless $makefile_created or File.exist?("Makefile")
opts = $arg_config.collect {|t, n| "\t#{t}#{n ? "=#{n}" : ""}\n"}
@@ -1689,6 +1806,8 @@
end
end
+# :startdoc:
+
init_mkmf
$make = with_config("make-prog", ENV["MAKE"] || "make")
Index: ruby_1_8/ChangeLog
===================================================================
--- ruby_1_8/ChangeLog (revision 15724)
+++ ruby_1_8/ChangeLog (revision 15725)
@@ -1,3 +1,7 @@
+Fri Mar 7 19:56:10 2008 Nobuyoshi Nakada <nobu@r...>
+
+ * lib/mkmf.rb: rdoc added. [ruby-Patches-9762]
+
Thu Mar 6 15:10:21 2008 NAKAMURA Usaku <usa@r...>
* {bcc32,win32}/Makefile.sub (RUNRUBY): use $(PROGRAM) instead of
Index: ruby_1_8/version.h
===================================================================
--- ruby_1_8/version.h (revision 15724)
+++ ruby_1_8/version.h (revision 15725)
@@ -1,7 +1,7 @@
#define RUBY_VERSION "1.8.6"
-#define RUBY_RELEASE_DATE "2008-03-06"
+#define RUBY_RELEASE_DATE "2008-03-07"
#define RUBY_VERSION_CODE 186
-#define RUBY_RELEASE_CODE 20080306
+#define RUBY_RELEASE_CODE 20080307
#define RUBY_PATCHLEVEL 5000
#define RUBY_VERSION_MAJOR 1
@@ -9,7 +9,7 @@
#define RUBY_VERSION_TEENY 6
#define RUBY_RELEASE_YEAR 2008
#define RUBY_RELEASE_MONTH 3
-#define RUBY_RELEASE_DAY 6
+#define RUBY_RELEASE_DAY 7
#ifdef RUBY_EXTERN
RUBY_EXTERN const char ruby_version[];
Index: ruby_1_8/lib/mkmf.rb
===================================================================
--- ruby_1_8/lib/mkmf.rb (revision 15724)
+++ ruby_1_8/lib/mkmf.rb (revision 15725)
@@ -63,6 +63,8 @@
$solaris = /solaris/ =~ RUBY_PLATFORM
$dest_prefix_pattern = (File::PATH_SEPARATOR == ';' ? /\A([[:alpha:]]:)?/ : /\A/)
+# :stopdoc:
+
def config_string(key, config = CONFIG)
s = config[key] and !s.empty? and block_given? ? yield(s) : s
end
@@ -132,14 +134,18 @@
CONFTEST_C = "conftest.c"
class String
+ # Wraps a string in escaped quotes if it contains whitespace.
def quote
- /\s/ =~ self ? "\"#{self}\"" : self
+ /\s/ =~ self ? "\"#{self}\"" : "#{self}"
end
+
+ # Generates a string used as cpp macro name.
def tr_cpp
strip.upcase.tr_s("^A-Z0-9_", "_")
end
end
class Array
+ # Wraps all strings in escaped quotes if they contain whitespace.
def quote
map {|s| s.quote}
end
@@ -149,6 +155,8 @@
FileUtils.rm_f(Dir[files.join("\0")])
end
+# Returns time stamp of the +target+ file if it exists and is newer
+# than or equal to all of +times+.
def modified?(target, times)
(t = File.mtime(target)) rescue return nil
Array === times or times = [times]
@@ -171,6 +179,12 @@
end
end
+# This is a custom logging module. It generates an mkmf.log file when you
+# run your extconf.rb script. This can be useful for debugging unexpected
+# failures.
+#
+# This module and its associated methods are meant for internal use only.
+#
module Logging
@log = nil
@logfile = 'mkmf.log'
@@ -485,6 +499,7 @@
log_src(src)
end
+# This is used internally by the have_macro? method.
def macro_defined?(macro, src, opt = "", &b)
src = src.sub(/[^\n]\z/, "\\&\n")
try_compile(src + <<"SRC", opt, &b)
@@ -552,7 +567,7 @@
install_files(mfile, [["lib/**/*.rb", dest, "lib"]], nil, srcdir)
end
-def append_library(libs, lib)
+def append_library(libs, lib) # :no-doc:
format(LIBARG, lib) + " " + libs
end
@@ -563,6 +578,11 @@
end
end
+# This emits a string to stdout that allows users to see the results of the
+# various have* and find* methods as they are tested.
+#
+# Internal use only.
+#
def checking_for(m, fmt = nil)
f = caller[0][/in `(.*)'$/, 1] and f << ": " #` for vim
m = "checking #{/\Acheck/ =~ f ? '' : 'for '}#{m}... "
@@ -592,6 +612,8 @@
end
end
+# :startdoc:
+
# Returns whether or not +macro+ is defined either in the common header
# files or within any +headers+ you provide.
#
@@ -611,7 +633,7 @@
# If +headers+ are provided, it will include those header files as the
# header files it looks in when searching for +func+.
#
-# Real name of the library to be linked can be altered by
+# The real name of the library to be linked can be altered by
# '--with-FOOlib' configuration option.
#
def have_library(lib, func = nil, headers = nil, &b)
@@ -752,7 +774,7 @@
# If found, a macro is passed as a preprocessor constant to the compiler using
# the member name, in uppercase, prepended with 'HAVE_ST_'.
#
-# For example, if have_struct_member('foo', 'bar') returned true, then the
+# For example, if have_struct_member('struct foo', 'bar') returned true, then the
# HAVE_ST_BAR preprocessor macro would be passed to the compiler.
#
def have_struct_member(type, member, headers = nil, &b)
@@ -888,6 +910,10 @@
end
end
+# :stopdoc:
+
+# Used internally by the what_type? method to determine if +type+ is a scalar
+# pointer.
def scalar_ptr_type?(type, member = nil, headers = nil, &b)
try_compile(<<"SRC", &b) # pointer
#{COMMON_HEADERS}
@@ -899,6 +925,8 @@
SRC
end
+# Used internally by the what_type? method to determine if +type+ is a scalar
+# pointer.
def scalar_type?(type, member = nil, headers = nil, &b)
try_compile(<<"SRC", &b) # pointer
#{COMMON_HEADERS}
@@ -942,6 +970,10 @@
end
end
+# This method is used internally by the find_executable method.
+#
+# Internal use only.
+#
def find_executable0(bin, path = nil)
ext = config_string('EXEEXT')
if File.expand_path(bin) == bin
@@ -962,18 +994,45 @@
nil
end
+# :startdoc:
+
+# Searches for the executable +bin+ on +path+. The default path is your
+# PATH environment variable. If that isn't defined, it will resort to
+# searching /usr/local/bin, /usr/ucb, /usr/bin and /bin.
+#
+# If found, it will return the full path, including the executable name,
+# of where it was found.
+#
+# Note that this method does not actually affect the generated Makefile.
+#
def find_executable(bin, path = nil)
checking_for checking_message(bin, path) do
find_executable0(bin, path)
end
end
+# :stopdoc:
+
def arg_config(config, *defaults, &block)
$arg_config << [config, *defaults]
defaults << nil if !block and defaults.empty?
$configure_args.fetch(config.tr('_', '-'), *defaults, &block)
end
+# :startdoc:
+
+# Tests for the presence of a --with-<tt>config</tt> or --without-<tt>config</tt>
+# option. Returns true if the with option is given, false if the without
+# option is given, and the default value otherwise.
+#
+# This can be useful for adding custom definitions, such as debug information.
+#
+# Example:
+#
+# if with_config("debug")
+# $defs.push("-DOSSL_DEBUG") unless $defs.include? "-DOSSL_DEBUG"
+# end
+#
def with_config(config, *defaults)
config = config.sub(/^--with[-_]/, '')
val = arg_config("--with-"+config) do
@@ -995,6 +1054,18 @@
end
end
+# Tests for the presence of an --enable-<tt>config</tt> or
+# --disable-<tt>config</tt> option. Returns true if the enable option is given,
+# false if the disable option is given, and the default value otherwise.
+#
+# This can be useful for adding custom definitions, such as debug information.
+#
+# Example:
+#
+# if enable_config("debug")
+# $defs.push("-DOSSL_DEBUG") unless $defs.include? "-DOSSL_DEBUG"
+# end
+#
def enable_config(config, *defaults)
if arg_config("--enable-"+config)
true
@@ -1007,6 +1078,32 @@
end
end
+# Generates a header file consisting of the various macro definitions generated
+# by other methods such as have_func and have_header. These are then wrapped in
+# a custom #ifndef based on the +header+ file name, which defaults to
+# 'extconf.h'.
+#
+# For example:
+#
+# # extconf.rb
+# require 'mkmf'
+# have_func('realpath')
+# have_header('sys/utime.h')
+# create_header
+# create_makefile('foo')
+#
+# The above script would generate the following extconf.h file:
+#
+# #ifndef EXTCONF_H
+# #define EXTCONF_H
+# #define HAVE_REALPATH 1
+# #define HAVE_SYS_UTIME_H 1
+# #endif
+#
+# Given that the create_header method generates a file based on definitions
+# set earlier in your extconf.rb file, you will probably want to make this
+# one of the last methods you call in your script.
+#
def create_header(header = "extconf.h")
message "creating %s\n", header
sym = header.tr("a-z./\055", "A-Z___")
@@ -1074,6 +1171,10 @@
[idir, ldir]
end
+# :stopdoc:
+
+# Handles meta information about installed libraries. Uses your platform's
+# pkg-config program if it has one.
def pkg_config(pkg)
if pkgconfig = with_config("#{pkg}-config") and find_executable0(pkgconfig)
# iff package specific config command is given
@@ -1111,6 +1212,10 @@
/\A\$[\(\{]/ =~ dir ? dir : "$(DESTDIR)"+dir
end
+# Converts forward slashes to backslashes. Aimed at MS Windows.
+#
+# Internal use only.
+#
def winsep(s)
s.tr('/', '\\')
end
@@ -1224,6 +1329,7 @@
RULES
end
+# :startdoc:
# Generates the Makefile for your extension, passing along any options and
# preprocessor constants that you may have generated through other methods.
@@ -1273,6 +1379,10 @@
# instead of copying files around manually, because some third party
# libraries may depend on the +target_prefix+ being set properly.
#
+# The +srcprefix+ argument can be used to override the default source
+# directory, i.e. the current directory . It is included as part of the VPATH
+# and added to the list of INCFLAGS.
+#
def create_makefile(target, srcprefix = nil)
$target = target
libpath = $DEFLIBPATH|$LIBPATH
@@ -1542,6 +1652,8 @@
mfile.close if mfile
end
+# :stopdoc:
+
def init_mkmf(config = CONFIG)
$makefile_created = false
$arg_config = []
@@ -1594,6 +1706,11 @@
Provided configuration options:
MESSAGE
+# Returns whether or not the Makefile was successfully generated. If not,
+# the script will abort with an error message.
+#
+# Internal use only.
+#
def mkmf_failed(path)
unless $makefile_created or File.exist?("Makefile")
opts = $arg_config.collect {|t, n| "\t#{t}#{n ? "=#{n}" : ""}\n"}
@@ -1601,6 +1718,8 @@
end
end
+# :startdoc:
+
init_mkmf
$make = with_config("make-prog", ENV["MAKE"] || "make")
--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/