[前][次][番号順一覧][スレッド一覧]

ruby-changes:45322

From: nobu <ko1@a...>
Date: Sun, 22 Jan 2017 21:50:42 +0900 (JST)
Subject: [ruby-changes:45322] nobu:r57395 (trunk): template/extinit.c.tmpl

nobu	2017-01-22 21:50:36 +0900 (Sun, 22 Jan 2017)

  New Revision: 57395

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=57395

  Log:
    template/extinit.c.tmpl
    
    * template/extinit.c.tmpl: separate from ext/extmk.rb.

  Added files:
    trunk/template/extinit.c.tmpl
  Modified files:
    trunk/common.mk
    trunk/ext/extmk.rb
Index: common.mk
===================================================================
--- common.mk	(revision 57394)
+++ common.mk	(revision 57395)
@@ -220,6 +220,10 @@ build-ext: $(EXTS_MK) https://github.com/ruby/ruby/blob/trunk/common.mk#L220
 	$(Q)$(MAKE) -f $(EXTS_MK) $(MFLAGS) libdir="$(libdir)" LIBRUBY_EXTS=$(LIBRUBY_EXTS) \
 	    EXTENCS="$(ENCOBJS)" UPDATE_LIBRARIES=no $(EXTSTATIC)
 
+ext/extinit.c: $(srcdir)/template/extinit.c.tmpl
+	$(Q)$(MINIRUBY) $(srcdir)/tool/generic_erb.rb -o $@ -c \
+	    $(srcdir)/template/extinit.c.tmpl $(EXTINITS)
+
 prog: program wprogram
 
 $(PREP): $(MKFILES)
Index: template/extinit.c.tmpl
===================================================================
--- template/extinit.c.tmpl	(revision 0)
+++ template/extinit.c.tmpl	(revision 57395)
@@ -0,0 +1,16 @@ https://github.com/ruby/ruby/blob/trunk/template/extinit.c.tmpl#L1
+%# -*- C -*-
+#include "ruby/ruby.h"
+
+#define init(func, name) {	\
+    extern void func(void);	\
+    ruby_init_ext(name, func);	\
+}
+
+void ruby_init_ext(const char *name, void (*init)(void));
+
+void Init_ext(void)
+{
+% ARGV.each do |n|
+    init(Init_<%=n.sub(/,(.*)/, ', "\1.so"')%>);
+% end
+}

Property changes on: template/extinit.c.tmpl
___________________________________________________________________
Added: svn:eol-style
   + LF

Index: ext/extmk.rb
===================================================================
--- ext/extmk.rb	(revision 57394)
+++ ext/extmk.rb	(revision 57395)
@@ -11,7 +11,6 @@ $destdir = nil https://github.com/ruby/ruby/blob/trunk/ext/extmk.rb#L11
 $dryrun = false
 $clean = nil
 $nodynamic = nil
-$extinit = nil
 $extobjs = []
 $extflags = ""
 $extlibs = nil
@@ -642,13 +641,12 @@ if $ignore https://github.com/ruby/ruby/blob/trunk/ext/extmk.rb#L641
   exit
 end
 
-$extinit ||= ""
 $extobjs ||= []
 $extpath ||= []
 $extflags ||= ""
 $extlibs ||= []
+extinits = {}
 unless $extlist.empty?
-  $extinit << "\n" unless $extinit.empty?
   list = $extlist.dup
   built = []
   while e = list.shift
@@ -662,27 +660,11 @@ unless $extlist.empty? https://github.com/ruby/ruby/blob/trunk/ext/extmk.rb#L660
       next
     end
     base = File.basename(feature)
-    $extinit << "    init(Init_#{base}, \"#{feature}.so\");\n"
+    extinits[base] = feature
     $extobjs << format("ext/%s/%s.%s", target, base, $LIBEXT)
     built << target
   end
 
-  src = %{\
-#include "ruby/ruby.h"
-
-#define init(func, name) {	\\
-    extern void func(void);	\\
-    ruby_init_ext(name, func);	\\
-}
-
-void ruby_init_ext(const char *name, void (*init)(void));
-
-void Init_ext(void)\n{\n#$extinit}
-}
-  if !modified?(extinit.c, MTIMES) || IO.read(extinit.c) != src
-    open(extinit.c, "w") {|fe| fe.print src}
-  end
-
   $extpath.delete("$(topdir)")
   $extflags = libpathflag($extpath) << " " << $extflags.strip
   conf = [
@@ -749,6 +731,7 @@ if $configure_only and $command_output https://github.com/ruby/ruby/blob/trunk/ext/extmk.rb#L731
     mf.macro "EXTLIBS", $extlibs
     mf.macro "EXTSO", extso
     mf.macro "EXTLDFLAGS", $extflags.split
+    mf.macro "EXTINITS", extinits.map {|k, v| "#{k},#{v}"}
     submakeopts = []
     if enable_config("shared", $enable_shared)
       submakeopts << 'DLDOBJS="$(EXTOBJS) $(EXTENCS)"'
@@ -785,7 +768,7 @@ if $configure_only and $command_output https://github.com/ruby/ruby/blob/trunk/ext/extmk.rb#L768
       mf.puts "#{tgt}:\n\t#{submake} $@"
     end
     mf.puts "libencs:\n\t$(Q)$(MAKE) -f enc.mk V=$(V) $@"
-    mf.puts "ext/extinit.#{$OBJEXT}:\n\t$(Q)$(MAKE) $(MFLAGS) V=$(V) $@" if $static
+    mf.puts "ext/extinit.#{$OBJEXT}:\n\t$(Q)$(MAKE) $(MFLAGS) V=$(V) EXTINITS=\"$(EXTINITS)\" $@" if $static
     mf.puts
     if $gnumake == "yes"
       submake = "$(MAKE) -C $(@D)"

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]