зеркало из https://github.com/github/ruby.git
mkmf.rb: defer use of instance variable
* lib/mkmf.rb (MakeMakefile#dir_config, MakeMakefile#_libdir_basename): defer use of instance variable until needed. [Bug #8074] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39717 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
c0035ed351
Коммит
76d8cc33f9
|
@ -1,3 +1,8 @@
|
||||||
|
Mon Mar 11 11:53:35 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* lib/mkmf.rb (MakeMakefile#dir_config, MakeMakefile#_libdir_basename):
|
||||||
|
defer use of instance variable until needed. [Bug #8074]
|
||||||
|
|
||||||
Thu Mar 7 10:42:28 2013 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
Thu Mar 7 10:42:28 2013 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
||||||
|
|
||||||
* lib/thread.rb (Queue#clear): return self.
|
* lib/thread.rb (Queue#clear): return self.
|
||||||
|
|
22
lib/mkmf.rb
22
lib/mkmf.rb
|
@ -45,6 +45,16 @@ end
|
||||||
# correctly compile and link the C extension to ruby and a third-party
|
# correctly compile and link the C extension to ruby and a third-party
|
||||||
# library.
|
# library.
|
||||||
module MakeMakefile
|
module MakeMakefile
|
||||||
|
#### defer until this module become global-state free.
|
||||||
|
# def self.extended(obj)
|
||||||
|
# obj.init_mkmf
|
||||||
|
# super
|
||||||
|
# end
|
||||||
|
#
|
||||||
|
# def initialize(*args, rbconfig: RbConfig, **rest)
|
||||||
|
# init_mkmf(rbconfig::MAKEFILE_CONFIG, rbconfig::CONFIG)
|
||||||
|
# super(*args, **rest)
|
||||||
|
# end
|
||||||
|
|
||||||
##
|
##
|
||||||
# The makefile configuration using the defaults from when ruby was built.
|
# The makefile configuration using the defaults from when ruby was built.
|
||||||
|
@ -1676,7 +1686,7 @@ SRC
|
||||||
idir = with_config(target + "-include", idefault)
|
idir = with_config(target + "-include", idefault)
|
||||||
$arg_config.last[1] ||= "${#{target}-dir}/include"
|
$arg_config.last[1] ||= "${#{target}-dir}/include"
|
||||||
ldir = with_config(target + "-lib", ldefault)
|
ldir = with_config(target + "-lib", ldefault)
|
||||||
$arg_config.last[1] ||= "${#{target}-dir}/#{@libdir_basename}"
|
$arg_config.last[1] ||= "${#{target}-dir}/#{_libdir_basename}"
|
||||||
|
|
||||||
idirs = idir ? Array === idir ? idir.dup : idir.split(File::PATH_SEPARATOR) : []
|
idirs = idir ? Array === idir ? idir.dup : idir.split(File::PATH_SEPARATOR) : []
|
||||||
if defaults
|
if defaults
|
||||||
|
@ -1693,7 +1703,7 @@ SRC
|
||||||
|
|
||||||
ldirs = ldir ? Array === ldir ? ldir.dup : ldir.split(File::PATH_SEPARATOR) : []
|
ldirs = ldir ? Array === ldir ? ldir.dup : ldir.split(File::PATH_SEPARATOR) : []
|
||||||
if defaults
|
if defaults
|
||||||
ldirs.concat(defaults.collect {|d| "#{d}/#{@libdir_basename}"})
|
ldirs.concat(defaults.collect {|d| "#{d}/#{_libdir_basename}"})
|
||||||
ldir = ([ldir] + ldirs).compact.join(File::PATH_SEPARATOR)
|
ldir = ([ldir] + ldirs).compact.join(File::PATH_SEPARATOR)
|
||||||
end
|
end
|
||||||
$LIBPATH = ldirs | $LIBPATH
|
$LIBPATH = ldirs | $LIBPATH
|
||||||
|
@ -2378,8 +2388,6 @@ site-install-rb: install-rb
|
||||||
$extout ||= nil
|
$extout ||= nil
|
||||||
$extout_prefix ||= nil
|
$extout_prefix ||= nil
|
||||||
|
|
||||||
@libdir_basename = config["libdir"] && config["libdir"][/\A\$\(exec_prefix\)\/(.*)/, 1] or "lib"
|
|
||||||
|
|
||||||
$arg_config.clear
|
$arg_config.clear
|
||||||
dir_config("opt")
|
dir_config("opt")
|
||||||
end
|
end
|
||||||
|
@ -2404,6 +2412,12 @@ MESSAGE
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def _libdir_basename
|
||||||
|
@libdir_basename ||= config_string("libdir") {|name| name[/\A\$\(exec_prefix\)\/(.*)/, 1]} || "lib"
|
||||||
|
end
|
||||||
|
|
||||||
extend self
|
extend self
|
||||||
init_mkmf
|
init_mkmf
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
require 'test/unit'
|
||||||
|
require 'mkmf'
|
||||||
|
require_relative '../ruby/envutil'
|
||||||
|
|
||||||
|
class TestMkmf
|
||||||
|
class TestConfig < Test::Unit::TestCase
|
||||||
|
def test_dir_config
|
||||||
|
bug8074 = '[Bug #8074]'
|
||||||
|
assert_separately %w[-rmkmf - -- --with-foo-dir=/test/foo], %{
|
||||||
|
assert_equal(%w[/test/foo/include /test/foo/lib], dir_config("foo"), #{bug8074.dump})
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Загрузка…
Ссылка в новой задаче