diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-01-28 09:23:03 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-01-28 09:23:03 +0000 |
commit | a21146a57503dcda22c6764afe6f67e9be5468ac (patch) | |
tree | 8423bddfe90ed6dedaea1d264bee0401f603fc7f | |
parent | 3658470310fb6095f27ef85226c7a8589e66be1e (diff) |
merges r21764 and r21765 from trunk into ruby_1_9_1.
* 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.
* common.mk (clean-extout): removes extout directory.
* 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.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@21833 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 32 | ||||
-rw-r--r-- | Makefile.in | 16 | ||||
-rw-r--r-- | common.mk | 15 | ||||
-rw-r--r-- | configure.in | 2 | ||||
-rw-r--r-- | lib/fileutils.rb | 15 | ||||
-rw-r--r-- | lib/mkmf.rb | 74 | ||||
-rw-r--r-- | lib/un.rb | 4 | ||||
-rwxr-xr-x | tool/rmdirs | 11 | ||||
-rw-r--r-- | win32/Makefile.sub | 28 | ||||
-rwxr-xr-x | win32/rm.bat | 11 | ||||
-rwxr-xr-x | win32/rmdirs.bat | 29 |
11 files changed, 195 insertions, 42 deletions
@@ -1,3 +1,35 @@ +Sun Jan 25 11:25:10 2009 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * 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 (clean-ext): skips non-existent + directories. + + * common.mk (clean, distclean): cleans rdoc. + + * common.mk (clean-extout): removes extout directory. + + * 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@ruby-lang.org> * dir.c (join_path): use strlcat() to force link. diff --git a/Makefile.in b/Makefile.in index 776c08d53f..f4a4f785db 100644 --- a/Makefile.in +++ b/Makefile.in @@ -4,6 +4,7 @@ NULLCMD = : #### Start of system configuration section. #### srcdir = @srcdir@ +top_srcdir = $(srcdir) hdrdir = $(srcdir)/include CC = @CC@ @@ -94,6 +95,7 @@ MAKEDIRS = @MAKEDIRS@ CP = cp MV = mv RM = rm -f +RMDIRS = @RMDIRS@ NM = @NM@ AR = @AR@ ARFLAGS = rcu @@ -219,8 +221,12 @@ clean-local:: distclean-local:: @$(RM) ext/config.cache $(RBCONFIG) - -$(RM) $(INSTALLED_LIST) $(arch_hdrdir)/ruby/config.h - -rmdir -p $(arch_hdrdir)/ruby + @-$(RM) run.gdb + @-$(RM) $(INSTALLED_LIST) $(arch_hdrdir)/ruby/config.h + @-$(RMDIRS) $(arch_hdrdir)/ruby + +distclean-rdoc: + @$(RMALL) $(RDOCOUT:/=\) clean-ext distclean-ext realclean-ext:: @set dummy ${EXTS}; shift; \ @@ -228,13 +234,13 @@ clean-ext distclean-ext realclean-ext:: 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 @@ -330,7 +330,7 @@ install-prereq: $(CLEAR_INSTALLED_LIST) 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-extout clean-local:: @$(RM) $(OBJS) $(MINIOBJS) $(MAINOBJ) $(LIBRUBY_A) $(LIBRUBY_SO) $(LIBRUBY) $(LIBRUBY_ALIASES) @$(RM) $(PROGRAM) $(WPROGRAM) miniruby$(EXEEXT) dmyext.$(OBJEXT) $(ARCHFILE) .*.time @@ -340,10 +340,13 @@ clean-enc: @-$(MAKE) -f $(ENC_MK) $(MFLAGS) clean clean-golf: @$(RM) $(GORUBY)$(EXEEXT) $(GOLFOBJS) +clean-rdoc: +clean-extout: + @-$(RMDIRS) $(EXTOUT)/$(arch) -distclean: distclean-ext distclean-local distclean-enc distclean-golf +distclean: distclean-ext distclean-local distclean-enc distclean-golf distclean-extout 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:: @@ -351,13 +354,17 @@ distclean-enc: clean-enc @-$(MAKE) -f $(ENC_MK) $(MFLAGS) distclean distclean-golf: clean-golf @$(RM) $(GOLFPRELUDES) +distclean-rdoc: +distclean-extout: clean-extout + @-$(RMDIRS) $(EXTOUT) -realclean:: realclean-ext realclean-local realclean-enc realclean-golf +realclean:: realclean-ext realclean-local realclean-enc realclean-golf realclean-extout realclean-local:: distclean-local @$(RM) parse.c parse.h lex.c newline.c revision.h realclean-ext:: realclean-enc:: distclean-enc realclean-golf: distclean-golf +realclean-extout: distclean-extout check: test test-all diff --git a/configure.in b/configure.in index f548204d5c..dbb2451a68 100644 --- a/configure.in +++ b/configure.in @@ -265,6 +265,8 @@ else 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 diff --git a/lib/fileutils.rb b/lib/fileutils.rb index 56fb19beb2..774c0dec8a 100644 --- a/lib/fileutils.rb +++ b/lib/fileutils.rb @@ -258,15 +258,24 @@ module FileUtils 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 diff --git a/lib/mkmf.rb b/lib/mkmf.rb index e3fd6ea619..1d46f6c299 100644 --- a/lib/mkmf.rb +++ b/lib/mkmf.rb @@ -1407,6 +1407,7 @@ ruby = #{$ruby} 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 @@ def create_makefile(target, srcprefix = nil) 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 @@ DEFFILE = #{deffile} CLEANFILES = #{$cleanfiles.join(' ')} DISTCLEANFILES = #{$distcleanfiles.join(' ')} +DISTCLEANDIRS = #{$distcleandirs.join(' ')} extout = #{$extout} extout_prefix = #{$extout_prefix} @@ -1652,6 +1655,18 @@ all: #{$extout ? "install" : target ? "$(DLLIB)" : "Makefile"} 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 @@ static: $(STATIC_LIB)#{$extout ? " install-rb" : ""} 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 @@ static: $(STATIC_LIB)#{$extout ? " install-rb" : ""} 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 @@ def init_mkmf(config = CONFIG) $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 @@ MAIN_DOES_NOTHING = config_string('MAIN_DOES_NOTHING') || 'int main() {return 0; 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 " @@ -158,11 +158,13 @@ end # # 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 diff --git a/tool/rmdirs b/tool/rmdirs new file mode 100755 index 0000000000..b116898fac --- /dev/null +++ b/tool/rmdirs @@ -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 diff --git a/win32/Makefile.sub b/win32/Makefile.sub index a71eeb90e1..e0021211ef 100644 --- a/win32/Makefile.sub +++ b/win32/Makefile.sub @@ -64,6 +64,7 @@ PURIFY = 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) @@ -571,6 +572,8 @@ s,@ARFLAGS@,$(ARFLAGS),;t t 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 @@ -705,18 +708,35 @@ clean-local:: @$(RM) $(RUBY_INSTALL_NAME).res $(RUBYW_INSTALL_NAME).res $(RUBY_SO_NAME).res @$(RM) *.map *.pdb *.ilk *.exp $(RUBYDEF) ext\ripper\y.output +clean: + @-rmdir $(EXTOUT:/=\)\$(arch) + 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 diff --git a/win32/rm.bat b/win32/rm.bat index eb415d67f9..83e3817287 100755 --- a/win32/rm.bat +++ b/win32/rm.bat @@ -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
diff --git a/win32/rmdirs.bat b/win32/rmdirs.bat new file mode 100755 index 0000000000..a8549cc125 --- /dev/null +++ b/win32/rmdirs.bat @@ -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
|