* lib/mkmf.rb (check_sizeof): added optional compiler option

argument.  [ruby-core:24785]

* lib/mkmf.rb (create_makefile): suppressed shadowing outer local
  variable warnings.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24418 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2009-08-06 04:00:38 +00:00
Родитель d04b691b96
Коммит c6ada1e7e0
3 изменённых файлов: 44 добавлений и 7 удалений

Просмотреть файл

@ -1,3 +1,11 @@
Thu Aug 6 13:00:30 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/mkmf.rb (check_sizeof): added optional compiler option
argument. [ruby-core:24785]
* lib/mkmf.rb (create_makefile): suppressed shadowing outer local
variable warnings.
Thu Aug 6 12:05:06 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/test/unit/testcase.rb (Test::Unit): removes silly TestCase

Просмотреть файл

@ -155,7 +155,9 @@ end
topdir = File.dirname(libdir = File.dirname(__FILE__))
extdir = File.expand_path("ext", topdir)
path = File.expand_path($0)
$extmk = path[0, topdir.size+1] == topdir+"/" && %r"\A(ext|enc|tool)\z" =~ File.dirname(path[topdir.size+1..-1])
$extmk = path[0, topdir.size+1] == topdir+"/"
$extmk &&= %r"\A(?:ext|enc|tool|test(?:/.+))\z" =~ File.dirname(path[topdir.size+1..-1])
$extmk &&= true
if not $extmk and File.exist?(($hdrdir = RbConfig::CONFIG["rubyhdrdir"]) + "/ruby/ruby.h")
$topdir = $hdrdir
$top_srcdir = $hdrdir
@ -990,7 +992,7 @@ end
# For example, if check_sizeof('mystruct') returned 12, then the
# SIZEOF_MYSTRUCT=12 preprocessor macro would be passed to the compiler.
#
def check_sizeof(type, headers = nil, &b)
def check_sizeof(type, headers = nil, opts = "", &b)
typename, member = type.split('.', 2)
prelude = cpp_include(headers).split(/$/)
prelude << "typedef #{typename} rbcv_typedef_;\n"
@ -1812,19 +1814,19 @@ site-install-rb: install-rb
return unless target
mfile.puts SRC_EXT.collect {|ext| ".path.#{ext} = $(VPATH)"} if $nmake == ?b
mfile.puts SRC_EXT.collect {|e| ".path.#{e} = $(VPATH)"} if $nmake == ?b
mfile.print ".SUFFIXES: .#{SRC_EXT.join(' .')} .#{$OBJEXT}\n"
mfile.print "\n"
CXX_EXT.each do |ext|
CXX_EXT.each do |e|
COMPILE_RULES.each do |rule|
mfile.printf(rule, ext, $OBJEXT)
mfile.printf(rule, e, $OBJEXT)
mfile.printf("\n\t%s\n\n", COMPILE_CXX)
end
end
%w[c].each do |ext|
%w[c].each do |e|
COMPILE_RULES.each do |rule|
mfile.printf(rule, ext, $OBJEXT)
mfile.printf(rule, e, $OBJEXT)
mfile.printf("\n\t%s\n\n", COMPILE_C)
end
end

27
test/mkmf/test_sizeof.rb Normal file
Просмотреть файл

@ -0,0 +1,27 @@
require 'test/unit'
require 'mkmf'
require 'tmpdir'
$extout = '$(topdir)/'+RbConfig::CONFIG["EXTOUT"]
RbConfig::CONFIG['topdir'] = CONFIG['topdir'] = File.expand_path(CONFIG['topdir'])
RbConfig::CONFIG["extout"] = CONFIG["extout"] = $extout
$extout_prefix = "$(extout)$(target_prefix)/"
class TestMkmf < Test::Unit::TestCase
def setup
@tmpdir = Dir.mktmpdir
@mkmfobj = Object.new
end
def mkmf(*args, &block)
@mkmfobj.instance_eval(*args, &block)
end
def test_sizeof
Dir.chdir(@tmpdir) do
open("confdefs.h", "w") {|f|
f.puts "typedef struct {char x;} test1_t;"
}
mkmf {check_sizeof("test1_t", "confdefs.h")} rescue puts File.read("mkmf.log")
end
end
end