Skip to content

Commit

Permalink
[Installer] Call per install hooks before cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiopelosin committed Feb 28, 2013
1 parent c9105e1 commit 57ec464
Show file tree
Hide file tree
Showing 36 changed files with 149 additions and 68 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -4,6 +4,7 @@

###### Bug fixes

- Pre install hooks are called before the Pods are cleaned.
- Fixed and issue which prevent the inclusion of OTHER_CFLAGS and
OTHER_CPLUSPLUSFLAGS in the release builds of the Pods project.

Expand Down
2 changes: 2 additions & 0 deletions lib/cocoapods/hooks/installer_representation.rb
Expand Up @@ -26,6 +26,8 @@ def sandbox_root

# @return [Pod::Project] the `Pods/Pods.xcodeproj` project.
#
# @note This value is not yet set in the pre install callbacks.
#
def project
installer.pods_project
end
Expand Down
6 changes: 6 additions & 0 deletions lib/cocoapods/hooks/library_representation.rb
Expand Up @@ -18,6 +18,12 @@ def dependencies
target_definition.dependencies
end

# @return [Pathname] The path of the Pods dir.
#
def sandbox_dir
sandbox.root
end

# @return [Pathname] The path of the prefix_header
#
def prefix_header_filename
Expand Down
12 changes: 11 additions & 1 deletion lib/cocoapods/installer.rb
Expand Up @@ -99,13 +99,14 @@ def download_dependencies
UI.section "Downloading dependencies" do
create_file_accessors
install_pod_sources
run_pre_install_hooks
clean_pod_sources
end
end

def generate_pods_project
UI.section "Generating Pods project" do
prepare_pods_project
run_pre_install_hooks
install_file_references
install_targets
run_post_install_hooks
Expand Down Expand Up @@ -240,15 +241,24 @@ def install_source_of_pod(pod_name)
end
end

@pod_installers ||= []
pod_installer = PodSourceInstaller.new(sandbox, specs_by_platform)
pod_installer.clean = config.clean?
pod_installer.aggressive_cache = config.aggressive_cache?
pod_installer.generate_docs = config.generate_docs?
pod_installer.install_docs = config.install_docs?
pod_installer.install!
@pod_installers << pod_installer
@installed_specs.concat(specs_by_platform.values.flatten)
end

def clean_pod_sources
return unless @pod_installers
@pod_installers.each do |pod_installer|
pod_installer.clean!
end
end

# Creates the Pods project from scratch if it doesn't exists.
#
# @return [void]
Expand Down
10 changes: 10 additions & 0 deletions lib/cocoapods/installer/pod_source_installer.rb
Expand Up @@ -82,6 +82,16 @@ def inspect
def install!
download_source unless predownloaded? || local?
generate_docs if generate_docs?
end

# Cleans the installations if appropriate.
#
# @todo As the pre install hooks need to run before cleaning this
# method should be refactored.
#
# @return [void]
#
def clean!
clean_installation if clean? && !local?
end

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -32,10 +32,10 @@ Downloading dependencies
Switched to a new branch 'activated-pod-commit'

-> Using Reachability (3.1.0)
- Running pre install hooks

Generating Pods project
- Creating Pods project
- Running pre install hooks
- Adding source files to Pods project
- Adding resources to Pods project
- Linking headers
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -20,10 +20,10 @@ Comparing resolved specification to the sandbox manifest
Downloading dependencies

-> Installing PodTest (1.0)
- Running pre install hooks

Generating Pods project
- Creating Pods project
- Running pre install hooks
- Adding source files to Pods project
- Adding resources to Pods project
- Linking headers
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -14,10 +14,10 @@ Comparing resolved specification to the sandbox manifest
Downloading dependencies

-> Installing Reachability (3.1.0)
- Running pre install hooks

Generating Pods project
- Creating Pods project
- Running pre install hooks
- Adding source files to Pods project
- Adding resources to Pods project
- Linking headers
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -50,10 +50,10 @@ Downloading dependencies
HEAD is now at f7176f4 updated podspec
$ /usr/bin/git checkout -b activated-pod-commit 2>&1
Switched to a new branch 'activated-pod-commit'
- Running pre install hooks

Generating Pods project
- Creating Pods project
- Running pre install hooks
- Adding source files to Pods project
- Adding resources to Pods project
- Linking headers
Expand Down
8 changes: 6 additions & 2 deletions spec/integration/install_new/after/Pods/Pods.xcodeproj.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion spec/integration/install_new/after/execution_output.txt
Expand Up @@ -29,10 +29,10 @@ Downloading dependencies
HEAD is now at f7176f4 updated podspec
$ /usr/bin/git checkout -b activated-pod-commit 2>&1
Switched to a new branch 'activated-pod-commit'
- Running pre install hooks

Generating Pods project
- Creating Pods project
- Running pre install hooks
- Adding source files to Pods project
- Adding resources to Pods project
- Linking headers
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -29,11 +29,11 @@ Downloading dependencies
HEAD is now at f7176f4 updated podspec
$ /usr/bin/git checkout -b activated-pod-commit 2>&1
Switched to a new branch 'activated-pod-commit'
- Running pre install hooks
- Podfile

Generating Pods project
- Creating Pods project
- Running pre install hooks
- Podfile
- Adding source files to Pods project
- Adding resources to Pods project
- Linking headers
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -32,10 +32,10 @@ Downloading dependencies
HEAD is now at f7176f4 updated podspec
$ /usr/bin/git checkout -b activated-pod-commit 2>&1
Switched to a new branch 'activated-pod-commit'
- Running pre install hooks

Generating Pods project
- Creating Pods project
- Running pre install hooks
- Adding source files to Pods project
- Adding resources to Pods project
- Linking headers
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 57ec464

Please sign in to comment.