Commit d1b84cb9 authored by Fabio Pelosin's avatar Fabio Pelosin

Merge branch 'master' into pods-project-edit-feature

* master:
  Further rationalize the Pods porject
  [Integration] Sort projects

Conflicts:
	lib/cocoapods/installer/pods_project_generator/target_installer/pod_target_installer.rb
	lib/cocoapods/installer/target_installer.rb
	lib/cocoapods/installer/target_installer/aggregate_target_installer.rb
	lib/cocoapods/project.rb
	spec/unit/installer/file_references_installer_spec.rb
	spec/unit/installer/pods_project_generator/target_installer/pod_target_installer_spec.rb
	spec/unit/installer_spec.rb
	spec/unit/project_spec.rb
parents 6c91dad6 e5536f14
......@@ -220,14 +220,18 @@ module Pod
# files should be stored.
#
def support_files_group
# TODO
unless @support_files_group
if target.is_a?(AggregateTarget)
#TODO move to Pods
@support_files_group = project.support_files_group[target.name] || project.support_files_group.new_group(target.name)
aggregate_name = target.label
@support_files_group = project.add_aggregate_group(aggregate_name, project.path.dirname)
else
aggregate_name = target.target_definition.label.to_s
pod_name = target.pod_name
@support_files_group = project.group_for_spec(pod_name, :support_files)
unless project.aggregate_group(aggregate_name)
# TODO
project.add_aggregate_group(aggregate_name, project.path.dirname)
end
@support_files_group = project.add_aggregate_pod_group(aggregate_name, pod_name, project.path.dirname)
end
end
@support_files_group
......
......@@ -14,7 +14,6 @@ module Pod
def install!
UI.message "- Installing target `#{target.name}` #{target.platform}" do
add_target
move_target_product_file_reference
add_files_to_build_phases
add_resources_bundle_targets
link_to_system_frameworks
......@@ -45,15 +44,6 @@ module Pod
end
end
# TODO
#
def move_target_product_file_reference
# TODO: add the target to the appropriate group from the start
pod_name = target.pod_name
group = project.group_for_spec(pod_name, :products)
target.target.product_reference.move(group)
end
# Adds the resources of the Pods to the Pods project.
#
# @note The source files are grouped by Pod and in turn by subspec
......@@ -66,9 +56,7 @@ module Pod
target.file_accessors.each do |file_accessor|
file_accessor.resource_bundles.each do |bundle_name, paths|
file_references = paths.map { |sf| project.reference_for_path(sf) }
group = project.group_for_spec(file_accessor.spec.name, :products)
product_group = project.group_for_spec(file_accessor.spec.name, :resources)
bundle_target = project.new_resources_bundle(bundle_name, file_accessor.spec_consumer.platform_name, product_group)
bundle_target = project.new_resources_bundle(bundle_name, file_accessor.spec_consumer.platform_name)
bundle_target.add_resources(file_references)
target.user_build_configurations.each do |bc_name, type|
......
......@@ -21,7 +21,7 @@ module Pod
# @return [Hash] The names of the specification subgroups by key.
#
ROOT_GROUPS = {
:support_files => 'Targets Support Files',
:support_files => 'Target Files',
:pods => 'Pods',
:development_pods => 'Development Pods',
}
......@@ -60,11 +60,11 @@ module Pod
public
# @!group Pod Groups
# @!group Groups
#-------------------------------------------------------------------------#
# Creates a new group for the Pod with the given name and configures its
# path.
# Creates a new group for the sources of the Pod with the given name and
# configures its path.
#
# @param [String] pod_name
# The name of the Pod.
......@@ -84,8 +84,6 @@ module Pod
parent_group = development ? development_pods : pods
source_tree = absolute ? :absolute : :group
group = parent_group.new_group(pod_name, path, source_tree)
support_files_group = group.new_group(SPEC_SUBGROUPS[:support_files])
support_files_group.source_tree = 'SOURCE_ROOT'
group
end
......@@ -109,12 +107,9 @@ module Pod
# @return [Hash] The names of the specification subgroups by key.
#
SPEC_SUBGROUPS = {
:source_files => 'Source Files',
:resources => 'Resources',
:frameworks_and_libraries => 'Frameworks & Libraries',
:support_files => 'Support Files',
:subspecs => 'Subspecs',
:products => 'Products',
}
# Returns the group for the specification with the give name creating it if
......@@ -131,14 +126,87 @@ module Pod
def group_for_spec(spec_name, subgroup_key = nil)
spec_group = spec_group(spec_name)
if subgroup_key
if subgroup_key == :source_files
spec_group
else
subgroup = SPEC_SUBGROUPS[subgroup_key]
raise ArgumentError, "Unrecognized subgroup `#{subgroup_key}`" unless subgroup
spec_group.find_subpath(subgroup, true)
end
else
spec_group
end
end
# Creates a new group for the aggregate target with the given name and
# path.
#
# @param [String] name
# The name of the target.
#
# @param [#to_s] path
# The path where the files of the target are stored.
#
# @return [PBXGroup] The new group.
#
def add_aggregate_group(name, path)
# TODO TMP
if existing = support_files_group[name]
existing
else
support_files_group.new_group(name, path)
end
end
# Returns the group for the aggregate target with the given name.
#
# @param [String] pod_name
# The name of the Pod.
#
# @return [PBXGroup] The group.
#
def aggregate_group(name)
support_files_group[name]
end
# @return [Array<PBXGroup>] Returns the list of the aggregate groups.
#
def aggregate_groups
support_files_group.children
end
# Creates a new group for the pod target with the given name and aggregate.
#
# @param [String] aggregate_name
# The name of the target.
#
# @param [String] path
# The name of the Pod.
#
# @param [#to_s] path
# The path where the files of the target are stored.
#
# @return [PBXGroup] The new group.
#
def add_aggregate_pod_group(aggregate_name, pod_name, path)
group = aggregate_group(aggregate_name).new_group(pod_name, path)
end
# Returns the group for the pod target with the given name and aggregate.
# path.
#
# @param [String] aggregate_name
# The name of the target.
#
# @param [String] path
# The name of the Pod.
#
# @return [PBXGroup] The group.
#
def aggregate_pod_group(aggregate_name, pod_name)
aggregate_group(aggregate_name)[pod_name]
end
public
......
Subproject commit e9a2805c54fc2f61db25dc5936d15a19cb4c2c13
Subproject commit 7d8fe481f635c00369636acd831ee466557055da
......@@ -18,7 +18,7 @@ module Pod
it "adds the files references of the source files the Pods project" do
@sut.install!
file_ref = config.sandbox.project['Pods/BananaLib/Source Files/Banana.m']
file_ref = config.sandbox.project['Pods/BananaLib/Banana.m']
file_ref.should.be.not.nil
file_ref.path.should == "Classes/Banana.m"
end
......
......@@ -12,7 +12,7 @@ module Pod
describe "In general" do
it "returns the support files group" do
@sut.support_files_group.name.should == 'Targets Support Files'
@sut.support_files_group.name.should == 'Target Files'
end
it "returns the pods group" do
......@@ -79,11 +79,6 @@ module Pod
Pathname.new(group.path).should.be.absolute
end
it "creates a support file group relative to the project" do
group = @sut.add_pod_group('BananaLib', @path, false, true)
group['Support Files'].source_tree.should == 'SOURCE_ROOT'
group['Support Files'].path.should.be.nil
end
end
#----------------------------------------#
......@@ -128,7 +123,7 @@ module Pod
it "returns the requested subgroup" do
group = @sut.group_for_spec('BananaLib/Tree', :source_files)
group.hierarchy_path.should == '/Pods/BananaLib/Subspecs/Tree/Source Files'
group.hierarchy_path.should == '/Pods/BananaLib/Subspecs/Tree'
end
it "raises if unable to recognize the subgroup key" do
......@@ -143,6 +138,38 @@ module Pod
group_1.uuid.should == group_2.uuid
end
end
it "adds the group for the given aggregate target" do
group = @sut.add_aggregate_group('Pods', config.sandbox.root + 'Aggregate/Pods')
group.parent.should == @sut.support_files_group
group.name.should == 'Pods'
group.path.should == 'Aggregate/Pods'
end
it "returns the group for the aggregate target with the given name" do
group = @sut.add_aggregate_group('Pods', config.sandbox.root + 'Aggregate/Pods')
@sut.aggregate_group('Pods').should == group
end
it "returns the list of the aggregate groups" do
group = @sut.add_aggregate_group('Pods', config.sandbox.root + 'Aggregate/Pods')
group = @sut.add_aggregate_group('Tests', config.sandbox.root + 'Aggregate/Tests')
@sut.aggregate_groups.map(&:name).should == ["Pods", "Tests"]
end
it "adds the group for the given aggregate target" do
parent = @sut.add_aggregate_group('Pods', config.sandbox.root + 'Aggregate/Pods')
group = @sut.add_aggregate_pod_group('Pods', 'BananaLib', config.sandbox.root + 'Aggregate/Pods/BananaLib')
group.parent.should == parent
group.name.should == 'BananaLib'
group.path.should == 'BananaLib'
end
it "returns the group for the aggregate target with the given name" do
@sut.add_aggregate_group('Pods', config.sandbox.root + 'Aggregate/Pods')
group = @sut.add_aggregate_pod_group('Pods', 'BananaLib', config.sandbox.root + 'Aggregate/Pods/BananaLib')
@sut.aggregate_pod_group('Pods', 'BananaLib').should == group
end
end
#-------------------------------------------------------------------------#
......@@ -159,7 +186,7 @@ module Pod
it "adds a file references to the given file" do
ref = @sut.add_file_reference(@file, @group)
ref.hierarchy_path.should == '/Pods/BananaLib/Source Files/file.m'
ref.hierarchy_path.should == '/Pods/BananaLib/file.m'
end
it "it doesn't duplicate file references for a single path" do
......@@ -190,7 +217,7 @@ module Pod
it "returns the reference for the given path" do
ref = @sut.reference_for_path(@file)
ref.hierarchy_path.should == '/Pods/BananaLib/Source Files/file.m'
ref.hierarchy_path.should == '/Pods/BananaLib/file.m'
end
it "returns nil if no reference for the given path is available" do
......
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