Commit 44e3dab4 authored by Kyle Fuller's avatar Kyle Fuller

Merge branch 'issue/2145'

parents 8343cf2d 4a550710
...@@ -37,6 +37,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ...@@ -37,6 +37,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
[Samuel Giddins](https://github.com/segiddins) [Samuel Giddins](https://github.com/segiddins)
[#2914](https://github.com/CocoaPods/CocoaPods/issues/2914) [#2914](https://github.com/CocoaPods/CocoaPods/issues/2914)
* Installer changed to organize a development pod's source and resource files
into subgroups reflecting their organization in the filesystem.
[Imre mihaly](https://github.com/imihaly)
##### Bug Fixes ##### Bug Fixes
* Fix updating a pod that has subspec dependencies. * Fix updating a pod that has subspec dependencies.
......
...@@ -67,7 +67,7 @@ module Pod ...@@ -67,7 +67,7 @@ module Pod
# #
def add_source_files_references def add_source_files_references
UI.message '- Adding source files to Pods project' do UI.message '- Adding source files to Pods project' do
add_file_accessors_paths_to_pods_group(:source_files) add_file_accessors_paths_to_pods_group(:source_files, nil, true)
end end
end end
...@@ -100,8 +100,8 @@ module Pod ...@@ -100,8 +100,8 @@ module Pod
# #
def add_resources def add_resources
UI.message '- Adding resources to Pods project' do UI.message '- Adding resources to Pods project' do
add_file_accessors_paths_to_pods_group(:resources, :resources) add_file_accessors_paths_to_pods_group(:resources, :resources, true)
add_file_accessors_paths_to_pods_group(:resource_bundle_files, :resources) add_file_accessors_paths_to_pods_group(:resource_bundle_files, :resources, true)
end end
end end
...@@ -152,14 +152,20 @@ module Pod ...@@ -152,14 +152,20 @@ module Pod
# @param [Symbol] group_key # @param [Symbol] group_key
# The key of the group of the Pods project. # The key of the group of the Pods project.
# #
# @param [Bool] reflect_file_system_structure_for_development
# Wether organizing the a local pod's files in subgroups inside
# the pod's group is allowed.
#
# @return [void] # @return [void]
# #
def add_file_accessors_paths_to_pods_group(file_accessor_key, group_key = nil) def add_file_accessors_paths_to_pods_group(file_accessor_key, group_key = nil, reflect_file_system_structure_for_development = false)
file_accessors.each do |file_accessor| file_accessors.each do |file_accessor|
pod_name = file_accessor.spec.name
local = sandbox.local?(pod_name)
paths = file_accessor.send(file_accessor_key) paths = file_accessor.send(file_accessor_key)
paths.each do |path| paths.each do |path|
group = pods_project.group_for_spec(file_accessor.spec.name, group_key) group = pods_project.group_for_spec(file_accessor.spec.name, group_key)
pods_project.add_file_reference(path, group) pods_project.add_file_reference(path, group, local && reflect_file_system_structure_for_development)
end end
end end
end end
......
...@@ -59,6 +59,7 @@ module Pod ...@@ -59,6 +59,7 @@ module Pod
parent_group = development ? development_pods : pods parent_group = development ? development_pods : pods
source_tree = absolute ? :absolute : :group source_tree = absolute ? :absolute : :group
group = parent_group.new_group(pod_name, path, source_tree) group = parent_group.new_group(pod_name, path, source_tree)
group group
end end
...@@ -144,13 +145,28 @@ module Pod ...@@ -144,13 +145,28 @@ module Pod
# @param [PBXGroup] group # @param [PBXGroup] group
# The group for the new file reference. # The group for the new file reference.
# #
# @param [Bool] reflect_file_system_structure
# Wether group structure should reflect the file system structure.
# If yes, where needed, intermediate groups are created, similar to
# how mkdir -p operates.
#
# @return [PBXFileReference] The new file reference. # @return [PBXFileReference] The new file reference.
# #
def add_file_reference(absolute_path, group) def add_file_reference(absolute_path, group, reflect_file_system_structure = false)
unless Pathname.new(absolute_path).absolute? file_path_name = Pathname.new(absolute_path)
unless file_path_name.absolute?
raise ArgumentError, "Paths must be absolute #{absolute_path}" raise ArgumentError, "Paths must be absolute #{absolute_path}"
end end
if reflect_file_system_structure
relative_path = file_path_name.relative_path_from(group.real_path)
relative_dir = relative_path.dirname
relative_dir.each_filename do|name|
next if name == '.'
group = group[name] || group.new_group(name, name)
end
end
if ref = reference_for_path(absolute_path) if ref = reference_for_path(absolute_path)
ref ref
else else
......
...@@ -161,6 +161,7 @@ module Pod ...@@ -161,6 +161,7 @@ module Pod
before do before do
@project.add_pod_group('BananaLib', config.sandbox.pod_dir('BananaLib'), false) @project.add_pod_group('BananaLib', config.sandbox.pod_dir('BananaLib'), false)
@file = config.sandbox.pod_dir('BananaLib') + 'file.m' @file = config.sandbox.pod_dir('BananaLib') + 'file.m'
@nested_file = config.sandbox.pod_dir('BananaLib') + 'Dir/SubDir/nested_file.m'
@group = @project.group_for_spec('BananaLib') @group = @project.group_for_spec('BananaLib')
end end
...@@ -169,6 +170,11 @@ module Pod ...@@ -169,6 +170,11 @@ module Pod
ref.hierarchy_path.should == '/Pods/BananaLib/file.m' ref.hierarchy_path.should == '/Pods/BananaLib/file.m'
end end
it "adds subgroups for a file reference if requested" do
ref = @project.add_file_reference(@nested_file, @group, true)
ref.hierarchy_path.should == '/Pods/BananaLib/Dir/SubDir/nested_file.m'
end
it "it doesn't duplicate file references for a single path" do it "it doesn't duplicate file references for a single path" do
ref_1 = @project.add_file_reference(@file, @group) ref_1 = @project.add_file_reference(@file, @group)
ref_2 = @project.add_file_reference(@file, @group) ref_2 = @project.add_file_reference(@file, @group)
......
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