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

ruby-changes:11003

From: nobu <ko1@a...>
Date: Tue, 24 Feb 2009 19:05:03 +0900 (JST)
Subject: [ruby-changes:11003] Ruby:r22592 (ruby_1_8, trunk): * common.mk (main): split from exts and makes main program after

nobu	2009-02-24 19:01:08 +0900 (Tue, 24 Feb 2009)

  New Revision: 22592

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=22592

  Log:
    * common.mk (main): split from exts and makes main program after
      building exts with miniruby, to get rid of overwriting running
      program.  [ruby-core:22339]
    * Makefile.in, win32/Makefile.sub (RUNCMD, MKMAIN_CMD): macros to
      run script file.
    
    * ext/extmk.rb (parse_args): added --command-output option which
      creates script file to make main program.

  Modified files:
    branches/ruby_1_8/ChangeLog
    branches/ruby_1_8/Makefile.in
    branches/ruby_1_8/common.mk
    branches/ruby_1_8/ext/extmk.rb
    branches/ruby_1_8/win32/Makefile.sub
    trunk/ChangeLog
    trunk/Makefile.in
    trunk/common.mk
    trunk/ext/extmk.rb
    trunk/win32/Makefile.sub

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 22591)
+++ ChangeLog	(revision 22592)
@@ -1,3 +1,15 @@
+Tue Feb 24 19:01:05 2009  Nobuyoshi Nakada  <nobu@r...>
+
+	* common.mk (main): split from exts and makes main program after
+	  building exts with miniruby, to get rid of overwriting running
+	  program.  [ruby-core:22339]
+
+	* Makefile.in, win32/Makefile.sub (RUNCMD, MKMAIN_CMD): macros to
+	  run script file.
+
+	* ext/extmk.rb (parse_args): added --command-output option which
+	  creates script file to make main program.
+
 Tue Feb 24 17:58:07 2009  Nobuyoshi Nakada  <nobu@r...>
 
 	* common.mk (ripper.c): exec can't work on Windows.
Index: common.mk
===================================================================
--- common.mk	(revision 22591)
+++ common.mk	(revision 22592)
@@ -122,9 +122,16 @@
 
 COMPILE_PRELUDE = $(MINIRUBY) -I$(srcdir) -rrbconfig $(srcdir)/tool/compile_prelude.rb
 
-all: encs exts
-exts: $(MKFILES) incs $(PREP) $(RBCONFIG) $(LIBRUBY)
-	@$(MINIRUBY) $(srcdir)/ext/extmk.rb --make="$(MAKE)" $(EXTMK_ARGS)
+all: encs exts main
+
+main: exts
+	@$(RUNCMD) $(MKMAIN_CMD) MAKE=$(MAKE)
+
+exts: $(MKMAIN_CMD)
+
+$(MKMAIN_CMD): $(MKFILES) incs $(PREP) $(RBCONFIG) $(LIBRUBY) 
+	@$(MINIRUBY) $(srcdir)/ext/extmk.rb --make="$(MAKE)" --command-output=$@ $(EXTMK_ARGS)
+
 prog: $(PROGRAM) $(WPROGRAM)
 
 loadpath: $(PREP)
Index: win32/Makefile.sub
===================================================================
--- win32/Makefile.sub	(revision 22591)
+++ win32/Makefile.sub	(revision 22592)
@@ -1,6 +1,7 @@
 # -*- makefile -*-
 
 SHELL = $(COMSPEC)
+RUNCMD = $(COMSPEC) /c
 MKFILES = Makefile
 NULL = nul
 
@@ -258,6 +259,8 @@
 
 INSTALLED_LIST= .installed.list
 
+MKMAIN_CMD    = mkmain.bat
+
 !if !defined(WINMAINOBJ)
 WINMAINOBJ    = winmain.$(OBJEXT)
 !endif
@@ -806,20 +809,15 @@
 $(INSNS):
 	@$(RM) $(PROGRAM)
 	-$(BASERUBY) -Ks $(srcdir)/tool/insns2vm.rb $(INSNS2VMOPT) $@
-	if not exist $@ copy $(srcdir:/=\)\$(@F) $@
 
 node_name.inc:
 	-$(BASERUBY) -n $(srcdir)/tool/node_name.rb $? > $@
-	if not exist $@ copy $(srcdir:/=\)\$(@F) $@
 
 known_errors.inc:
 	-$(BASERUBY) $(srcdir)/tool/generic_erb.rb -c -o $@ $(srcdir)/template/known_errors.inc.tmpl $(srcdir)/defs/known_errors.def
-	if not exist $@ copy $(srcdir:/=\)\$(@F) $@
 
 miniprelude.c:
 	-$(BASERUBY) -I$(srcdir) $(srcdir)/tool/compile_prelude.rb $(srcdir)/prelude.rb $@
