class Pod::Installer::PodSourceInstaller

Public Instance Methods

install_for_prebuild!(standard_sanbox) click to toggle source
# File lib/cocoapods-hd/Integration.rb, line 21
def install_for_prebuild!(standard_sanbox)
  return if standard_sanbox.local? self.name

  # make a symlink to target folder
  prebuild_sandbox = Pod::PrebuildSandbox.from_standard_sandbox(standard_sanbox)
  # if spec used in multiple platforms, it may return multiple paths
  target_names = prebuild_sandbox.existed_target_names_for_pod_name(self.name)

  def walk(path, &action)
    return unless path.exist?
    path.children.each do |child|
      result = action.call(child, &action)
      if child.directory?
        walk(child, &action) if result
      end
    end
  end

  def make_link(source, target)
    source = Pathname.new(source)
    target = Pathname.new(target)
    target.parent.mkpath unless target.parent.exist?
    relative_source = source.relative_path_from(target.parent)
    FileUtils.ln_sf(relative_source, target)
  end

  def mirror_with_symlink(source, basefolder, target_folder)
    target = target_folder + source.relative_path_from(basefolder)
    make_link(source, target)
  end

  target_names.each do |name|

    # symbol link copy all substructure
    real_file_folder = prebuild_sandbox.framework_folder_path_for_target_name(name)

    # If have only one platform, just place int the root folder of this pod.
    # If have multiple paths, we use a sperated folder to store different
    # platform frameworks. e.g. AFNetworking/AFNetworking-iOS/AFNetworking.framework

    target_folder = standard_sanbox.pod_dir(self.name)
    if target_names.count > 1
      target_folder += real_file_folder.basename
    end
    target_folder.rmtree if target_folder.exist?
    target_folder.mkpath

    walk(real_file_folder) do |child|
      source = child
      # only make symlink to file and `.framework` folder
      if child.directory? and [".framework", ".dSYM"].include? child.extname
        mirror_with_symlink(source, real_file_folder, target_folder)
        next false # return false means don't go deeper
      elsif child.file?
        mirror_with_symlink(source, real_file_folder, target_folder)
        next true
      else
        next true
      end
    end

    # symbol link copy resource for static framework
    hash = Prebuild::Passer.resources_to_copy_for_static_framework || {}

    path_objects = hash[name]
    if path_objects != nil
      path_objects.each do |object|
        make_link(object.real_file_path, object.target_file_path)
      end
    end
  end # of for each

end
walk(path, &action) click to toggle source
# File lib/cocoapods-hd/Integration.rb, line 29
def walk(path, &action)
  return unless path.exist?
  path.children.each do |child|
    result = action.call(child, &action)
    if child.directory?
      walk(child, &action) if result
    end
  end
end