Commit 431f2b21 authored by Fabio Pelosin's avatar Fabio Pelosin

[Installer] Add target dependencies explicitely [WIP]

See #1165
parent 452d4040
...@@ -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: 5a729b8c406bae502cb942e31738467a00191776 revision: a5dd638c3da221871269199abc214f9216b9bdbf
branch: master branch: master
specs: specs:
xcodeproj (0.7.1) xcodeproj (0.7.1)
......
...@@ -111,6 +111,7 @@ module Pod ...@@ -111,6 +111,7 @@ module Pod
prepare_pods_project prepare_pods_project
install_file_references install_file_references
install_libraries install_libraries
set_target_dependencies
link_aggregate_target link_aggregate_target
run_post_install_hooks run_post_install_hooks
write_pod_project write_pod_project
...@@ -332,6 +333,43 @@ module Pod ...@@ -332,6 +333,43 @@ module Pod
end end
end end
def set_target_dependencies
aggregate_targets.each do |aggregate_target|
aggregate_target.pod_targets.each do |pod_target|
add_dependency(aggregate_target, pod_target)
pod_target.dependencies.each do |dep|
pod_dependency_target = aggregate_target.pod_targets.find { |target| target.root_spec.name == dep }
add_dependency(pod_target, pod_dependency_target)
end
end
end
end
# TODO: tmp - move
#
def add_dependency(dependent_target, dependency_target)
container_proxy = pods_project.new(Xcodeproj::Project::PBXContainerItemProxy)
# container_proxy.container_portal = '224D2C1BCDE44D8F9B674AD5'
container_proxy.proxy_type = '1'
# container_proxy.remote_global_id_string = 'F8D3306CA0564CA3861B2D4E'
# container_proxy.remote_info = 'Pods-AFHTTPRequestOperationLogger'
# reference_proxy = pods_project.new(Xcodeproj::Project::PBXReferenceProxy)
# reference_proxy.path =
# reference_proxy.file_type =
# reference_proxy.remote_ref = container_proxy
# reference_proxy.source_tree = BUILT_PRODUCTS_DIR
dependency = pods_project.new(Xcodeproj::Project::PBXTargetDependency)
dependency.target = dependency_target.target
# dependency.targetProxy = container_proxy
dependent_target.target.dependencies << dependency
end
# Links the aggregate targets with all the dependent libraries. # Links the aggregate targets with all the dependent libraries.
# #
# @note This is run in the integration step to ensure that targets # @note This is run in the integration step to ensure that targets
......
...@@ -49,5 +49,14 @@ module Pod ...@@ -49,5 +49,14 @@ module Pod
specs.first.root specs.first.root
end end
# @return [Array<String>] The names of the Pods on which this target
# depends.
#
def dependencies
specs.map do |spec|
spec.consumer(platform).dependencies.map { |dep| dep.name }
end.flatten
end
end end
end end
...@@ -163,7 +163,7 @@ module Pod ...@@ -163,7 +163,7 @@ module Pod
it "creates a dummy source to ensure the creation of a single base library" do it "creates a dummy source to ensure the creation of a single base library" do
@installer.install! @installer.install!
build_files = @installer.library.target.source_build_phase.files build_files = @installer.library.target.source_build_phase.files
build_file = build_files.find { |bf| bf.file_ref.name == 'Pods-dummy.m' } build_file = build_files.find { |bf| bf.file_ref.path.include?('Pods-dummy.m') }
build_file.should.be.not.nil build_file.should.be.not.nil
build_file.file_ref.path.should == 'Pods-dummy.m' build_file.file_ref.path.should == 'Pods-dummy.m'
dummy = config.sandbox.root + 'Pods-dummy.m' dummy = config.sandbox.root + 'Pods-dummy.m'
......
...@@ -116,7 +116,7 @@ module Pod ...@@ -116,7 +116,7 @@ module Pod
it 'adds the source files of each pod to the target of the Pod library' do it 'adds the source files of each pod to the target of the Pod library' do
@installer.install! @installer.install!
names = @installer.library.target.source_build_phase.files.map { |bf| bf.file_ref.name } names = @installer.library.target.source_build_phase.files.map { |bf| bf.file_ref.display_name }
names.should.include("Banana.m") names.should.include("Banana.m")
end end
...@@ -156,7 +156,7 @@ module Pod ...@@ -156,7 +156,7 @@ module Pod
it "creates a dummy source to ensure the compilation of libraries with only categories" do it "creates a dummy source to ensure the compilation of libraries with only categories" do
@installer.install! @installer.install!
build_files = @installer.library.target.source_build_phase.files build_files = @installer.library.target.source_build_phase.files
build_file = build_files.find { |bf| bf.file_ref.name == 'Pods-BananaLib-dummy.m' } build_file = build_files.find { |bf| bf.file_ref.display_name == 'Pods-BananaLib-dummy.m' }
build_file.should.be.not.nil build_file.should.be.not.nil
build_file.file_ref.path.should == 'Pods-BananaLib-dummy.m' build_file.file_ref.path.should == 'Pods-BananaLib-dummy.m'
dummy = config.sandbox.root + 'Pods-BananaLib-dummy.m' dummy = config.sandbox.root + 'Pods-BananaLib-dummy.m'
......
...@@ -64,6 +64,7 @@ module Pod ...@@ -64,6 +64,7 @@ module Pod
@installer.stubs(:install_libraries) @installer.stubs(:install_libraries)
@installer.stubs(:link_aggregate_target) @installer.stubs(:link_aggregate_target)
@installer.stubs(:write_lockfiles) @installer.stubs(:write_lockfiles)
@installer.stubs(:aggregate_targets).returns([])
@installer.unstub(:generate_pods_project) @installer.unstub(:generate_pods_project)
def @installer.run_post_install_hooks def @installer.run_post_install_hooks
@hook_called = true @hook_called = true
...@@ -226,8 +227,7 @@ module Pod ...@@ -226,8 +227,7 @@ module Pod
@installer.stubs(:aggregate_targets).returns([]) @installer.stubs(:aggregate_targets).returns([])
config.stubs(:podfile_path).returns(Pathname.new('/Podfile')) config.stubs(:podfile_path).returns(Pathname.new('/Podfile'))
@installer.send(:prepare_pods_project) @installer.send(:prepare_pods_project)
f = @installer.pods_project['Podfile'] @installer.pods_project['Podfile'].should.be.not.nil
f.name.should == 'Podfile'
end end
it "sets the deployment target for the whole project" do it "sets the deployment target for the whole project" do
......
...@@ -99,7 +99,6 @@ module Pod ...@@ -99,7 +99,6 @@ module Pod
it "adds the Podfile configured as a Ruby file" do it "adds the Podfile configured as a Ruby file" do
@project.add_podfile(config.sandbox.root + '../Podfile') @project.add_podfile(config.sandbox.root + '../Podfile')
f = @project['Podfile'] f = @project['Podfile']
f.name.should == 'Podfile'
f.source_tree.should == 'SOURCE_ROOT' f.source_tree.should == 'SOURCE_ROOT'
f.xc_language_specification_identifier.should == 'xcode.lang.ruby' f.xc_language_specification_identifier.should == 'xcode.lang.ruby'
f.path.should == '../Podfile' f.path.should == '../Podfile'
......
...@@ -25,6 +25,14 @@ module Pod ...@@ -25,6 +25,14 @@ module Pod
it "returns the spec consumers for the pod targets" do it "returns the spec consumers for the pod targets" do
@pod_target.spec_consumers.should.not == nil @pod_target.spec_consumers.should.not == nil
end end
it "returns the root spec" do
@pod_target.root_spec.name.should == 'BananaLib'
end
it "returns the name of the Pods on which this target depends" do
@pod_target.dependencies.should == ["monkey"]
end
end end
describe "Support files" do describe "Support files" 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