Commit e5536f14 authored by Fabio Pelosin's avatar Fabio Pelosin

Further rationalize the Pods porject

parent 340492f0
...@@ -17,7 +17,7 @@ GIT ...@@ -17,7 +17,7 @@ GIT
GIT GIT
remote: https://github.com/CocoaPods/Xcodeproj.git remote: https://github.com/CocoaPods/Xcodeproj.git
revision: c9c8fb4f5fc7f89ab86cde341c1bc584ace2217a revision: 23d64ce79dd23e928dadac986a858a13c07ac988
branch: master branch: master
specs: specs:
xcodeproj (0.10.1) xcodeproj (0.10.1)
...@@ -41,7 +41,7 @@ GIT ...@@ -41,7 +41,7 @@ GIT
GIT GIT
remote: https://github.com/irrationalfab/PrettyBacon.git remote: https://github.com/irrationalfab/PrettyBacon.git
revision: f9f711c5b95d9eee9a79a2a23e25bb3390f9cbcb revision: 59cde2c52a3211c06f894e7324e5e4fac9d8476a
branch: master branch: master
specs: specs:
prettybacon (0.0.1) prettybacon (0.0.1)
......
...@@ -64,7 +64,7 @@ module Pod ...@@ -64,7 +64,7 @@ module Pod
# @return [void] # @return [void]
# #
def create_suport_files_group def create_suport_files_group
@support_files_group = project.support_files_group.new_group(library.name) @support_files_group = project.add_aggregate_group(library.name, sandbox.root)
end end
# Generates a dummy source file for each target so libraries that contain # Generates a dummy source file for each target so libraries that contain
......
...@@ -12,8 +12,8 @@ module Pod ...@@ -12,8 +12,8 @@ module Pod
# #
def install! def install!
UI.message "- Installing target `#{library.name}` #{library.platform}" do UI.message "- Installing target `#{library.name}` #{library.platform}" do
add_target
create_suport_files_group create_suport_files_group
add_target
create_xcconfig_file create_xcconfig_file
create_target_environment_header create_target_environment_header
create_bridge_support_file create_bridge_support_file
......
...@@ -12,8 +12,11 @@ module Pod ...@@ -12,8 +12,11 @@ module Pod
# #
def install! def install!
UI.message "- Installing target `#{library.name}` #{library.platform}" do UI.message "- Installing target `#{library.name}` #{library.platform}" do
aggregate_name = library.target_definition.label.to_s
project.add_aggregate_group(aggregate_name, sandbox.root)
pod_name = library.pod_name
@support_files_group = project.add_aggregate_pod_group(aggregate_name, pod_name, sandbox.root)
add_target add_target
move_target_product_file_reference
add_files_to_build_phases add_files_to_build_phases
add_resources_bundle_targets add_resources_bundle_targets
# create_suport_files_group # create_suport_files_group
...@@ -48,12 +51,6 @@ module Pod ...@@ -48,12 +51,6 @@ module Pod
end end
end end
def move_target_product_file_reference
pod_name = library.pod_name
group = project.group_for_spec(pod_name, :products)
target.product_reference.move(group)
end
# Adds the resources of the Pods to the Pods project. # Adds the resources of the Pods to the Pods project.
# #
# @note The source files are grouped by Pod and in turn by subspec # @note The source files are grouped by Pod and in turn by subspec
...@@ -66,7 +63,9 @@ module Pod ...@@ -66,7 +63,9 @@ module Pod
library.file_accessors.each do |file_accessor| library.file_accessors.each do |file_accessor|
file_accessor.resource_bundles.each do |bundle_name, paths| file_accessor.resource_bundles.each do |bundle_name, paths|
file_references = paths.map { |sf| project.reference_for_path(sf) } file_references = paths.map { |sf| project.reference_for_path(sf) }
group = project.group_for_spec(file_accessor.spec.name, :products) aggregate_name = library.target_definition.label.to_s
pod_name = library.pod_name
group = project.aggregate_pod_group(aggregate_name, pod_name)
product_group = project.group_for_spec(file_accessor.spec.name, :resources) 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, product_group)
bundle_target.add_resources(file_references) bundle_target.add_resources(file_references)
...@@ -195,8 +194,9 @@ module Pod ...@@ -195,8 +194,9 @@ module Pod
# @return [PBXFileReference] the file reference of the added file. # @return [PBXFileReference] the file reference of the added file.
# #
def add_file_to_support_group(path) def add_file_to_support_group(path)
aggregate_name = library.target_definition.label.to_s
pod_name = library.pod_name pod_name = library.pod_name
group = project.group_for_spec(pod_name, :support_files) group = project.aggregate_pod_group(aggregate_name, pod_name)
group.new_file(path) group.new_file(path)
end end
......
...@@ -15,7 +15,7 @@ module Pod ...@@ -15,7 +15,7 @@ module Pod
# #
def initialize(path, skip_initialization = false) def initialize(path, skip_initialization = false)
super(path, skip_initialization) super(path, skip_initialization)
@support_files_group = new_group('Targets Support Files') @support_files_group = new_group('Target Files')
@refs_by_absolute_path = {} @refs_by_absolute_path = {}
@pods = new_group('Pods') @pods = new_group('Pods')
@development_pods = new_group('Development Pods') @development_pods = new_group('Development Pods')
...@@ -37,11 +37,11 @@ module Pod ...@@ -37,11 +37,11 @@ module Pod
public public
# @!group Pod Groups # @!group Groups
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
# Creates a new group for the Pod with the given name and configures its # Creates a new group for the sources of the Pod with the given name and
# path. # configures its path.
# #
# @param [String] pod_name # @param [String] pod_name
# The name of the Pod. # The name of the Pod.
...@@ -63,8 +63,6 @@ module Pod ...@@ -63,8 +63,6 @@ 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)
support_files_group = group.new_group(SPEC_SUBGROUPS[:support_files])
support_files_group.source_tree = 'SOURCE_ROOT'
group group
end end
...@@ -91,9 +89,7 @@ module Pod ...@@ -91,9 +89,7 @@ module Pod
:source_files => 'Source Files', :source_files => 'Source Files',
:resources => 'Resources', :resources => 'Resources',
:frameworks_and_libraries => 'Frameworks & Libraries', :frameworks_and_libraries => 'Frameworks & Libraries',
:support_files => 'Support Files',
:subspecs => 'Subspecs', :subspecs => 'Subspecs',
:products => 'Products',
} }
# Returns the group for the specification with the give name creating it if # Returns the group for the specification with the give name creating it if
...@@ -110,14 +106,87 @@ module Pod ...@@ -110,14 +106,87 @@ module Pod
def group_for_spec(spec_name, subgroup_key = nil) def group_for_spec(spec_name, subgroup_key = nil)
spec_group = spec_group(spec_name) spec_group = spec_group(spec_name)
if subgroup_key if subgroup_key
if subgroup_key == :source_files
spec_group
else
subgroup = SPEC_SUBGROUPS[subgroup_key] subgroup = SPEC_SUBGROUPS[subgroup_key]
raise ArgumentError, "Unrecognized subgroup `#{subgroup_key}`" unless subgroup raise ArgumentError, "Unrecognized subgroup `#{subgroup_key}`" unless subgroup
spec_group.find_subpath(subgroup, true) spec_group.find_subpath(subgroup, true)
end
else else
spec_group spec_group
end end
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 public
......
Subproject commit 3b5a20dede40a3c55fbacb623254a4c3e06a51b3 Subproject commit 7d8fe481f635c00369636acd831ee466557055da
...@@ -24,7 +24,7 @@ module Pod ...@@ -24,7 +24,7 @@ module Pod
it "adds the files references of the source files the Pods project" do it "adds the files references of the source files the Pods project" do
@installer.install! @installer.install!
file_ref = @installer.pods_project['Pods/BananaLib/Source Files/Banana.m'] file_ref = @installer.pods_project['Pods/BananaLib/Banana.m']
file_ref.should.be.not.nil file_ref.should.be.not.nil
file_ref.path.should == "Classes/Banana.m" file_ref.path.should == "Classes/Banana.m"
end end
......
...@@ -33,7 +33,7 @@ module Pod ...@@ -33,7 +33,7 @@ module Pod
it "adds file references for the support files of the target" do it "adds file references for the support files of the target" do
@installer.install! @installer.install!
@project.support_files_group @project.support_files_group
group = @project['Pods/BananaLib/Support Files'] group = @project['Target Files/Pods/BananaLib']
group.children.map(&:display_name).sort.should == [ group.children.map(&:display_name).sort.should == [
"Pods-BananaLib-Private.xcconfig", "Pods-BananaLib-Private.xcconfig",
"Pods-BananaLib-dummy.m", "Pods-BananaLib-dummy.m",
......
...@@ -345,7 +345,7 @@ module Pod ...@@ -345,7 +345,7 @@ module Pod
end end
it "recursively sorts the project by type" do it "recursively sorts the project by type" do
@installer.pods_project.main_group.expects(:recursively_sort_by_type) @installer.pods_project.main_group.expects(:sort)
@installer.send(:write_pod_project) @installer.send(:write_pod_project)
end end
......
...@@ -12,7 +12,7 @@ module Pod ...@@ -12,7 +12,7 @@ module Pod
describe "In general" do describe "In general" do
it "creates the support files group on initialization" do it "creates the support files group on initialization" do
@project.support_files_group.name.should == 'Targets Support Files' @project.support_files_group.name.should == 'Target Files'
end end
it "creates the Pods group on initialization" do it "creates the Pods group on initialization" do
...@@ -64,11 +64,6 @@ module Pod ...@@ -64,11 +64,6 @@ module Pod
Pathname.new(group.path).should.be.absolute Pathname.new(group.path).should.be.absolute
end end
it "creates a support file group relative to the project" do
group = @project.add_pod_group('BananaLib', @path, false, true)
group['Support Files'].source_tree.should == 'SOURCE_ROOT'
group['Support Files'].path.should.be.nil
end
end end
#----------------------------------------# #----------------------------------------#
...@@ -113,7 +108,7 @@ module Pod ...@@ -113,7 +108,7 @@ module Pod
it "returns the requested subgroup" do it "returns the requested subgroup" do
group = @project.group_for_spec('BananaLib/Tree', :source_files) group = @project.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 end
it "raises if unable to recognize the subgroup key" do it "raises if unable to recognize the subgroup key" do
...@@ -128,6 +123,38 @@ module Pod ...@@ -128,6 +123,38 @@ module Pod
group_1.uuid.should == group_2.uuid group_1.uuid.should == group_2.uuid
end end
end end
it "adds the group for the given aggregate target" do
group = @project.add_aggregate_group('Pods', config.sandbox.root + 'Aggregate/Pods')
group.parent.should == @project.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 = @project.add_aggregate_group('Pods', config.sandbox.root + 'Aggregate/Pods')
@project.aggregate_group('Pods').should == group
end
it "returns the list of the aggregate groups" do
group = @project.add_aggregate_group('Pods', config.sandbox.root + 'Aggregate/Pods')
group = @project.add_aggregate_group('Tests', config.sandbox.root + 'Aggregate/Tests')
@project.aggregate_groups.map(&:name).should == ["Pods", "Tests"]
end
it "adds the group for the given aggregate target" do
parent = @project.add_aggregate_group('Pods', config.sandbox.root + 'Aggregate/Pods')
group = @project.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
@project.add_aggregate_group('Pods', config.sandbox.root + 'Aggregate/Pods')
group = @project.add_aggregate_pod_group('Pods', 'BananaLib', config.sandbox.root + 'Aggregate/Pods/BananaLib')
@project.aggregate_pod_group('Pods', 'BananaLib').should == group
end
end end
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
...@@ -144,7 +171,7 @@ module Pod ...@@ -144,7 +171,7 @@ module Pod
it "adds a file references to the given file" do it "adds a file references to the given file" do
ref = @project.add_file_reference(@file, @group) ref = @project.add_file_reference(@file, @group)
ref.hierarchy_path.should == '/Pods/BananaLib/Source Files/file.m' ref.hierarchy_path.should == '/Pods/BananaLib/file.m'
end 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
...@@ -175,7 +202,7 @@ module Pod ...@@ -175,7 +202,7 @@ module Pod
it "returns the reference for the given path" do it "returns the reference for the given path" do
ref = @project.reference_for_path(@file) ref = @project.reference_for_path(@file)
ref.hierarchy_path.should == '/Pods/BananaLib/Source Files/file.m' ref.hierarchy_path.should == '/Pods/BananaLib/file.m'
end end
it "returns nil if no reference for the given path is available" do 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