ruby-changes:10220
From: nobu <ko1@a...>
Date: Sun, 25 Jan 2009 11:06:51 +0900 (JST)
Subject: [ruby-changes:10220] Ruby:r21764 (trunk): * Makefile.in, win32/Makefile.sub (RMDIRS): remove directory and
nobu 2009-01-25 11:06:29 +0900 (Sun, 25 Jan 2009) New Revision: 21764 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=21764 Log: * Makefile.in, win32/Makefile.sub (RMDIRS): remove directory and parents. * Makefile.in, win32/Makefile.sub (distclean-rdoc): added to remove temprary rdoc. * Makefile.in, win32/Makefile.sub (distclean): removes extout directory. * Makefile.in, win32/Makefile.sub (clean-ext): skips non-existent directories. * common.mk (clean, distclean): cleans rdoc. * configure.in (RMDIRS, RMALL): added to clean extout. * lib/fileutils.rb (FileUtils#rmdir): added :parents option. * lib/mkmf.rb (create_makefile): cleans installed files at clean instead of distclean. * lib/mkmf.rb (create_makefile): added clean-so and clean-rb. * lib/mkmf.rb (def init_mkmf): added DISTCLEANDIRS. * lib/un.rb (rmdir): added -p option. * tool/rmdirs, win32/rmdirs.bat: removes directory and the parents. * win32/rm.bat: added -r option. Added files: trunk/tool/rmdirs trunk/win32/rmdirs.bat Modified files: trunk/ChangeLog trunk/Makefile.in trunk/common.mk trunk/configure.in trunk/lib/fileutils.rb trunk/lib/mkmf.rb trunk/lib/un.rb trunk/win32/Makefile.sub trunk/win32/rm.bat Index: configure.in =================================================================== --- configure.in (revision 21763) +++ configure.in (revision 21764) @@ -265,6 +265,8 @@ MAKEDIRS='install -d' fi AC_SUBST(MAKEDIRS) +AC_SUBST(RMDIRS, ['$(top_srcdir)/tool/rmdirs']) +AC_SUBST(RMALL, ['rm -fr']) dnl check for large file stuff mv confdefs.h confdefs1.h Index: ChangeLog =================================================================== --- ChangeLog (revision 21763) +++ ChangeLog (revision 21764) @@ -1,3 +1,36 @@ +Sun Jan 25 11:07:51 2009 Nobuyoshi Nakada <nobu@r...> + + * Makefile.in, win32/Makefile.sub (RMDIRS): remove directory and + parents. + + * Makefile.in, win32/Makefile.sub (distclean-rdoc): added to remove + temprary rdoc. + + * Makefile.in, win32/Makefile.sub (distclean): removes extout + directory. + + * Makefile.in, win32/Makefile.sub (clean-ext): skips non-existent + directories. + + * common.mk (clean, distclean): cleans rdoc. + + * configure.in (RMDIRS, RMALL): added to clean extout. + + * lib/fileutils.rb (FileUtils#rmdir): added :parents option. + + * lib/mkmf.rb (create_makefile): cleans installed files at clean + instead of distclean. + + * lib/mkmf.rb (create_makefile): added clean-so and clean-rb. + + * lib/mkmf.rb (def init_mkmf): added DISTCLEANDIRS. + + * lib/un.rb (rmdir): added -p option. + + * tool/rmdirs, win32/rmdirs.bat: removes directory and the parents. + + * win32/rm.bat: added -r option. + Sun Jan 25 09:09:29 2009 Nobuyoshi Nakada <nobu@r...> * dir.c (join_path): use strlcat() to force link. Index: lib/fileutils.rb =================================================================== --- lib/fileutils.rb (revision 21763) +++ lib/fileutils.rb (revision 21764) @@ -258,15 +258,24 @@ def rmdir(list, options = {}) fu_check_options options, OPT_TABLE['rmdir'] list = fu_list(list) - fu_output_message "rmdir #{list.join ' '}" if options[:verbose] + parents = options[:parents] + fu_output_message "rmdir #{parents ? '-p ' : ''}#{list.join ' '}" if options[:verbose] return if options[:noop] list.each do |dir| - Dir.rmdir dir.sub(%r</\z>, '') + begin + Dir.rmdir(dir = dir.sub(%r</\z>, '')) + if parents + until (parent = File.dirname(dir)) == '.' or parent == dir + Dir.rmdir(dir) + end + end + rescue Errno::ENOTEMPTY, Errno::ENOENT + end end end module_function :rmdir - OPT_TABLE['rmdir'] = [:noop, :verbose] + OPT_TABLE['rmdir'] = [:parents, :noop, :verbose] # # Options: force noop verbose Index: lib/mkmf.rb =================================================================== --- lib/mkmf.rb (revision 21763) +++ lib/mkmf.rb (revision 21764) @@ -1407,6 +1407,7 @@ RUBY = $(ruby#{sep}) RM = #{config_string('RM', &possible_command) || '$(RUBY) -run -e rm -- -f'} RM_RF = #{'$(RUBY) -run -e rm -- -rf'} +RMDIRS = #{config_string('RMDIRS', &possible_command) || '$(RUBY) -run -e rmdir -- -p'} MAKEDIRS = #{config_string('MAKEDIRS', &possible_command) || '@$(RUBY) -run -e mkdir -- -p'} INSTALL = #{config_string('INSTALL', &possible_command) || '@$(RUBY) -run -e install -- -vp'} INSTALL_PROG = #{config_string('INSTALL_PROG') || '$(INSTALL) -m 0755'} @@ -1606,7 +1607,8 @@ origdef ||= '' if $extout and $INSTALLFILES - $distcleanfiles.concat($INSTALLFILES.collect {|files, dir|File.join(dir, files.sub(/\A\.\//, ''))}) + $cleanfiles.concat($INSTALLFILES.collect {|files, dir|File.join(dir, files.sub(/\A\.\//, ''))}) + $distcleandirs.concat($INSTALLFILES.collect {|files, dir| dir}) end if $extmk and not $extconf_h @@ -1626,6 +1628,7 @@ CLEANFILES = #{$cleanfiles.join(' ')} DISTCLEANFILES = #{$distcleanfiles.join(' ')} +DISTCLEANDIRS = #{$distcleandirs.join(' ')} extout = #{$extout} extout_prefix = #{$extout_prefix} @@ -1652,6 +1655,18 @@ static: $(STATIC_LIB)#{$extout ? " install-rb" : ""} " mfile.print CLEANINGS + fsep = config_string('BUILD_FILE_SEPARATOR') {|s| s unless s == "/"} + if fsep + fseprepl = proc {|s| + s = s.gsub("/", fsep) + s = s.gsub(/(\$\(\w+)(\))/) {$1+sep+$2} + s = s.gsub(/(\$\{\w+)(\})/) {$1+sep+$2} + } + sep = ":/=#{fsep}" + else + fseprepl = proc {|s| s} + sep = "" + end dirs = [] mfile.print "install: install-so install-rb\n\n" sodir = (dir = "$(RUBYARCHDIR)").dup @@ -1660,18 +1675,13 @@ f = "$(DLLIB)" dest = "#{dir}/#{f}" mfile.puts dir, "install-so: #{dest}" - unless $extout + if $extout + mfile.print "clean-so::\n" + mfile.print "\t@-$(RM) #{fseprepl[dest]}\n" + mfile.print "\t@-$(RMDIRS) #{fseprepl[dir]}\n" + else mfile.print "#{dest}: #{f}\n" - if (sep = config_string('BUILD_FILE_SEPARATOR')) - f.gsub!("/", sep) - dir.gsub!("/", sep) - sep = ":/="+sep - f.gsub!(/(\$\(\w+)(\))/) {$1+sep+$2} - f.gsub!(/(\$\{\w+)(\})/) {$1+sep+$2} - dir.gsub!(/(\$\(\w+)(\))/) {$1+sep+$2} - dir.gsub!(/(\$\{\w+)(\})/) {$1+sep+$2} - end - mfile.print "\t$(INSTALL_PROG) #{f} #{dir}\n" + mfile.print "\t$(INSTALL_PROG) #{fseprepl[f]} #{fseprepl[dir]}\n" if defined?($installed_list) mfile.print "\t@echo #{dir}/#{File.basename(f)}>>$(INSTALLED_LIST)\n" end @@ -1683,35 +1693,41 @@ mfile.print("install-rb-default: pre-install-rb-default\n") mfile.print("pre-install-rb: Makefile\n") mfile.print("pre-install-rb-default: Makefile\n") - fsep = config_string('BUILD_FILE_SEPARATOR') {|s| s unless s == "/"} - sep = fsep ? ":/=#{fsep}" : "" for sfx, i in [["-default", [["lib/**/*.rb", "$(RUBYLIBDIR)", "lib"]]], ["", $INSTALLFILES]] files = install_files(mfile, i, nil, srcprefix) or next for dir, *files in files unless dirs.include?(dir) dirs << dir mfile.print "pre-install-rb#{sfx}: #{dir}\n" - end if $nmake + end for f in files dest = "#{dir}/#{File.basename(f)}" mfile.print("install-rb#{sfx}: #{dest}\n") mfile.print("#{dest}: #{f}\n") - mfile.print("\t$(MAKEDIRS) $(@D)\n") unless $nmake mfile.print("\t$(#{$extout ? 'COPY' : 'INSTALL_DATA'}) ") - if fsep - f = f.gsub("/", fsep) - f = f.gsub(/(\$\(\w+)(\))/) {$1+sep+$2} - f = f.gsub(/(\$\{\w+)(\})/) {$1+sep+$2} - end - mfile.print("#{f} $(@D#{sep})\n") + mfile.print("#{fseprepl[f]} $(@D#{sep})\n") if defined?($installed_list) and !$extout mfile.print("\t@echo #{dest}>>$(INSTALLED_LIST)\n") end + if $extout + mfile.print("clean-rb#{sfx}::\n") + mfile.print("\t@-$(RM) #{fseprepl[dest]}\n") + end end end + if $extout + dirs.uniq! + dirs.reverse! + unless dirs.empty? + mfile.print("clean-rb#{sfx}::\n") + for dir in dirs + mfile.print("\t@-$(RMDIRS) #{fseprepl[dir]}\n") + end + end + end end dirs.unshift(sodir) if target and !dirs.include?(sodir) - dirs.each {|d| mfile.print "#{d}:\n\t$(MAKEDIRS) $@\n" if $nmake || d == sodir} + dirs.each {|d| mfile.print "#{d}:\n\t$(MAKEDIRS) $@\n"} mfile.print <<-SITEINSTALL @@ -1823,6 +1839,7 @@ $cleanfiles = config_string('CLEANFILES') {|s| Shellwords.shellwords(s)} || [] $cleanfiles << "mkmf.log" $distcleanfiles = config_string('DISTCLEANFILES') {|s| Shellwords.shellwords(s)} || [] + $distcleandirs = config_string('DISTCLEANDIRS') {|s| Shellwords.shellwords(s)} || [] $extout ||= nil $extout_prefix ||= nil @@ -1917,12 +1934,19 @@ sep = config_string('BUILD_FILE_SEPARATOR') {|s| ":/=#{s}" if sep != "/"} || "" CLEANINGS = " -clean: +clean-rb-default:: +clean-rb:: +clean-so:: +clean: clean-so clean-rb-default clean-rb \t\t@-$(RM) $(CLEANLIBS#{sep}) $(CLEANOBJS#{sep}) $(CLEANFILES#{sep}) -distclean: clean +distclean-rb-default:: +distclean-rb:: +distclean-so:: +distclean: clean distclean-so distclean-rb-default distclean-rb \t\t@-$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log \t\t@-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES#{sep}) +\t\t@-$(RMDIRS) $(DISTCLEANDIRS#{sep}) realclean: distclean " Index: lib/un.rb =================================================================== --- lib/un.rb (revision 21763) +++ lib/un.rb (revision 21764) @@ -158,11 +158,13 @@ # # ruby -run -e rmdir -- [OPTION] DIR # +# -p remove DIRECTORY and its ancestors. # -v verbose # def rmdir - setup do |argv, options| + setup("p") do |argv, options| + options[:parents] = true if options.delete :p FileUtils.rmdir argv, options end end Index: common.mk =================================================================== --- common.mk (revision 21763) +++ common.mk (revision 21764) @@ -340,7 +340,7 @@ clear-installed-list: @exit > $(INSTALLED_LIST) -clean: clean-ext clean-local clean-enc clean-golf +clean: clean-ext clean-local clean-enc clean-golf clean-rdoc clean-local:: @$(RM) $(OBJS) $(MINIOBJS) $(MAINOBJ) $(LIBRUBY_A) $(LIBRUBY_SO) $(LIBRUBY) $(LIBRUBY_ALIASES) @$(RM) $(PROGRAM) $(WPROGRAM) miniruby$(EXEEXT) dmyext.$(OBJEXT) $(ARCHFILE) .*.time @@ -350,10 +350,11 @@ @-$(MAKE) -f $(ENC_MK) $(MFLAGS) clean clean-golf: @$(RM) $(GORUBY)$(EXEEXT) $(GOLFOBJS) +clean-rdoc: distclean: distclean-ext distclean-local distclean-enc distclean-golf distclean-local:: clean-local - @$(RM) $(MKFILES) $(arch_hdrdir)/ruby/config.h rbconfig.rb yasmdata.rb encdb.h + @$(RM) $(MKFILES) rbconfig.rb yasmdata.rb encdb.h @$(RM) config.cache config.log config.status config.status.lineno $(PRELUDES) @$(RM) *~ *.bak *.stackdump core *.core gmon.out $(PREP) distclean-ext:: @@ -361,6 +362,7 @@ @-$(MAKE) -f $(ENC_MK) $(MFLAGS) distclean distclean-golf: clean-golf @$(RM) $(GOLFPRELUDES) +distclean-rdoc: realclean:: realclean-ext realclean-local realclean-enc realclean-golf realclean-local:: distclean-local Index: win32/rm.bat =================================================================== --- win32/rm.bat (revision 21763) +++ win32/rm.bat (revision 21764) @@ -1,8 +1,19 @@ @echo off +:optloop if "%1" == "-f" shift +if "%1" == "-r" (set recursive=1 & goto :optloop) +if "%recursive%" == "1" goto :recursive :begin if "%1" == "" goto :end if exist "%1" del "%1" +set p=%1 +if exist "%p:/=\%" del "%p:/=\%" shift goto :begin +:recursive +if "%1" == "" goto :end +set p=%1 +if exist "%p:/=\%" rd /s /q "%p:/=\%" +shift +goto :recursive :end Index: win32/Makefile.sub =================================================================== --- win32/Makefile.sub (revision 21763) +++ win32/Makefile.sub (revision 21764) @@ -64,6 +64,7 @@ AUTOCONF = autoconf IFCHANGE = $(COMSPEC) /C $(srcdir:/=\)\win32\ifchange.bat RM = $(COMSPEC) /C $(srcdir:/=\)\win32\rm.bat +RMDIRS = $(COMSPEC) /C $(srcdir:/=\)\win32\rmdirs.bat CP = copy > nul MV = move > nul !if !defined(BASERUBY) @@ -575,6 +576,8 @@ s,@LN_S@,$(LN_S),;t t s,@SET_MAKE@,MFLAGS = -$$(MAKEFLAGS),;t t s,@RM@,$$(COMSPEC) /C $$(top_srcdir:/=\)\win32\rm.bat,;t t +s,@RMDIRS@,$$(COMSPEC) /C $$(top_srcdir:/=\)\win32\rmdirs.bat,;t t +s,@RMALL@,$$(COMSPEC) /C rmdir /s /q,;t t s,@CP@,copy > nul,;t t s,@LIBOBJS@,$(LIBOBJS),;t t s,@ALLOCA@,$(ALLOCA),;t t @@ -712,15 +715,29 @@ distclean-local:: @$(RM) ext\config.cache $(RBCONFIG:/=\) $(CONFIG_H:/=\) @$(RM) $(RUBY_INSTALL_NAME).rc $(RUBYW_INSTALL_NAME).rc $(RUBY_SO_NAME).rc + @-$(RM) $(INSTALLED_LIST:/=\) $(arch_hdrdir:/=\)\ruby\config.h + @-$(RMDIRS) $(arch_hdrdir:/=\)\ruby +distclean-rdoc: + @-$(RMALL) $(RDOCOUT:/=\) + +distclean: + @-rmdir $(EXTOUT:/=\)\$(arch) + @-rmdir $(EXTOUT:/=\) + clean-ext distclean-ext realclean-ext:: - @for /R ext %I in (.) do @if exist %I\Makefile ( \ +!if "$(EXTS)" == "" + @for %I in ($(EXTS)) \ +!else + @for /R ext %I in (.) \ +!endif + do @if exist %I\Makefile ( \ + cd %I && ( \ echo $(@:-ext=)ing %~nI & \ - cd %I & \ $(MAKE) $(MFLAGS) $(@:-ext=) & \ cd %CD% & \ - rmdir %I \ - ) + $(RMDIRS) %I \ + ) ) distclean-ext realclean-ext:: @-rmdir ext Index: win32/rmdirs.bat =================================================================== --- win32/rmdirs.bat (revision 0) +++ win32/rmdirs.bat (revision 21764) @@ -0,0 +1,29 @@ +::-*- batch -*- +@echo off +if "%1" == "-p" shift +:begin +if "%1" == "" goto :end + set dir=%1 + shift + set dir=%dir:/=\% + :rmdirs + if not exist "%dir%\." goto :begin + if "%dir%" == "." goto :begin + if "%dir%" == ".." goto :begin + rd "%dir%" || goto :begin + :trim_sep + if not /%dir:~-1%/ == /\/ goto :trim_base + set dir=%dir:~0,-1% + if not "%dir%" == "" goto :trim_sep + :trim_base + if /%dir:~-1%/ == /\/ goto :parent + set dir=%dir:~0,-1% + if not "%dir%" == "" goto :trim_base + :parent + set dir=%dir:~0,-1% + if "%dir%" == "" goto :begin + if "%dir:~-1%" == ":" goto :begin + goto :rmdirs +shift +goto :begin +:end Property changes on: win32/rmdirs.bat ___________________________________________________________________ Name: svn:eol-style + CRLF Name: svn:executable + * Index: Makefile.in =================================================================== --- Makefile.in (revision 21763) +++ Makefile.in (revision 21764) @@ -4,6 +4,7 @@ #### Start of system configuration section. #### srcdir = @srcdir@ +top_srcdir = $(srcdir) hdrdir = $(srcdir)/include CC = @CC@ @@ -94,6 +95,7 @@ CP = cp MV = mv RM = rm -f +RMDIRS = @RMDIRS@ NM = @NM@ AR = @AR@ ARFLAGS = rcu @@ -221,22 +223,29 @@ @$(RM) ext/config.cache $(RBCONFIG) $(RM) Doxyfile @-$(RM) run.gdb - -$(RM) $(INSTALLED_LIST) $(arch_hdrdir)/ruby/config.h - -rmdir -p $(arch_hdrdir)/ruby + @-$(RM) $(INSTALLED_LIST) $(arch_hdrdir)/ruby/config.h + @-$(RMDIRS) $(arch_hdrdir)/ruby +distclean-rdoc: + @$(RMALL) $(RDOCOUT:/=\) + +distclean: + @-rmdir $(EXTOUT)/$(arch) + @-rmdir $(EXTOUT) + clean-ext distclean-ext realclean-ext:: @set dummy ${EXTS}; shift; \ if test "$$#" = 0; then \ set dummy `find ext -name Makefile | sed 's:^ext/::;s:/Makefile$$::' | sort`; \ shift; \ fi; \ - cd ext; \ for dir; do \ + [ -f "ext/$$dir/Makefile" ] || continue; \ echo $(@:-ext=)ing "$$dir"; \ - (cd "$$dir"; $(MAKE) $(MFLAGS) $(@:-ext=)) && \ + (cd "ext/$$dir" && exec $(MAKE) $(MFLAGS) $(@:-ext=)) && \ case "$@" in \ *distclean-ext*|*realclean-ext*) \ - rmdir -p "$$dir" 2> /dev/null;; \ + $(RMDIRS) "ext/$$dir";; \ esac; \ done Index: tool/rmdirs =================================================================== --- tool/rmdirs (revision 0) +++ tool/rmdirs (revision 21764) @@ -0,0 +1,11 @@ +#!/bin/sh +for dir; do + while rmdir "$dir" >/dev/null 2>&1 && + parent=`expr "$dir" : '\(.*\)/[^/][^/]*'`; do + case "$parent" in + . | .. | "$dir") break;; + *) dir="$parent";; + esac + done +done +true Property changes on: tool/rmdirs ___________________________________________________________________ Name: svn:eol-style + LF Name: svn:executable + * -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/