1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21764 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2009-01-25 02:06:29 +00:00
parent 0506348ef5
commit 97de7d1081
11 changed files with 189 additions and 40 deletions

View file

@ -1,3 +1,36 @@
Sun Jan 25 11:07:51 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 (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@ruby-lang.org>
* dir.c (join_path): use strlcat() to force link.

View file

@ -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
@ -221,8 +223,15 @@ distclean-local::
@$(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; \
@ -230,13 +239,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

View file

@ -340,7 +340,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-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 @@ clean-enc:
@-$(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 @@ distclean-enc: clean-enc
@-$(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

View file

@ -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

View file

@ -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

View file

@ -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
"

View file

@ -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

11
tool/rmdirs Executable file
View file

@ -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

View file

@ -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)
@ -575,6 +576,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
@ -712,15 +715,29 @@ clean-local::
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

View file

@ -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

29
win32/rmdirs.bat Executable file
View file

@ -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