Commit 1d7b4e76 authored by Fabio Pelosin's avatar Fabio Pelosin

[LocalPod] Clean all the unused files.

parent b568f82b
...@@ -42,7 +42,7 @@ module Pod ...@@ -42,7 +42,7 @@ module Pod
end end
def files def files
@pod.absolute_source_files.map(&:to_s) @pod.source_files(false).map(&:to_s)
end end
def index_file def index_file
......
...@@ -57,7 +57,7 @@ module Pod ...@@ -57,7 +57,7 @@ module Pod
downloader = Downloader.for_pod(pod) downloader = Downloader.for_pod(pod)
downloader.download downloader.download
if config.clean if config.clean
downloader.clean # downloader.clean
pod.clean pod.clean
end end
end end
......
...@@ -8,7 +8,7 @@ module Pod ...@@ -8,7 +8,7 @@ module Pod
def initialize(specification, sandbox, platform) def initialize(specification, sandbox, platform)
@top_specification, @sandbox = specification, sandbox @top_specification, @sandbox = specification, sandbox
@top_specification.activate_platform(platform) @top_specification.activate_platform(platform)
@specifications = [] << specification @specifications = []
end end
def self.from_podspec(podspec, sandbox, platform) def self.from_podspec(podspec, sandbox, platform)
...@@ -32,7 +32,7 @@ module Pod ...@@ -32,7 +32,7 @@ module Pod
def to_s def to_s
result = top_specification.to_s result = top_specification.to_s
# result << " [LOCAL]" if top_specification.local? result << " [LOCAL]" if top_specification.local?
result result
end end
...@@ -62,8 +62,14 @@ module Pod ...@@ -62,8 +62,14 @@ module Pod
end end
def clean def clean
# TODO: nuke everything that is not used clean_paths.each { |path| FileUtils.rm_rf(path) }
# clean_paths.each { |path| FileUtils.rm_rf(path) }
# remove empty diretories
Dir.glob("#{root}/**/{*,.*}").
sort_by(&:length).reverse. # Clean the deepest paths first
reject { |d| d =~ /\/\.\.?$/ }. # Remove the `.` and `..` paths
select { |d| File.directory? d }. # Get only directories
each { |d| Dir.rmdir d if (Dir.entries(d) == %w[ . .. ]) } # Remove the paths only if it is empty
end end
def prefix_header_file def prefix_header_file
...@@ -72,23 +78,34 @@ module Pod ...@@ -72,23 +78,34 @@ module Pod
end end
end end
def source_files def source_files(relative = true)
chained_expanded_paths(:source_files, :glob => '*.{h,m,mm,c,cpp}', :relative_to_sandbox => true) chained_expanded_paths(:source_files, :glob => '*.{h,m,mm,c,cpp}', :relative_to_sandbox => relative)
end end
def absolute_source_files def resources(relative = true)
chained_expanded_paths(:source_files, :glob => '*.{h,m,mm,c,cpp}') chained_expanded_paths(:resources, :relative_to_sandbox => relative)
end end
def clean_paths def clean_paths
# TODO: delete paths = expanded_paths('**/*').reject {|p| p.directory? }
# chained_expanded_paths(:clean_paths) # TODO: deprecate Specification#clean_paths
paths = @top_specification.clean_paths unless @top_specification.clean_paths.empty?
paths - used_files
end
def used_files
source_files(false) + resources(false) + readme_file + license_file + [prefix_header_file]
end
def readme_file
expanded_paths('README.*')
end end
def resources def license_file
chained_expanded_paths(:resources, :relative_to_sandbox => true) expanded_paths(%w[ LICENSE licence.txt ])
end end
def header_files def header_files
source_files.select { |f| f.extname == '.h' } source_files.select { |f| f.extname == '.h' }
end end
...@@ -99,15 +116,6 @@ module Pod ...@@ -99,15 +116,6 @@ module Pod
end end
end end
def readme_file
expanded_paths('README.*', options = {})
end
def license
#TODO: merge with the work of will and return the text
expanded_paths(%w[ LICENSE licence.txt ], options = {})
end
def add_to_target(target) def add_to_target(target)
implementation_files.each do |file| implementation_files.each do |file|
target.add_source_file(file, nil, specification.compiler_flags.strip) target.add_source_file(file, nil, specification.compiler_flags.strip)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment