summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-05-29 03:08:45 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-05-29 03:08:45 +0000
commita594ca98f299dba9c988f95ce58e9c5d6229d26f (patch)
tree243c52fc6b4bde0a87e4ee7e16d2734902e9805e
parenta552fa2d66d495ec9700e9a656137e444b6f24dd (diff)
auto_ext.rb
* ext/-test-/auto_ext.rb (auto_ext): utitily method to create extension libraries for tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55198 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--ext/-test-/auto_ext.rb10
-rw-r--r--ext/-test-/bignum/extconf.rb9
-rw-r--r--ext/-test-/class/extconf.rb9
-rw-r--r--ext/-test-/debug/extconf.rb8
-rw-r--r--ext/-test-/exception/extconf.rb8
-rw-r--r--ext/-test-/file/extconf.rb9
-rw-r--r--ext/-test-/float/extconf.rb9
-rw-r--r--ext/-test-/hash/extconf.rb9
-rw-r--r--ext/-test-/integer/extconf.rb9
-rw-r--r--ext/-test-/iter/extconf.rb9
-rw-r--r--ext/-test-/method/extconf.rb8
-rw-r--r--ext/-test-/proc/extconf.rb9
-rw-r--r--ext/-test-/string/extconf.rb9
-rw-r--r--ext/-test-/struct/extconf.rb9
-rw-r--r--ext/-test-/symbol/extconf.rb8
-rw-r--r--ext/-test-/time/extconf.rb9
-rw-r--r--ext/-test-/win32/console/extconf.rb8
18 files changed, 47 insertions, 107 deletions
diff --git a/ChangeLog b/ChangeLog
index 1fc2cc0..8dfc947 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Sun May 29 12:08:42 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * ext/-test-/auto_ext.rb (auto_ext): utitily method to create
+ extension libraries for tests.
+
Sat May 28 20:40:57 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
* misc/ruby-additional.el (ruby-insert-heredoc-code-block): insert
diff --git a/ext/-test-/auto_ext.rb b/ext/-test-/auto_ext.rb
new file mode 100644
index 0000000..5f840c4
--- /dev/null
+++ b/ext/-test-/auto_ext.rb
@@ -0,0 +1,10 @@
+# frozen_string_literal: false
+def auto_ext(feat = $0[%r[/ext/-test-/(.*)/extconf.rb\z], 1], inc: false)
+ $INCFLAGS << " -I$(topdir) -I$(top_srcdir)" if inc
+ $srcs = Dir[File.join($srcdir, "*.{#{SRC_EXT.join(%q{,})}}")]
+ inits = $srcs.map {|s| File.basename(s, ".*")}
+ inits.delete("init")
+ inits.map! {|s|"X(#{s})"}
+ $defs << "-DTEST_INIT_FUNCS(X)=\"#{inits.join(' ')}\""
+ create_makefile(feat)
+end
diff --git a/ext/-test-/bignum/extconf.rb b/ext/-test-/bignum/extconf.rb
index 34f503c..d786b15 100644
--- a/ext/-test-/bignum/extconf.rb
+++ b/ext/-test-/bignum/extconf.rb
@@ -1,8 +1,3 @@
# frozen_string_literal: false
-$INCFLAGS << " -I$(topdir) -I$(top_srcdir)"
-$srcs = Dir[File.join($srcdir, "*.{#{SRC_EXT.join(%q{,})}}")]
-inits = $srcs.map {|s| File.basename(s, ".*")}
-inits.delete("init")
-inits.map! {|s|"X(#{s})"}
-$defs << "-DTEST_INIT_FUNCS(X)=\"#{inits.join(' ')}\""
-create_makefile("-test-/bignum")
+require_relative "../auto_ext.rb"
+auto_ext(inc: true)
diff --git a/ext/-test-/class/extconf.rb b/ext/-test-/class/extconf.rb
index 1c7837d..d786b15 100644
--- a/ext/-test-/class/extconf.rb
+++ b/ext/-test-/class/extconf.rb
@@ -1,8 +1,3 @@
# frozen_string_literal: false
-$INCFLAGS << " -I$(topdir) -I$(top_srcdir)"
-$srcs = Dir[File.join($srcdir, "*.{#{SRC_EXT.join(%q{,})}}")]
-inits = $srcs.map {|s| File.basename(s, ".*")}
-inits.delete("init")
-inits.map! {|s|"X(#{s})"}
-$defs << "-DTEST_INIT_FUNCS(X)=\"#{inits.join(' ')}\""
-create_makefile("-test-/class")
+require_relative "../auto_ext.rb"
+auto_ext(inc: true)
diff --git a/ext/-test-/debug/extconf.rb b/ext/-test-/debug/extconf.rb
index 0f34383..ca51178 100644
--- a/ext/-test-/debug/extconf.rb
+++ b/ext/-test-/debug/extconf.rb
@@ -1,7 +1,3 @@
# frozen_string_literal: false
-$srcs = Dir[File.join($srcdir, "*.{#{SRC_EXT.join(%q{,})}}")]
-inits = $srcs.map {|s| File.basename(s, ".*")}
-inits.delete("init")
-inits.map! {|s|"X(#{s})"}
-$defs << "-DTEST_INIT_FUNCS(X)=\"#{inits.join(' ')}\""
-create_makefile("-test-/debug")
+require_relative "../auto_ext.rb"
+auto_ext
diff --git a/ext/-test-/exception/extconf.rb b/ext/-test-/exception/extconf.rb
index 55bbb1f..ca51178 100644
--- a/ext/-test-/exception/extconf.rb
+++ b/ext/-test-/exception/extconf.rb
@@ -1,7 +1,3 @@
# frozen_string_literal: false
-$srcs = Dir[File.join($srcdir, "*.{#{SRC_EXT.join(%q{,})}}")]
-inits = $srcs.map {|s| File.basename(s, ".*")}
-inits.delete("init")
-inits.map! {|s|"X(#{s})"}
-$defs << "-DTEST_INIT_FUNCS(X)=\"#{inits.join(' ')}\""
-create_makefile("-test-/exception")
+require_relative "../auto_ext.rb"
+auto_ext
diff --git a/ext/-test-/file/extconf.rb b/ext/-test-/file/extconf.rb
index c4cfdad..321c173 100644
--- a/ext/-test-/file/extconf.rb
+++ b/ext/-test-/file/extconf.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: false
-$INCFLAGS << " -I$(topdir) -I$(top_srcdir)"
+require_relative "../auto_ext.rb"
headers = %w[sys/param.h sys/mount.h sys/vfs.h].select {|h| have_header(h)}
if have_type("struct statfs", headers)
@@ -14,9 +14,4 @@ if have_type("struct statvfs", headers)
have_struct_member("struct statvfs", "f_type", headers)
end
-$srcs = Dir[File.join($srcdir, "*.{#{SRC_EXT.join(%q{,})}}")]
-inits = $srcs.map {|s| File.basename(s, ".*")}
-inits.delete("init")
-inits.map! {|s|"X(#{s})"}
-$defs << "-DTEST_INIT_FUNCS(X)=\"#{inits.join(' ')}\""
-create_makefile("-test-/file")
+auto_ext(inc: true)
diff --git a/ext/-test-/float/extconf.rb b/ext/-test-/float/extconf.rb
index 15709a1..d786b15 100644
--- a/ext/-test-/float/extconf.rb
+++ b/ext/-test-/float/extconf.rb
@@ -1,8 +1,3 @@
# frozen_string_literal: false
-$INCFLAGS << " -I$(topdir) -I$(top_srcdir)"
-$srcs = Dir[File.join($srcdir, "*.{#{SRC_EXT.join(%q{,})}}")]
-inits = $srcs.map {|s| File.basename(s, ".*")}
-inits.delete("init")
-inits.map! {|s|"X(#{s})"}
-$defs << "-DTEST_INIT_FUNCS(X)=\"#{inits.join(' ')}\""
-create_makefile("-test-/float")
+require_relative "../auto_ext.rb"
+auto_ext(inc: true)
diff --git a/ext/-test-/hash/extconf.rb b/ext/-test-/hash/extconf.rb
index c823cb9..d786b15 100644
--- a/ext/-test-/hash/extconf.rb
+++ b/ext/-test-/hash/extconf.rb
@@ -1,8 +1,3 @@
# frozen_string_literal: false
-$INCFLAGS << " -I$(topdir) -I$(top_srcdir)"
-$srcs = Dir[File.join($srcdir, "*.{#{SRC_EXT.join(%q{,})}}")]
-inits = $srcs.map {|s| File.basename(s, ".*")}
-inits.delete("init")
-inits.map! {|s|"X(#{s})"}
-$defs << "-DTEST_INIT_FUNCS(X)=\"#{inits.join(' ')}\""
-create_makefile("-test-/hash")
+require_relative "../auto_ext.rb"
+auto_ext(inc: true)
diff --git a/ext/-test-/integer/extconf.rb b/ext/-test-/integer/extconf.rb
index 20bfffb..d786b15 100644
--- a/ext/-test-/integer/extconf.rb
+++ b/ext/-test-/integer/extconf.rb
@@ -1,8 +1,3 @@
# frozen_string_literal: false
-$INCFLAGS << " -I$(topdir) -I$(top_srcdir)"
-$srcs = Dir[File.join($srcdir, "*.{#{SRC_EXT.join(%q{,})}}")]
-inits = $srcs.map {|s| File.basename(s, ".*")}
-inits.delete("init")
-inits.map! {|s|"X(#{s})"}
-$defs << "-DTEST_INIT_FUNCS(X)=\"#{inits.join(' ')}\""
-create_makefile("-test-/integer")
+require_relative "../auto_ext.rb"
+auto_ext(inc: true)
diff --git a/ext/-test-/iter/extconf.rb b/ext/-test-/iter/extconf.rb
index a0f03e2..d786b15 100644
--- a/ext/-test-/iter/extconf.rb
+++ b/ext/-test-/iter/extconf.rb
@@ -1,8 +1,3 @@
# frozen_string_literal: false
-$INCFLAGS << " -I$(topdir) -I$(top_srcdir)"
-$srcs = Dir[File.join($srcdir, "*.{#{SRC_EXT.join(%q{,})}}")]
-inits = $srcs.map {|s| File.basename(s, ".*")}
-inits.delete("init")
-inits.map! {|s|"X(#{s})"}
-$defs << "-DTEST_INIT_FUNCS(X)=\"#{inits.join(' ')}\""
-create_makefile("-test-/iter")
+require_relative "../auto_ext.rb"
+auto_ext(inc: true)
diff --git a/ext/-test-/method/extconf.rb b/ext/-test-/method/extconf.rb
index 3a52c1a..ca51178 100644
--- a/ext/-test-/method/extconf.rb
+++ b/ext/-test-/method/extconf.rb
@@ -1,7 +1,3 @@
# frozen_string_literal: false
-$srcs = Dir[File.join($srcdir, "*.{#{SRC_EXT.join(%q{,})}}")]
-inits = $srcs.map {|s| File.basename(s, ".*")}
-inits.delete("init")
-inits.map! {|s|"X(#{s})"}
-$defs << "-DTEST_INIT_FUNCS(X)=\"#{inits.join(' ')}\""
-create_makefile("-test-/method")
+require_relative "../auto_ext.rb"
+auto_ext
diff --git a/ext/-test-/proc/extconf.rb b/ext/-test-/proc/extconf.rb
index 9f87575..d786b15 100644
--- a/ext/-test-/proc/extconf.rb
+++ b/ext/-test-/proc/extconf.rb
@@ -1,8 +1,3 @@
# frozen_string_literal: false
-$INCFLAGS << " -I$(topdir) -I$(top_srcdir)"
-$srcs = Dir[File.join($srcdir, "*.{#{SRC_EXT.join(%q{,})}}")]
-inits = $srcs.map {|s| File.basename(s, ".*")}
-inits.delete("init")
-inits.map! {|s|"X(#{s})"}
-$defs << "-DTEST_INIT_FUNCS(X)=\"#{inits.join(' ')}\""
-create_makefile("-test-/proc")
+require_relative "../auto_ext.rb"
+auto_ext(inc: true)
diff --git a/ext/-test-/string/extconf.rb b/ext/-test-/string/extconf.rb
index 5e8b709..d786b15 100644
--- a/ext/-test-/string/extconf.rb
+++ b/ext/-test-/string/extconf.rb
@@ -1,8 +1,3 @@
# frozen_string_literal: false
-$INCFLAGS << " -I$(topdir) -I$(top_srcdir)"
-$srcs = Dir[File.join($srcdir, "*.{#{SRC_EXT.join(%q{,})}}")]
-inits = $srcs.map {|s| File.basename(s, ".*")}
-inits.delete("init")
-inits.map! {|s|"X(#{s})"}
-$defs << "-DTEST_INIT_FUNCS(X)=\"#{inits.join(' ')}\""
-create_makefile("-test-/string")
+require_relative "../auto_ext.rb"
+auto_ext(inc: true)
diff --git a/ext/-test-/struct/extconf.rb b/ext/-test-/struct/extconf.rb
index 3b01a19..d786b15 100644
--- a/ext/-test-/struct/extconf.rb
+++ b/ext/-test-/struct/extconf.rb
@@ -1,8 +1,3 @@
# frozen_string_literal: false
-$INCFLAGS << " -I$(topdir) -I$(top_srcdir)"
-$srcs = Dir[File.join($srcdir, "*.{#{SRC_EXT.join(%q{,})}}")]
-inits = $srcs.map {|s| File.basename(s, ".*")}
-inits.delete("init")
-inits.map! {|s|"X(#{s})"}
-$defs << "-DTEST_INIT_FUNCS(X)=\"#{inits.join(' ')}\""
-create_makefile("-test-/struct")
+require_relative "../auto_ext.rb"
+auto_ext(inc: true)
diff --git a/ext/-test-/symbol/extconf.rb b/ext/-test-/symbol/extconf.rb
index f62fd47..ecebdb7 100644
--- a/ext/-test-/symbol/extconf.rb
+++ b/ext/-test-/symbol/extconf.rb
@@ -1,8 +1,4 @@
# frozen_string_literal: false
-$srcs = Dir[File.join($srcdir, "*.{#{SRC_EXT.join(%q{,})}}")]
-inits = $srcs.map {|s| File.basename(s, ".*")}
-inits.delete("init")
-inits.map! {|s|"X(#{s})"}
-$defs << "-DTEST_INIT_FUNCS(X)=\"#{inits.join(' ')}\""
+require_relative "../auto_ext.rb"
have_func("rb_pin_dynamic_symbol")
-create_makefile("-test-/symbol")
+auto_ext
diff --git a/ext/-test-/time/extconf.rb b/ext/-test-/time/extconf.rb
index c0b1934..d786b15 100644
--- a/ext/-test-/time/extconf.rb
+++ b/ext/-test-/time/extconf.rb
@@ -1,8 +1,3 @@
# frozen_string_literal: false
-$INCFLAGS << " -I$(topdir) -I$(top_srcdir)"
-$srcs = Dir[File.join($srcdir, "*.{#{SRC_EXT.join(%q{,})}}")]
-inits = $srcs.map {|s| File.basename(s, ".*")}
-inits.delete("init")
-inits.map! {|s|"X(#{s})"}
-$defs << "-DTEST_INIT_FUNCS(X)=\"#{inits.join(' ')}\""
-create_makefile("-test-/time")
+require_relative "../auto_ext.rb"
+auto_ext(inc: true)
diff --git a/ext/-test-/win32/console/extconf.rb b/ext/-test-/win32/console/extconf.rb
index fb9ef9d..5162172 100644
--- a/ext/-test-/win32/console/extconf.rb
+++ b/ext/-test-/win32/console/extconf.rb
@@ -1,9 +1,5 @@
# frozen_string_literal: false
if $mingw or $mswin
- $srcs = Dir[File.join($srcdir, "*.{#{SRC_EXT.join(%q{,})}}")]
- inits = $srcs.map {|s| File.basename(s, ".*")}
- inits.delete("init")
- inits.map! {|s|"X(#{s})"}
- $defs << "-DTEST_INIT_FUNCS(X)=\"#{inits.join(' ')}\""
- create_makefile("-test-/win32/console")
+ require_relative "../../auto_ext.rb"
+ auto_ext
end