1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/mkmf.rb: Wrap mkmf.rb in module MakeMakefile to clean up Object

documentation.  [Ruby 1.9 - Feature #5658]
* ext/extmk.rb:  Use MakeMakefile::CONFIG instead of Object::CONFIG
* test/mkmf/base.rb:  ditto


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33890 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
drbrain 2011-11-28 21:54:33 +00:00
parent 22702f9278
commit 194882cc40
4 changed files with 1858 additions and 1838 deletions

View file

@ -1,3 +1,10 @@
Tue Nov 29 05:54:18 2011 Eric Hodel <drbrain@segment7.net>
* lib/mkmf.rb: Wrap mkmf.rb in module MakeMakefile to clean up Object
documentation. [Ruby 1.9 - Feature #5658]
* ext/extmk.rb: Use MakeMakefile::CONFIG instead of Object::CONFIG
* test/mkmf/base.rb: ditto
Tue Nov 29 00:08:57 2011 Yuki Sonoda (Yugui) <yugui@yugui.jp>
* common.mk (INSTRUBY_ARGS): added --mantype to apply mdoc2man.rb

View file

@ -147,7 +147,7 @@ def extmake(target)
remove_const(:MAKEFILE_CONFIG)
const_set(:MAKEFILE_CONFIG, mkconfig)
}
Object.class_eval {
MakeMakefile.class_eval {
remove_const(:CONFIG)
const_set(:CONFIG, mkconfig)
}
@ -240,7 +240,7 @@ def extmake(target)
remove_const(:MAKEFILE_CONFIG)
const_set(:MAKEFILE_CONFIG, mkconfig0)
}
Object.class_eval {
MakeMakefile.class_eval {
remove_const(:CONFIG)
const_set(:CONFIG, mkconfig0)
}

View file

@ -6,6 +6,37 @@ require 'rbconfig'
require 'fileutils'
require 'shellwords'
# :stopdoc:
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_*", "_").tr_s("*", "P")
end
def funcall_style
/\)\z/ =~ self ? dup : "#{self}()"
end
def sans_arguments
self[/\A[^()]+/]
end
end
class Array
# Wraps all strings in escaped quotes if they contain whitespace.
def quote
map {|s| s.quote}
end
end
# :startdoc:
module MakeMakefile
CONFIG = RbConfig::MAKEFILE_CONFIG
ORIG_LIBPATH = ENV['LIB']
@ -75,10 +106,12 @@ $dest_prefix_pattern = (File::PATH_SEPARATOR == ';' ? /\A([[:alpha:]]:)?/ : /\A/
def config_string(key, config = CONFIG)
s = config[key] and !s.empty? and block_given? ? yield(s) : s
end
module_function :config_string
def dir_re(dir)
Regexp.new('\$(?:\('+dir+'\)|\{'+dir+'\})(?:\$(?:\(target_prefix\)|\{target_prefix\}))?')
end
module_function :dir_re
def relative_from(path, base)
dir = File.join(path, "")
@ -176,32 +209,6 @@ CPPOUTFILE = CONFIG['CPPOUTFILE']
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_*", "_").tr_s("*", "P")
end
def funcall_style
/\)\z/ =~ self ? dup : "#{self}()"
end
def sans_arguments
self[/\A[^()]+/]
end
end
class Array
# Wraps all strings in escaped quotes if they contain whitespace.
def quote
map {|s| s.quote}
end
end
def rm_f(*files)
opt = (Hash === files.last ? [files.pop] : [])
FileUtils.rm_f(Dir[*files.flatten], *opt)
@ -519,9 +526,7 @@ ensure
rm_f "conftest*"
end
class Object
alias_method :try_header, (config_string('try_header') || :try_cpp)
end
def cpp_include(header)
if header
@ -2249,6 +2254,7 @@ end
# :startdoc:
def make_makefile
init_mkmf
$make = with_config("make-prog", ENV["MAKE"] || "make")
@ -2277,6 +2283,7 @@ end
$configure_args["--topdir"] ||= $curdir
$ruby = arg_config("--ruby", File.join(RbConfig::CONFIG["bindir"], CONFIG["ruby_install_name"]))
end
split = Shellwords.method(:shellwords).to_proc
EXPORT_PREFIX = config_string('EXPORT_PREFIX') {|s| s.strip}
@ -2335,7 +2342,13 @@ distclean: clean distclean-so distclean-rb-default distclean-rb
realclean: distclean
"
end
include MakeMakefile
if not $extmk and /\A(extconf|makefile).rb\z/ =~ File.basename($0)
END {mkmf_failed($0)}
end
make_makefile

View file

@ -78,7 +78,7 @@ class TestMkmf < Test::Unit::TestCase
remove_const(:MAKEFILE_CONFIG)
const_set(:MAKEFILE_CONFIG, mkconfig)
}
Object.class_eval {
MakeMakefile.class_eval {
remove_const(:CONFIG)
const_set(:CONFIG, mkconfig)
}
@ -101,7 +101,7 @@ class TestMkmf < Test::Unit::TestCase
remove_const(:MAKEFILE_CONFIG)
const_set(:MAKEFILE_CONFIG, mkconfig0)
}
Object.class_eval {
MakeMakefile.class_eval {
remove_const(:CONFIG)
const_set(:CONFIG, mkconfig0)
}