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
#
def pre_download(sandbox)
UI.titled_section("Pre-downloading: `#{name}` #{description}", { :verbose_prefix => "-> " }) do
target = sandbox.root + name
target = sandbox.pod_dir(name)
target.rmtree if target.exist?
downloader = Downloader.for_target(target, params)
downloader.cache_root = CACHE_ROOT.to_s
......
......@@ -30,6 +30,7 @@ module Pod
autoload :Analyzer, 'cocoapods/installer/analyzer'
autoload :FileReferencesInstaller, 'cocoapods/installer/file_references_installer'
autoload :Migrator, 'cocoapods/installer/migrator'
autoload :PodSourceInstaller, 'cocoapods/installer/pod_source_installer'
autoload :TargetInstaller, 'cocoapods/installer/target_installer'
autoload :UserProjectIntegrator, 'cocoapods/installer/user_project_integrator'
......@@ -81,12 +82,20 @@ module Pod
# @return [void]
#
def install!
migrate_installation_if_needed
resolve_dependencies
download_dependencies
generate_pods_project
integrate_user_project if config.integrate_targets?
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
UI.section "Analyzing dependencies" do
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
generator.save_as(path)
add_file_to_support_group(path)
relative_path = project.relativize(path)
target.build_configurations.each do |c|
relative_path = path.relative_path_from(sandbox.root)
c.build_settings['GCC_PREFIX_HEADER'] = relative_path.to_s
end
end
......@@ -305,7 +305,7 @@ module Pod
# @return [PBXFileReference] the file reference of the added file.
#
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)
end
......
......@@ -92,7 +92,7 @@ module Pod
# @return [void]
#
def implode
root.rmtree
generated_dir_root.rmtree
end
# Removes the files of the Pod with the given name from the sandbox.
......@@ -124,13 +124,13 @@ module Pod
# @return [Pathname] the path of the manifest.
#
def manifest_path
root + "Manifest.lock"
generated_dir_root + "Manifest.lock"
end
# @return [Pathname] the path of the Pods project.
#
def project_path
root + "Pods.xcodeproj"
generated_dir_root + "Pods.xcodeproj"
end
# Returns the path for the directory where to store the support files of
......@@ -143,7 +143,7 @@ module Pod
#
def library_support_files_dir(name)
# root + "Target Support Files/#{name}"
root
generated_dir_root
end
# Returns the path where the Pod with the given name is stored, taking into
......@@ -159,17 +159,28 @@ module Pod
if local?(root_name)
Pathname.new(local_pods[root_name])
else
# root + "Sources/#{name}"
root + root_name
sources_root + root_name
end
end
# @return [Pathname] the directory where to store the documentation.
# @return [Pathname]
#
def documentation_dir
root + 'Documentation'
def generated_dir_root
root + 'Generated'
end
# @return [Pathname]
#
def headers_root
generated_dir_root + 'Headers'
end
def sources_root
generated_dir_root + 'Sources'
end
#-------------------------------------------------------------------------#
public
......@@ -197,7 +208,7 @@ module Pod
#
def specifications_dir(external_source = false)
# root + "Specifications"
root + "Local Podspecs"
generated_dir_root + "Local Podspecs"
end
# Returns the path of the specification for the Pod with the
......
......@@ -9,7 +9,7 @@ module Pod
# @return [Pathname] the absolute path of this header directory.
#
def root
@sandbox.root + @relative_path
sandbox.headers_root + @relative_path
end
# @return [Sandbox] the sandbox where this header directory is stored.
......@@ -58,7 +58,8 @@ module Pod
# headers directory.
#
# @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.
#
......@@ -70,7 +71,7 @@ module Pod
namespaced_path.mkpath unless File.exist?(namespaced_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
FileUtils.ln_sf(source, relative_header_path.basename)
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