summaryrefslogtreecommitdiff
path: root/ext/dl/callback
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-03-09 18:48:34 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-03-09 18:48:34 +0000
commit53f011e662e74a846abf2c53ad2d1b096811f4f7 (patch)
treec9307d28a27aa9eebe922769830b68dbcd167f9f /ext/dl/callback
parentd3c4a4686a8f4533380c24d17736db3f6124de34 (diff)
* ext/dl/callback/depend: fix for parallel build.
* ext/dl/callback/extconf.rb: callback.h is no longer created. * ext/dl/callback/mkcallback.rb: creates main source first. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22863 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/dl/callback')
-rw-r--r--ext/dl/callback/depend18
-rw-r--r--ext/dl/callback/extconf.rb3
-rw-r--r--ext/dl/callback/mkcallback.rb25
3 files changed, 23 insertions, 23 deletions
diff --git a/ext/dl/callback/depend b/ext/dl/callback/depend
index aeca53f0ccc..63dfab6360d 100644
--- a/ext/dl/callback/depend
+++ b/ext/dl/callback/depend
@@ -1,18 +1,10 @@
-callback.o: $(hdrdir)/ruby.h $(hdrdir)/io.h
-
-callback-0.o: callback-0.c $(hdrdir)/ruby.h
-callback-1.o: callback-1.c $(hdrdir)/ruby.h
-callback-2.o: callback-2.c $(hdrdir)/ruby.h
-callback-3.o: callback-3.c $(hdrdir)/ruby.h
-callback-4.o: callback-4.c $(hdrdir)/ruby.h
-callback-5.o: callback-5.c $(hdrdir)/ruby.h
-callback-6.o: callback-6.c $(hdrdir)/ruby.h
-callback-7.o: callback-7.c $(hdrdir)/ruby.h
-callback-8.o: callback-8.c $(hdrdir)/ruby.h
+$(OBJS): $(hdrdir)/ruby.h
callback-0.c callback-1.c callback-2.c \
callback-3.c callback-4.c callback-5.c \
callback-6.c callback-7.c callback-8.c \
+ : callback.c
+
callback.c: $(srcdir)/mkcallback.rb $(srcdir)/../dl.h
- @echo "generating callback.h"
- @$(RUBY) $(srcdir)/mkcallback.rb $(srcdir)/../dl.h
+ @echo "generating callback.c"
+ @$(RUBY) $(srcdir)/mkcallback.rb -output=callback $(srcdir)/../dl.h
diff --git a/ext/dl/callback/extconf.rb b/ext/dl/callback/extconf.rb
index 1e8e749e1f1..6c3387670d6 100644
--- a/ext/dl/callback/extconf.rb
+++ b/ext/dl/callback/extconf.rb
@@ -5,7 +5,8 @@ if compiled?("dl")
callback_srcs = callbacks.map{|basename| "#{basename}.c"}
callback_objs = callbacks.map{|basename| "#{basename}.o"}
- $distcleanfiles += [ "callback.h", *callback_srcs ]
+ $distcleanfiles << '$(SRCS)'
+ $srcs = callback_srcs
$objs = callback_objs
$INCFLAGS << " -I$(srcdir)/.."
diff --git a/ext/dl/callback/mkcallback.rb b/ext/dl/callback/mkcallback.rb
index 81bfb82e9a0..b62a2eadf1c 100644
--- a/ext/dl/callback/mkcallback.rb
+++ b/ext/dl/callback/mkcallback.rb
@@ -1,4 +1,6 @@
-$out = open("callback.c", "w")
+#!ruby -s
+$output ||= "callback"
+$out = open("#{$output}.c", "w")
$dl_h = ARGV[0] || "dl.h"
@@ -157,10 +159,9 @@ def gen_push_addr_ary(ty, aryname, calltype)
end
def gen_callback_file(ty)
- filename = "callback-#{ty}.c"
+ filename = "#{$output}-#{ty}.c"
initname = "rb_dl_init_callbacks_#{ty}"
- open(filename, "w") {|f|
- f.puts <<-EOS
+ body = <<-EOS
#include "dl.h"
extern VALUE rb_DLCdeclCallbackAddrs, rb_DLCdeclCallbackProcs;
@@ -169,8 +170,8 @@ extern VALUE rb_DLStdcallCallbackAddrs, rb_DLStdcallCallbackProcs;
#endif
extern ID rb_dl_cb_call;
EOS
- yield f
- f.puts <<-EOS
+ yield body
+ body << <<-EOS
void
#{initname}()
{
@@ -182,12 +183,12 @@ void
#endif
}
EOS
- }
- initname
+ [filename, initname, body]
end
+callbacks = []
for ty in 0...MAX_DLTYPE
- initname = gen_callback_file(ty) {|f|
+ filename, initname, body = gen_callback_file(ty) {|f|
foreach_proc_entry do |calltype, proc_entry|
for argc in 0...DLSTACK_SIZE
for n in 0...MAX_CALLBACK
@@ -197,6 +198,7 @@ for ty in 0...MAX_DLTYPE
end
}
$out << "void #{initname}();\n"
+ callbacks << [filename, body]
end
$out << (<<EOS)
@@ -229,3 +231,8 @@ Init_callback(void)
}
}
EOS
+$out.close
+
+for filename, body in callbacks
+ open(filename, "wb") {|f| f.puts body}
+end