-	if not exist $@ copy $(srcdir:/=\)\$(@F) $@
 
 newline.c:
 	-$(BASERUBY) "$(srcdir)/tool/transcode-tblgen.rb" -vo newline.c $(srcdir)/enc/trans/newline.trans
-	if not exist $@ copy $(srcdir:/=\)\$(@F) $@
Index: Makefile.in
===================================================================
--- Makefile.in	(revision 22591)
+++ Makefile.in	(revision 22592)
@@ -1,5 +1,6 @@
 SHELL = /bin/sh
 NULLCMD = :
+RUNCMD = $(SHELL)
 exec = exec
 
 #### Start of system configuration section. ####
@@ -118,6 +119,8 @@
 MANTYPE	      = @MANTYPE@
 
 INSTALLED_LIST= .installed.list
+
+MKMAIN_CMD    = mkmain.sh
 #### End of variables
 
 all:
Index: ext/extmk.rb
===================================================================
--- ext/extmk.rb	(revision 22591)
+++ ext/extmk.rb	(revision 22592)
@@ -16,6 +16,7 @@
 $extpath = nil
 $ignore = nil
 $message = nil
+$command_output = nil
 
 $progname = $0
 alias $PROGRAM_NAME $0
@@ -230,6 +231,7 @@
 
 def parse_args()
   $mflags = []
+  $makeflags = []
 
   $optparser ||= OptionParser.new do |opts|
     opts.on('-n') {$dryrun = true}
@@ -258,11 +260,15 @@
       if arg = v.first
         arg.insert(0, '-') if /\A[^-][^=]*\Z/ =~ arg
       end
+      $makeflags.concat(v.reject {|arg| /\AMINIRUBY=/ =~ arg}.quote)
       $mflags.concat(v)
     end
     opts.on('--message [MESSAGE]', String) do |v|
       $message = v
     end
+    opts.on('--command-output=FILE', String) do |v|
+      $command_output = v
+    end
   end
   begin
     $optparser.parse!(ARGV)
@@ -521,6 +527,7 @@
   puts(*conf)
   $stdout.flush
   $mflags.concat(conf)
+  $makeflags.concat(conf)
 else
   FileUtils.rm_f(extinit.to_a)
 end
@@ -537,9 +544,10 @@
 unless $destdir.to_s.empty?
   $mflags.defined?("DESTDIR") or $mflags << "DESTDIR=#{$destdir}"
 end
-puts "making #{rubies.join(', ')}"
-$stdout.flush
+message = "making #{rubies.join(', ')}"
 $mflags.concat(rubies)
+$makeflags.uniq!
+$makeflags.concat(rubies)
 
 if $nmake == ?b
   unless (vars = $mflags.grep(/\A\w+=/n)).empty?
@@ -555,7 +563,27 @@
 end
 $mflags.unshift("topdir=#$topdir")
 ENV.delete("RUBYOPT")
-system($make, *sysquote($mflags)) or exit($?.exitstatus)
+if $command_output
+  message = "echo #{message}"
+  cmd = [$make, *sysquote($makeflags)].join(' ')
+  open($command_output, 'wb') do |f|
+    case $command_output
+    when /\.sh\z/
+      f.puts message, "rm -f $0; exec #{cmd}"
+    when /\.bat\z/
+      ["@echo off", message, cmd, "del %0 & exit %ERRORLEVEL%"].each do |s|
+        f.print s, "\r\n"
+      end
+    else
+      f.puts cmd
+    end
+    f.chmod(0755)
+  end
+else
+  puts message
+  $stdout.flush
+  system($make, *sysquote($mflags)) or exit($?.exitstatus)
+end
 
 #Local variables:
 # mode: ruby
Index: ruby_1_8/Makefile.in
===================================================================
--- ruby_1_8/Makefile.in	(revision 22591)
+++ ruby_1_8/Makefile.in	(revision 22592)
@@ -1,5 +1,6 @@
 SHELL = /bin/sh
 NULLCMD = :
+RUNCMD = $(SHELL)
 
 #### Start of system configuration section. ####
 
@@ -93,6 +94,8 @@
 MANTYPE	      = @MANTYPE@
 
 INSTALLED_LIST= .installed.list
+
+MKMAIN_CMD    = mkmain.sh
 #### End of variables
 
 all:
Index: ruby_1_8/ext/extmk.rb
===================================================================
--- ruby_1_8/ext/extmk.rb	(revision 22591)
+++ ruby_1_8/ext/extmk.rb	(revision 22592)
@@ -16,6 +16,7 @@
 $extpath = nil
 $ignore = nil
 $message = nil
+$command_output = nil
 
 $progname = $0
 alias $PROGRAM_NAME $0
@@ -239,6 +240,7 @@
 
 def parse_args()
   $mflags = []
+  $makeflags = []
 
   opts = nil
   $optparser ||= OptionParser.new do |opts|
@@ -268,11 +270,15 @@
       if arg = v.first
         arg.insert(0, '-') if /\A[^-][^=]*\Z/ =~ arg
       end
