summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-08-06 04:00:38 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-08-06 04:00:38 +0000
commitc6ada1e7e044d584e30359c8783a5bf9eb019d60 (patch)
tree2bec70a1eb44e3273292739fef26c4c5b0af5e5e
parentd04b691b96fa1c4c0c55a30e711309f7d5301042 (diff)
* 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
-rw-r--r--ChangeLog8
-rw-r--r--lib/mkmf.rb16
-rw-r--r--test/mkmf/test_sizeof.rb27
3 files changed, 44 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index a13e4ac6ec..63e0ec8de1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
diff --git a/lib/mkmf.rb b/lib/mkmf.rb
index 9c1b838acd..c5e4bd89b4 100644
--- a/lib/mkmf.rb
+++ b/lib/mkmf.rb
@@ -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
diff --git a/test/mkmf/test_sizeof.rb b/test/mkmf/test_sizeof.rb
new file mode 100644
index 0000000000..2e277d302b
--- /dev/null
+++ b/test/mkmf/test_sizeof.rb
@@ -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