From dab9bf686da7049882abc59a8e596215dd76b8f1 Mon Sep 17 00:00:00 2001 From: Satoshi Ohki Date: Wed, 11 Jan 2012 10:41:43 +0900 Subject: [PATCH] fixed bug of directory cleaning. prevents multiple times to clean the root directory of symlink headers. --- lib/cocoapods/config.rb | 4 +++ lib/cocoapods/installer.rb | 4 +++ lib/cocoapods/installer/target_installer.rb | 9 +------ spec/integration_spec.rb | 27 +++++++++++++++++++++ 4 files changed, 36 insertions(+), 8 deletions(-) diff --git a/lib/cocoapods/config.rb b/lib/cocoapods/config.rb index 66d21b3116..a1074a8fcf 100644 --- a/lib/cocoapods/config.rb +++ b/lib/cocoapods/config.rb @@ -40,6 +40,10 @@ def project_podfile @project_podfile end + def headers_symlink_root + @headers_symlink_root ||= "#{project_pods_root}/Headers" + end + # Returns the spec at the pat returned from `project_podfile`. def rootspec unless @rootspec diff --git a/lib/cocoapods/installer.rb b/lib/cocoapods/installer.rb index 3ebc7a5590..53c9c97093 100644 --- a/lib/cocoapods/installer.rb +++ b/lib/cocoapods/installer.rb @@ -72,6 +72,10 @@ def install! puts "Installing dependencies of: #{@podfile.defined_in_file}" if config.verbose? install_dependencies! root = config.project_pods_root + headers_symlink_root = config.headers_symlink_root + + # Clean old header symlinks + FileUtils.rm_r(headers_symlink_root, :secure => true) if File.exists?(headers_symlink_root) puts "Generating support files" unless config.silent? target_installers.each do |target_installer| diff --git a/lib/cocoapods/installer/target_installer.rb b/lib/cocoapods/installer/target_installer.rb index b772632125..37d1116fdb 100644 --- a/lib/cocoapods/installer/target_installer.rb +++ b/lib/cocoapods/installer/target_installer.rb @@ -61,18 +61,11 @@ def prefix_header_filename "#{@definition.lib_name}-prefix.pch" end - def headers_symlink_path_name - "#{config.project_pods_root}/Headers" - end - # TODO move xcconfig related code into the xcconfig method, like copy_resources_script and generate_bridge_support. def install! # First add the target to the project @target = @project.targets.new_static_library(@definition.lib_name) - # Clean old header symlinks - FileUtils.rm_r(headers_symlink_path_name, :secure => true) if File.exists?(headers_symlink_path_name) - header_search_paths = [] build_specifications.each do |spec| xcconfig.merge!(spec.xcconfig) @@ -82,7 +75,7 @@ def install! end # Symlink header files to Pods/Headers spec.copy_header_mappings.each do |header_dir, files| - target_dir = "#{headers_symlink_path_name}/#{header_dir}" + target_dir = "#{config.headers_symlink_root}/#{header_dir}" FileUtils.mkdir_p(target_dir) target_dir_real_path = Pathname.new(target_dir).realpath files.each do |file| diff --git a/spec/integration_spec.rb b/spec/integration_spec.rb index 371fd892b3..479c2ef51c 100644 --- a/spec/integration_spec.rb +++ b/spec/integration_spec.rb @@ -337,6 +337,33 @@ def should_successfully_perform(command) end end + it "should prevent duplication cleaning headers symlinks with multiple targets" do + Pod::Source.reset! + Pod::Spec::Set.reset! + + podfile = Pod::Podfile.new do + # first ensure that the correct info is available to the specs when they load + config.rootspec = self + self.platform platform + target(:debug) { dependency 'SSZipArchive' } + target(:test, :exclusive => true) { dependency 'JSONKit' } + dependency 'ASIHTTPRequest' + end + + installer = Pod::Installer.new(podfile) + installer.install! + + root = config.project_pods_root + (root + 'Pods.xcconfig').should.exist + (root + 'Headers').should.exist + (root + 'Headers/SSZipArchive').should.exist + (root + 'Headers/ASIHTTPRequest').should.exist + (root + 'Headers/JSONKit').should.exist + Pathname.glob(File.join(root.to_s, 'Headers/ASIHTTPRequest/*.h')).size.should.be > 0 + Pathname.glob(File.join(root.to_s, 'Headers/SSZipArchive/*.h')).size.should.be > 0 + Pathname.glob(File.join(root.to_s, 'Headers/JSONKit/*.h')).size.should.be > 0 + end + end end