Commit ac5f166c authored by Fabio Pelosin's avatar Fabio Pelosin Committed by Michele

Initial work for sandbox reorganization

parent c4fedc56
...@@ -134,7 +134,7 @@ module Pod ...@@ -134,7 +134,7 @@ module Pod
# #
def pre_download(sandbox) def pre_download(sandbox)
UI.titled_section("Pre-downloading: `#{name}` #{description}", { :verbose_prefix => "-> " }) do UI.titled_section("Pre-downloading: `#{name}` #{description}", { :verbose_prefix => "-> " }) do
target = sandbox.root + name target = sandbox.pod_dir(name)
target.rmtree if target.exist? target.rmtree if target.exist?
downloader = Downloader.for_target(target, params) downloader = Downloader.for_target(target, params)
downloader.cache_root = CACHE_ROOT.to_s downloader.cache_root = CACHE_ROOT.to_s
......
...@@ -30,6 +30,7 @@ module Pod ...@@ -30,6 +30,7 @@ module Pod
autoload :Analyzer, 'cocoapods/installer/analyzer' autoload :Analyzer, 'cocoapods/installer/analyzer'
autoload :FileReferencesInstaller, 'cocoapods/installer/file_references_installer' autoload :FileReferencesInstaller, 'cocoapods/installer/file_references_installer'
autoload :Migrator, 'cocoapods/installer/migrator'
autoload :PodSourceInstaller, 'cocoapods/installer/pod_source_installer' autoload :PodSourceInstaller, 'cocoapods/installer/pod_source_installer'
autoload :TargetInstaller, 'cocoapods/installer/target_installer' autoload :TargetInstaller, 'cocoapods/installer/target_installer'
autoload :UserProjectIntegrator, 'cocoapods/installer/user_project_integrator' autoload :UserProjectIntegrator, 'cocoapods/installer/user_project_integrator'
...@@ -81,12 +82,20 @@ module Pod ...@@ -81,12 +82,20 @@ module Pod
# @return [void] # @return [void]
# #
def install! def install!
migrate_installation_if_needed
resolve_dependencies resolve_dependencies
download_dependencies download_dependencies
generate_pods_project generate_pods_project
integrate_user_project if config.integrate_targets? integrate_user_project if config.integrate_targets?
end end
def migrate_installation_if_needed
UI.section "Performing existing installation migration" do
migrator = Migrator.new(lockfile.cocoapods_version, sandbox)
migrator.migrate!
end
end
def resolve_dependencies def resolve_dependencies
UI.section "Analyzing dependencies" do UI.section "Analyzing dependencies" do
analyze analyze
......
module Pod
class Installer
# Migrates installations performed by previous versions of CocoaPods.
#
class Migrator
#
#
attr_reader :installation_version
#
#
attr_reader :sandbox
#
#
def initialize(installation_version, sandbox)
@installation_version = installation_version
@sandbox = sandbox
end
#
#
def migrate!
migrate_to_0_20 if version_minor('0.20')
end
#-----------------------------------------------------------------------#
private
# @!group Migration Steps
def migrate_to_0_20
title_options = { :verbose_prefix => "-> ".green }
UI.titled_section("Migrating to CocoaPods 0.20".green, title_options) do
mkdir(sandbox.generated_dir_root)
mkdir(sandbox.headers_root)
mkdir(sandbox.sources_root)
sandbox.root.children.each do |child|
relative = child.relative_path_from(sandbox.root)
case relative.to_s
when 'Generated'
next
when 'BuildHeaders', 'Headers'
move(child, sandbox.headers_root + relative)
else
if child.directory? && child.extname != '.xcodeproj'
move(child, sandbox.sources_root + relative)
else
move(child, sandbox.generated_dir_root + relative)
end
end
end
end
end
#-----------------------------------------------------------------------#
private
# @!group Private helpers
def version_minor(target_version)
installation_version < Version.new(target_version)
end
def mkdir(path)
path.mkpath
end
def move(path, new_name)
path.rename(new_name)
end
#-----------------------------------------------------------------------#
end
end
end
...@@ -176,8 +176,8 @@ module Pod ...@@ -176,8 +176,8 @@ module Pod
generator.save_as(path) generator.save_as(path)
add_file_to_support_group(path) add_file_to_support_group(path)
relative_path = project.relativize(path)
target.build_configurations.each do |c| target.build_configurations.each do |c|
relative_path = path.relative_path_from(sandbox.root)
c.build_settings['GCC_PREFIX_HEADER'] = relative_path.to_s c.build_settings['GCC_PREFIX_HEADER'] = relative_path.to_s
end end
end end
...@@ -305,7 +305,7 @@ module Pod ...@@ -305,7 +305,7 @@ module Pod
# @return [PBXFileReference] the file reference of the added file. # @return [PBXFileReference] the file reference of the added file.
# #
def add_file_to_support_group(path) def add_file_to_support_group(path)
relative_path = path.relative_path_from(sandbox.root) relative_path = project.relativize(path)
support_files_group.new_file(relative_path) support_files_group.new_file(relative_path)
end end
......
...@@ -92,7 +92,7 @@ module Pod ...@@ -92,7 +92,7 @@ module Pod
# @return [void] # @return [void]
# #
def implode def implode
root.rmtree generated_dir_root.rmtree
end end
# Removes the files of the Pod with the given name from the sandbox. # Removes the files of the Pod with the given name from the sandbox.
...@@ -124,13 +124,13 @@ module Pod ...@@ -124,13 +124,13 @@ module Pod
# @return [Pathname] the path of the manifest. # @return [Pathname] the path of the manifest.
# #
def manifest_path def manifest_path
root + "Manifest.lock" generated_dir_root + "Manifest.lock"
end end
# @return [Pathname] the path of the Pods project. # @return [Pathname] the path of the Pods project.
# #
def project_path def project_path
root + "Pods.xcodeproj" generated_dir_root + "Pods.xcodeproj"
end end
# Returns the path for the directory where to store the support files of # Returns the path for the directory where to store the support files of
...@@ -143,7 +143,7 @@ module Pod ...@@ -143,7 +143,7 @@ module Pod
# #
def library_support_files_dir(name) def library_support_files_dir(name)
# root + "Target Support Files/#{name}" # root + "Target Support Files/#{name}"
root generated_dir_root
end end
# Returns the path where the Pod with the given name is stored, taking into # Returns the path where the Pod with the given name is stored, taking into
...@@ -159,17 +159,28 @@ module Pod ...@@ -159,17 +159,28 @@ module Pod
if local?(root_name) if local?(root_name)
Pathname.new(local_pods[root_name]) Pathname.new(local_pods[root_name])
else else
# root + "Sources/#{name}" sources_root + root_name
root + root_name
end end
end end
# @return [Pathname] the directory where to store the documentation. # @return [Pathname]
# #
def documentation_dir def generated_dir_root
root + 'Documentation' root + 'Generated'
end end
# @return [Pathname]
#
def headers_root
generated_dir_root + 'Headers'
end
def sources_root
generated_dir_root + 'Sources'
end
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
public public
...@@ -197,7 +208,7 @@ module Pod ...@@ -197,7 +208,7 @@ module Pod
# #
def specifications_dir(external_source = false) def specifications_dir(external_source = false)
# root + "Specifications" # root + "Specifications"
root + "Local Podspecs" generated_dir_root + "Local Podspecs"
end end
# Returns the path of the specification for the Pod with the # Returns the path of the specification for the Pod with the
......
...@@ -9,7 +9,7 @@ module Pod ...@@ -9,7 +9,7 @@ module Pod
# @return [Pathname] the absolute path of this header directory. # @return [Pathname] the absolute path of this header directory.
# #
def root def root
@sandbox.root + @relative_path sandbox.headers_root + @relative_path
end end
# @return [Sandbox] the sandbox where this header directory is stored. # @return [Sandbox] the sandbox where this header directory is stored.
...@@ -58,7 +58,8 @@ module Pod ...@@ -58,7 +58,8 @@ module Pod
# headers directory. # headers directory.
# #
# @param [Pathname] relative_header_path # @param [Pathname] relative_header_path
# the path of the header file relative to the sandbox. # the path of the header file relative to the Pods project
# (`PODS_ROOT` variable of the xcconfigs).
# #
# @note This method adds the files to the search paths. # @note This method adds the files to the search paths.
# #
...@@ -70,7 +71,7 @@ module Pod ...@@ -70,7 +71,7 @@ module Pod
namespaced_path.mkpath unless File.exist?(namespaced_path) namespaced_path.mkpath unless File.exist?(namespaced_path)
relative_header_paths.map do |relative_header_path| relative_header_paths.map do |relative_header_path|
source = (@sandbox.root + relative_header_path).relative_path_from(namespaced_path) source = (sandbox.root + relative_header_path).relative_path_from(namespaced_path)
Dir.chdir(namespaced_path) do Dir.chdir(namespaced_path) do
FileUtils.ln_sf(source, relative_header_path.basename) FileUtils.ln_sf(source, relative_header_path.basename)
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