From f4721c599cd486dbf51cab47c2aa88a8e9ac10cf Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Mon, 9 Apr 2012 16:32:46 +0200 Subject: [PATCH] Don't shell out for :clean target --- Rakefile | 31 ++++++++++++++++++++----------- rake.d/helpers.rb | 1 + 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/Rakefile b/Rakefile index 33b776972..842364196 100644 --- a/Rakefile +++ b/Rakefile @@ -467,17 +467,26 @@ end # Cleaning tasks desc "Remove all compiled files" task :clean do - tools = $tools.collect { |name| "src/tools/#{name}" }.join " " - run <<-SHELL, :allow_failure => true - rm -f *.o */*.o */*/*.o */lib*.a */*/lib*.a */*/*.gch po/*.mo - */*.exe */*/*.exe */*/*.dll */*/*.dll.a doc/guide/*/*.hhk - src/info/ui/*.h src/info/*.moc.cpp src/common/*/*.o - src/mmg/*/*.o #{$applications.join(" ")} #{tools} - lib/libebml/src/*.o lib/libmatroska/src/*.o - lib/libebml/src/lib*.a lib/libmatroska/src/lib*.a - lib/pugixml/src/*.o lib/pugixml/src/lib*.a - SHELL - run "rm -rf #{$dependency_dir}", :allow_failure => true + puts " CLEAN" + + patterns = %w{ + src/**/*.o lib/**/*.o src/**/lib*.a lib/**/lib*.a src/**/*.gch + src/**/*.exe src/**/*.dll src/**/*.dll.a + src/**/*.moc.cpp src/info/ui/*.h src/mmg-qt/forms/*.h + po/*.mo doc/guide/**/*.hhk + } + patterns += $applications + $tools.collect { |name| "src/tools/#{name}" } + verbose = ENV['V'].to_bool + + patterns.collect { |pattern| FileList[pattern].to_a }.flatten.select { |file_name| File.exists? file_name }.each do |file_name| + puts " rm #{file_name}" if verbose + File.unlink file_name + end + + if Dir.exists? $dependency_dir + puts " rm -rf #{$dependency_dir}" if verbose + FileUtils.rm_rf $dependency_dir + end end namespace :clean do diff --git a/rake.d/helpers.rb b/rake.d/helpers.rb index d4b8190b9..0d90f9039 100644 --- a/rake.d/helpers.rb +++ b/rake.d/helpers.rb @@ -1,5 +1,6 @@ $use_tempfile_for_run = defined?(RUBY_PLATFORM) && /mingw/i.match(RUBY_PLATFORM) require "tempfile" +require "fileutils" if defined? Mutex $message_mutex = Mutex.new