move clean logic to Application
This commit is contained in:
1 parent
de46bb0cc1
commit
e29ec5a126
4 files changed
+48
-44
No files matched your search
@@ -57,25 +57,6 @@ module Rscons
|
||||
@application ||= Application.new
|
||||
end
|
||||
|
||||
# Remove all generated files.
|
||||
#
|
||||
# @return [void]
|
||||
def clean
|
||||
cache = Cache.instance
|
||||
# remove all built files
|
||||
cache.targets.each do |target|
|
||||
FileUtils.rm_f(target)
|
||||
end
|
||||
# remove all created directories if they are empty
|
||||
cache.directories.sort {|a, b| b.size <=> a.size}.each do |directory|
|
||||
next unless File.directory?(directory)
|
||||
if (Dir.entries(directory) - ['.', '..']).empty?
|
||||
Dir.rmdir(directory) rescue nil
|
||||
end
|
||||
end
|
||||
cache.clear
|
||||
end
|
||||
|
||||
# Return whether the given path is an absolute filesystem path.
|
||||
#
|
||||
# @param path [String] the path to examine.
|
||||
|
||||
@@ -29,11 +29,34 @@ module Rscons
|
||||
# Process exit code (0 on success).
|
||||
def run(operation)
|
||||
# TODO
|
||||
case operation
|
||||
when "clean"
|
||||
clean
|
||||
end
|
||||
0
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Remove all generated files.
|
||||
#
|
||||
# @return [void]
|
||||
def clean
|
||||
cache = Cache.instance
|
||||
# remove all built files
|
||||
cache.targets.each do |target|
|
||||
FileUtils.rm_f(target)
|
||||
end
|
||||
# remove all created directories if they are empty
|
||||
cache.directories.sort {|a, b| b.size <=> a.size}.each do |directory|
|
||||
next unless File.directory?(directory)
|
||||
if (Dir.entries(directory) - ['.', '..']).empty?
|
||||
Dir.rmdir(directory) rescue nil
|
||||
end
|
||||
end
|
||||
cache.clear
|
||||
end
|
||||
|
||||
# Determine the number of threads to use by default.
|
||||
#
|
||||
# @return [Integer]
|
||||
|
||||
Reference in new issue
Block a user