-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Creates a stage sandbox and sandbox dir cleaner step. #8339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,16 +30,18 @@ module Pod | |
# source control. | ||
# | ||
class Installer | ||
autoload :Analyzer, 'cocoapods/installer/analyzer' | ||
autoload :InstallationOptions, 'cocoapods/installer/installation_options' | ||
autoload :PostInstallHooksContext, 'cocoapods/installer/post_install_hooks_context' | ||
autoload :PreInstallHooksContext, 'cocoapods/installer/pre_install_hooks_context' | ||
autoload :SourceProviderHooksContext, 'cocoapods/installer/source_provider_hooks_context' | ||
autoload :PodfileValidator, 'cocoapods/installer/podfile_validator' | ||
autoload :PodSourceInstaller, 'cocoapods/installer/pod_source_installer' | ||
autoload :PodSourcePreparer, 'cocoapods/installer/pod_source_preparer' | ||
autoload :UserProjectIntegrator, 'cocoapods/installer/user_project_integrator' | ||
autoload :Xcode, 'cocoapods/installer/xcode' | ||
autoload :Analyzer, 'cocoapods/installer/analyzer' | ||
autoload :InstallationOptions, 'cocoapods/installer/installation_options' | ||
autoload :PostInstallHooksContext, 'cocoapods/installer/post_install_hooks_context' | ||
autoload :PreInstallHooksContext, 'cocoapods/installer/pre_install_hooks_context' | ||
autoload :SourceProviderHooksContext, 'cocoapods/installer/source_provider_hooks_context' | ||
autoload :PodfileValidator, 'cocoapods/installer/podfile_validator' | ||
autoload :PodSourceInstaller, 'cocoapods/installer/pod_source_installer' | ||
autoload :PodSourcePreparer, 'cocoapods/installer/pod_source_preparer' | ||
autoload :UserProjectIntegrator, 'cocoapods/installer/user_project_integrator' | ||
autoload :Xcode, 'cocoapods/installer/xcode' | ||
autoload :SandboxHeaderPathsInstaller, 'cocoapods/installer/sandbox_header_paths_installer' | ||
autoload :SandboxDirCleaner, 'cocoapods/installer/sandbox_dir_cleaner' | ||
|
||
include Config::Mixin | ||
|
||
|
@@ -171,7 +173,6 @@ def resolve_dependencies | |
UI.section 'Analyzing dependencies' do | ||
analyze(analyzer) | ||
validate_build_configurations | ||
clean_sandbox | ||
end | ||
|
||
UI.section 'Verifying no changes' do | ||
|
@@ -190,6 +191,20 @@ def download_dependencies | |
end | ||
end | ||
|
||
# Stages the sandbox after analysis. | ||
# | ||
# @param [Sandbox] sandbox | ||
# The sandbox to stage. | ||
# | ||
# @param [Array<PodTarget>] pod_targets | ||
# The list of all pod targets. | ||
# | ||
# @return [void] | ||
# | ||
def stage_sandbox(sandbox, pod_targets) | ||
SandboxHeaderPathsInstaller.new(sandbox, pod_targets).install! | ||
end | ||
|
||
#-------------------------------------------------------------------------# | ||
|
||
# @!group Pods Project Generation | ||
|
@@ -206,7 +221,15 @@ def create_generator(generate_multiple_pod_projects = false) | |
|
||
# Generates the Xcode project(s) that go inside the `Pods/` directory. | ||
# | ||
def generate_pods_project(generator = create_generator(installation_options.generate_multiple_pod_projects)) | ||
def generate_pods_project | ||
stage_sandbox(sandbox, pod_targets) | ||
clean_sandbox(pod_targets) | ||
create_and_save_projects | ||
write_lockfiles | ||
SandboxDirCleaner.new(sandbox, pod_targets, aggregate_targets).clean! | ||
end | ||
|
||
def create_and_save_projects(generator = create_generator(installation_options.generate_multiple_pod_projects)) | ||
UI.section 'Generating Pods project' do | ||
pod_project_generation_result = generator.generate! | ||
@target_installation_results = pod_project_generation_result.target_installation_results | ||
|
@@ -227,8 +250,6 @@ def generate_pods_project(generator = create_generator(installation_options.gene | |
all_projects_by_pod_targets.each do |project, pod_targets| | ||
generator.share_development_pod_schemes(project, development_pod_targets(pod_targets)) | ||
end | ||
|
||
write_lockfiles | ||
end | ||
end | ||
|
||
|
@@ -314,26 +335,15 @@ def validate_build_configurations | |
end | ||
end | ||
|
||
# @return [void] In this step we clean all the folders that will be | ||
# regenerated from scratch and any file which might not be | ||
# overwritten. | ||
# | ||
# @todo [#247] Clean the headers of only the pods to install. | ||
# @return [void] In this step we clean all the header folders for pod targets that will be | ||
# regenerated from scratch and cleanup any pods that have been removed. | ||
# | ||
def clean_sandbox | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. all the old functionality now seems to be replicated in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sets up incremental since |
||
sandbox.public_headers.implode! | ||
target_support_dirs = sandbox.target_support_files_root.children.select(&:directory?) | ||
def clean_sandbox(pod_targets) | ||
pod_targets.each do |pod_target| | ||
pod_target.build_headers.implode! | ||
target_support_dirs.delete(pod_target.support_files_dir) | ||
pod_target.build_headers.implode_path!(pod_target.headers_sandbox) | ||
sandbox.public_headers.implode_path!(pod_target.headers_sandbox) | ||
end | ||
|
||
aggregate_targets.each do |aggregate_target| | ||
target_support_dirs.delete(aggregate_target.support_files_dir) | ||
end | ||
|
||
target_support_dirs.each { |dir| FileUtils.rm_rf(dir) } | ||
|
||
unless sandbox_state.deleted.empty? | ||
title_options = { :verbose_prefix => '-> '.red } | ||
sandbox_state.deleted.each do |pod_name| | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
module Pod | ||
class Installer | ||
# Cleans up the sandbox directory by removing stale target support files and headers. | ||
# | ||
class SandboxDirCleaner | ||
# @return [Sandbox] The sandbox directory that will be cleaned. | ||
# | ||
attr_reader :sandbox | ||
|
||
# @return [Array<PodTarget>] | ||
# The list of all pod targets that will be installed into the Sandbox. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this correct or copy pasta? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct in that I wrote it :) The list of pod targets that will be installed are used to compute which folders need to be deleted. |
||
# | ||
attr_reader :pod_targets | ||
|
||
# @return [Array<AggregateTarget>] | ||
# The list of all aggregate targets that will be installed into the Sandbox. | ||
# | ||
attr_reader :aggregate_targets | ||
|
||
# Initialize a new instance | ||
# | ||
# @param [Sandbox] sandbox @see #sandbox | ||
# @param [Array<PodTarget>] pod_targets @see #pod_targets | ||
# @param [Array<AggregateTarget>] aggregate_targets @see #aggregate_targets | ||
# | ||
def initialize(sandbox, pod_targets, aggregate_targets) | ||
@sandbox = sandbox | ||
@pod_targets = pod_targets | ||
@aggregate_targets = aggregate_targets | ||
end | ||
|
||
def clean! | ||
UI.message('Cleaning up sandbox directory') do | ||
# Clean up Target Support Files Directory | ||
target_support_dirs_to_install = (pod_targets + aggregate_targets).map(&:support_files_dir) | ||
target_support_dirs = sandbox_target_support_dirs | ||
|
||
removed_target_support_dirs = target_support_dirs - target_support_dirs_to_install | ||
removed_target_support_dirs.each { |dir| remove_dir(dir) } | ||
|
||
# Clean up Sandbox Headers Directory | ||
sandbox_private_headers_to_install = pod_targets.flat_map do |pod_target| | ||
if pod_target.header_mappings_by_file_accessor.empty? | ||
[] | ||
else | ||
[pod_target.build_headers.root.join(pod_target.headers_sandbox)] | ||
end | ||
end | ||
sandbox_public_headers_to_install = pod_targets.flat_map do |pod_target| | ||
if pod_target.public_header_mappings_by_file_accessor.empty? | ||
[] | ||
else | ||
[sandbox.public_headers.root.join(pod_target.headers_sandbox)] | ||
end | ||
end | ||
|
||
removed_sandbox_public_headers = sandbox_public_headers - sandbox_public_headers_to_install | ||
removed_sandbox_public_headers.each { |path| remove_dir(path) } | ||
|
||
removed_sandbox_private_headers = sandbox_private_headers(pod_targets) - sandbox_private_headers_to_install | ||
removed_sandbox_private_headers.each { |path| remove_dir(path) } | ||
end | ||
end | ||
|
||
private | ||
|
||
def sandbox_target_support_dirs | ||
child_directories_of(sandbox.target_support_files_root) | ||
end | ||
|
||
def sandbox_private_headers(pod_targets) | ||
pod_targets.flat_map { |pod_target| child_directories_of(pod_target.build_headers.root) }.uniq | ||
end | ||
|
||
def sandbox_public_headers | ||
child_directories_of(sandbox.public_headers.root) | ||
end | ||
|
||
def child_directories_of(dir) | ||
return [] unless dir.exist? | ||
dir.children.select(&:directory?) | ||
end | ||
|
||
def remove_dir(path) | ||
FileUtils.rm_rf(path) | ||
end | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
module Pod | ||
class Installer | ||
# Adds all the search paths into the sandbox HeaderStore and each pod target's HeaderStore. | ||
# | ||
class SandboxHeaderPathsInstaller | ||
# @return [Sandbox] The sandbox to use for this analysis. | ||
sebastianv1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# | ||
attr_reader :sandbox | ||
|
||
# @return [Array<PodTarget>] The list of pod targets to analyze. | ||
# | ||
attr_reader :pod_targets | ||
|
||
# Initialize a new instance | ||
# | ||
# @param [Sandbox] sandbox @see #sandbox | ||
# @param [Array<PodTarget>] pod_targets @see #pod_targets | ||
# | ||
def initialize(sandbox, pod_targets) | ||
@pod_targets = pod_targets | ||
@sandbox = sandbox | ||
end | ||
|
||
def install! | ||
# Link all pod target header search paths into the HeaderStore. | ||
pod_targets.each do |pod_target| | ||
next if pod_target.build_as_framework? && pod_target.should_build? | ||
install_target(pod_target) | ||
end | ||
end | ||
|
||
private | ||
|
||
def install_target(pod_target) | ||
pod_target_header_mappings = pod_target.header_mappings_by_file_accessor.values | ||
public_header_mappings = pod_target.public_header_mappings_by_file_accessor.values | ||
added_build_headers = !pod_target_header_mappings.all?(&:empty?) | ||
added_public_headers = !public_header_mappings.all?(&:empty?) | ||
|
||
pod_target.build_headers.add_search_path(pod_target.headers_sandbox, pod_target.platform) if added_build_headers | ||
sandbox.public_headers.add_search_path(pod_target.headers_sandbox, pod_target.platform) if added_public_headers | ||
end | ||
end | ||
end | ||
end |
Uh oh!
There was an error while loading. Please reload this page.