+      $makeflags.concat(v.reject {|arg| /\AMINIRUBY=/ =~ arg}.quote)
       $mflags.concat(v)
     end
     opts.on('--message [MESSAGE]', String) do |v|
       $message = v
     end
+    opts.on('--command-output=FILE', String) do |v|
+      $command_output = v
+    end
   end
   begin
     $optparser.parse!(ARGV)
@@ -528,6 +534,7 @@
   puts conf
   $stdout.flush
   $mflags.concat(conf)
+  $makeflags.concat(conf)
 else
   FileUtils.rm_f(extinit.to_a)
 end
@@ -544,9 +551,10 @@
 unless $destdir.to_s.empty?
   $mflags.defined?("DESTDIR") or $mflags << "DESTDIR=#{$destdir}"
 end
-puts "making #{rubies.join(', ')}"
-$stdout.flush
+message = "making #{rubies.join(', ')}"
 $mflags.concat(rubies)
+$makeflags.uniq!
+$makeflags.concat(rubies)
 
 if $nmake == ?b
   unless (vars = $mflags.grep(/\A\w+=/n)).empty?
@@ -560,7 +568,27 @@
     vars.each {|flag| flag.sub!(/\A/, "-D")}
   end
 end
-system($make, *sysquote($mflags)) or exit($?.exitstatus)
+if $command_output
+  message = "echo #{message}"
+  cmd = [$make, *sysquote($makeflags)].join(' ')
+  open($command_output, 'wb') do |f|
+    case $command_output
+    when /\.sh\z/
+      f.puts message, "rm -f $0; exec #{cmd}"
+    when /\.bat\z/
+      ["@echo off", message, cmd, "del %0 & exit %ERRORLEVEL%"].each do |s|
+        f.print s, "\r\n"
+      end
+    else
+      f.puts cmd
+    end
+    f.chmod(0755)
+  end
+else
+  puts message
+  $stdout.flush
+  system($make, *sysquote($mflags)) or exit($?.exitstatus)
+end
 
 #Local variables:
 # mode: ruby
Index: ruby_1_8/ChangeLog
===================================================================
--- ruby_1_8/ChangeLog	(revision 22591)
+++ ruby_1_8/ChangeLog	(revision 22592)
@@ -1,3 +1,15 @@
+Tue Feb 24 19:01:05 2009  Nobuyoshi Nakada  <nobu@r...>
+
+	* common.mk (main): split from exts and makes main program after
+	  building exts with miniruby, to get rid of overwriting running
+	  program.  [ruby-core:22339]
+
+	* Makefile.in, win32/Makefile.sub (RUNCMD, MKMAIN_CMD): macros to
+	  run script file.
+
+	* ext/extmk.rb (parse_args): added --command-output option which
+	  creates script file to make main program.
+
 Tue Feb 24 07:09:50 2009  Yukihiro Matsumoto  <matz@r...>
 
 	* regex.c (re_compile_pattern): \s should include \v too.
Index: ruby_1_8/common.mk
===================================================================
--- ruby_1_8/common.mk	(revision 22591)
+++ ruby_1_8/common.mk	(revision 22592)
@@ -80,8 +80,16 @@
 
 VCS           = svn
 
-all: $(MKFILES) $(PREP) $(RBCONFIG) $(LIBRUBY)
-	@$(MINIRUBY) $(srcdir)/ext/extmk.rb --make="$(MAKE)" $(EXTMK_ARGS)
+all: main
+
+main: exts
+	@$(RUNCMD) $(MKMAIN_CMD) MAKE=$(MAKE)
+
+exts: $(MKMAIN_CMD)
+
+$(MKMAIN_CMD): $(MKFILES) $(PREP) $(RBCONFIG) $(LIBRUBY)
+	@$(MINIRUBY) $(srcdir)/ext/extmk.rb --make="$(MAKE)" --command-output=$@ $(EXTMK_ARGS)
+
 prog: $(PROGRAM) $(WPROGRAM)
 
 miniruby$(EXEEXT): config.status $(LIBRUBY_A) $(MAINOBJ) $(MINIOBJS) $(OBJS) $(DMYEXT)
Index: ruby_1_8/win32/Makefile.sub
===================================================================
--- ruby_1_8/win32/Makefile.sub	(revision 22591)
+++ ruby_1_8/win32/Makefile.sub	(revision 22592)
@@ -1,6 +1,7 @@
 # -*- makefile -*-
 
 SHELL = $(COMSPEC)
+RUNCMD = $(COMSPEC) /c
 MKFILES = Makefile
 NULL = nul
 
@@ -237,6 +238,8 @@
 
 INSTALLED_LIST= .installed.list
 
+MKMAIN_CMD    = mkmain.bat
+
 !if !defined(WINMAINOBJ)
 WINMAINOBJ    = winmain.$(OBJEXT)
 !endif

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

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