Commit 8a7f3a2c authored by Fabio Pelosin's avatar Fabio Pelosin

[SandboxAnalyzer] Detect pre-downloaded Pods

parent 0e0523fc
...@@ -36,13 +36,6 @@ module Pod ...@@ -36,13 +36,6 @@ module Pod
library.target_definition library.target_definition
end end
# @return [PBXNativeTarget] The target generated by the installation
# process.
#
def target
library.target
end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
public public
...@@ -58,6 +51,13 @@ module Pod ...@@ -58,6 +51,13 @@ module Pod
# #
attr_reader :library attr_reader :library
# @return [PBXNativeTarget] The target generated by the installation
# process.
#
def target
library.target
end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
# @!group Private implementation # @!group Private implementation
......
...@@ -90,7 +90,6 @@ module Pod ...@@ -90,7 +90,6 @@ module Pod
def resolve_dependencies def resolve_dependencies
UI.section "Analyzing dependencies" do UI.section "Analyzing dependencies" do
analyze analyze
detect_pods_to_install
prepare_for_legacy_compatibility prepare_for_legacy_compatibility
clean_sandbox clean_sandbox
end end
...@@ -158,28 +157,6 @@ module Pod ...@@ -158,28 +157,6 @@ module Pod
@libraries = analyzer.result.libraries @libraries = analyzer.result.libraries
end end
# Computes the list of the Pods that should be installed or reinstalled in
# the {Sandbox}.
#
# The pods to install are identified as the Pods that don't exist in the
# sandbox or the Pods whose version differs from the one of the lockfile.
#
# @note In update mode specs originating from external dependencies and
# or from head sources are always reinstalled.
#
# @return [void]
#
# @todo [#534] Detect if the folder of a Pod is empty (even if it exits).
#
def detect_pods_to_install
names = []
names += analysis_result.sandbox_state.added + analysis_result.sandbox_state.changed
names += sandbox.predownloaded_pods
names = names.map { |name| Specification.root_name(name) }
names = names.flatten.uniq
@names_of_pods_to_install = names
end
# Prepares the Pods folder in order to be compatible with the most recent # Prepares the Pods folder in order to be compatible with the most recent
# version of CocoaPods. # version of CocoaPods.
# #
...@@ -201,9 +178,9 @@ module Pod ...@@ -201,9 +178,9 @@ module Pod
sandbox.build_headers.implode! sandbox.build_headers.implode!
sandbox.public_headers.implode! sandbox.public_headers.implode!
unless analysis_result.sandbox_state.deleted.empty? unless sandbox_state.deleted.empty?
title_options = { :verbose_prefix => "-> ".red } title_options = { :verbose_prefix => "-> ".red }
analysis_result.sandbox_state.deleted.each do |pod_name| sandbox_state.deleted.each do |pod_name|
UI.titled_section("Removing #{pod_name}".red, title_options) do UI.titled_section("Removing #{pod_name}".red, title_options) do
sandbox.clean_pod(pod_name) sandbox.clean_pod(pod_name)
end end
...@@ -233,9 +210,10 @@ module Pod ...@@ -233,9 +210,10 @@ module Pod
# #
def install_pod_sources def install_pod_sources
@installed_specs = [] @installed_specs = []
pods_to_install = sandbox_state.added | sandbox_state.changed
title_options = { :verbose_prefix => "-> ".green } title_options = { :verbose_prefix => "-> ".green }
root_specs.sort_by(&:name).each do |spec| root_specs.sort_by(&:name).each do |spec|
if names_of_pods_to_install.include?(spec.name) if pods_to_install.include?(spec.name)
UI.titled_section("Installing #{spec}".green, title_options) do UI.titled_section("Installing #{spec}".green, title_options) do
install_source_of_pod(spec.name) install_source_of_pod(spec.name)
end end
...@@ -477,6 +455,12 @@ module Pod ...@@ -477,6 +455,12 @@ module Pod
analysis_result.specifications.map { |spec| spec.root }.uniq analysis_result.specifications.map { |spec| spec.root }.uniq
end end
# @return [SpecsState] The state of the sandbox returned by the analyzer.
#
def sandbox_state
analysis_result.sandbox_state
end
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
end end
......
...@@ -18,6 +18,7 @@ module Pod ...@@ -18,6 +18,7 @@ module Pod
# - The specification is in head mode or from an external source and the # - The specification is in head mode or from an external source and the
# installation process is in update mode. # installation process is in update mode.
# - The directory of the Pod is empty. # - The directory of the Pod is empty.
# - The Pod has been pre-downloaded.
# #
# Removed # Removed
# - If a specification is present in the lockfile but not in the resolved # - If a specification is present in the lockfile but not in the resolved
...@@ -147,6 +148,7 @@ module Pod ...@@ -147,6 +148,7 @@ module Pod
return true if spec.version != sandbox_version(pod) return true if spec.version != sandbox_version(pod)
return true if spec.checksum != sandbox_checksum(pod) return true if spec.checksum != sandbox_checksum(pod)
return true if resolved_spec_names(pod) != sandbox_spec_names(pod) return true if resolved_spec_names(pod) != sandbox_spec_names(pod)
return true if sandbox.predownloaded?(pod)
return true if folder_empty?(pod) return true if folder_empty?(pod)
if update_mode if update_mode
return true if spec.version.head? return true if spec.version.head?
......
...@@ -53,7 +53,7 @@ module Pod ...@@ -53,7 +53,7 @@ module Pod
absolute_paths = paths.reject { |p| p == "#{root}/." || p == "#{root}/.." } absolute_paths = paths.reject { |p| p == "#{root}/." || p == "#{root}/.." }
relative_paths = absolute_paths.map { |p| p[root_length..-1] } relative_paths = absolute_paths.map { |p| p[root_length..-1] }
@files = relative_paths - relative_dirs @files = relative_paths - relative_dirs
@dirs = relative_dirs.map { |d| d.gsub(/\/\.\.?$/,'') }.uniq @dirs = relative_dirs.map { |d| d.gsub(/\/\.\.?$/,'') }.reject { |d| d == '.' || d == '..' } .uniq
end end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
......
...@@ -83,6 +83,11 @@ module Pod ...@@ -83,6 +83,11 @@ module Pod
@analyzer.send(:pod_changed?, 'BananaLib').should == true @analyzer.send(:pod_changed?, 'BananaLib').should == true
end end
it "considers changed a Pod which has been pre-downloaded" do
@sandbox.stubs(:predownloaded?).returns(true)
@analyzer.send(:pod_changed?, 'BananaLib').should == true
end
it "considers changed a Pod whose specification is in head mode if in update mode" do it "considers changed a Pod whose specification is in head mode if in update mode" do
@spec.version.head = true @spec.version.head = true
@analyzer.stubs(:update_mode).returns(true) @analyzer.stubs(:update_mode).returns(true)
......
...@@ -117,39 +117,6 @@ module Pod ...@@ -117,39 +117,6 @@ module Pod
#--------------------------------------# #--------------------------------------#
describe "#detect_pods_to_install" do
before do
@analysis_result = Installer::Analyzer::AnalysisResult.new
@analysis_result.specifications = []
@analysis_result.sandbox_state = Installer::Analyzer::SpecsState.new()
@installer.stubs(:analysis_result).returns(@analysis_result)
Pathname.any_instance.stubs(:exist?).returns(true)
end
it "includes the added Pods" do
@analysis_result.sandbox_state.add_name('added-pod', :added)
@installer.send(:detect_pods_to_install)
@installer.names_of_pods_to_install.should == ['added-pod']
end
it "includes the changed Pods" do
@analysis_result.sandbox_state.add_name('changed-pod', :changed)
@installer.send(:detect_pods_to_install)
@installer.names_of_pods_to_install.should == ['changed-pod']
end
it "includes the pre-downloaded Pods" do
@analysis_result.sandbox_state.add_name('unchanged-pods', :unchanged)
config.sandbox.stubs(:predownloaded_pods).returns(['pre-downloaded-pod'])
@installer.send(:detect_pods_to_install)
@installer.names_of_pods_to_install.should == ['pre-downloaded-pod']
end
end
#--------------------------------------#
describe "#clean_sandbox" do describe "#clean_sandbox" do
before do before do
...@@ -183,9 +150,15 @@ module Pod ...@@ -183,9 +150,15 @@ module Pod
it "installs all the Pods which are marked as needing installation" do it "installs all the Pods which are marked as needing installation" do
spec = fixture_spec('banana-lib/BananaLib.podspec') spec = fixture_spec('banana-lib/BananaLib.podspec')
@installer.stubs(:root_specs).returns([spec]) spec_2 = Spec.new
@installer.stubs(:names_of_pods_to_install).returns(['BananaLib']) spec_2.name = 'RestKit'
@installer.stubs(:root_specs).returns([spec, spec_2])
sandbox_state = Installer::Analyzer::SpecsState.new
sandbox_state.added << 'BananaLib'
sandbox_state.changed << 'RestKit'
@installer.stubs(:sandbox_state).returns(sandbox_state)
@installer.expects(:install_source_of_pod).with('BananaLib') @installer.expects(:install_source_of_pod).with('BananaLib')
@installer.expects(:install_source_of_pod).with('RestKit')
@installer.send(:install_pod_sources) @installer.send(:install_pod_sources)
end end
......
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