Commit 6b68f529 authored by Eloy Duran's avatar Eloy Duran

Don’t create a target if its definition, in the Podfile, is empty (no dependencies). Closes #79.

parent 0318141b
...@@ -18,7 +18,7 @@ module Pod ...@@ -18,7 +18,7 @@ module Pod
include Config::Mixin include Config::Mixin
include Shared include Shared
attr_reader :target attr_reader :podfile, :project, :definition, :target
def initialize(podfile, project, definition) def initialize(podfile, project, definition)
@podfile, @project, @definition = podfile, project, definition @podfile, @project, @definition = podfile, project, definition
...@@ -163,8 +163,8 @@ module Pod ...@@ -163,8 +163,8 @@ module Pod
def target_installers def target_installers
@target_installers ||= @podfile.target_definitions.values.map do |definition| @target_installers ||= @podfile.target_definitions.values.map do |definition|
TargetInstaller.new(@podfile, project, definition) TargetInstaller.new(@podfile, project, definition) unless definition.empty?
end end.compact
end end
def install! def install!
......
...@@ -8,7 +8,13 @@ module Pod ...@@ -8,7 +8,13 @@ module Pod
end end
def lib_name def lib_name
name == :default ? "Pods" : "Pods-#{name}" if name == :default
"Pods"
elsif @parent
"#{@parent.lib_name}-#{name}"
else
"Pods-#{name}"
end
end end
# Returns *all* dependencies of this target, not only the target specific # Returns *all* dependencies of this target, not only the target specific
...@@ -16,6 +22,10 @@ module Pod ...@@ -16,6 +22,10 @@ module Pod
def dependencies def dependencies
@target_dependencies + (@parent ? @parent.dependencies : []) @target_dependencies + (@parent ? @parent.dependencies : [])
end end
def empty?
target_dependencies.empty?
end
end end
def self.from_file(path) def self.from_file(path)
......
...@@ -3,7 +3,10 @@ require File.expand_path('../../spec_helper', __FILE__) ...@@ -3,7 +3,10 @@ require File.expand_path('../../spec_helper', __FILE__)
describe "Pod::Installer" do describe "Pod::Installer" do
describe ", by default," do describe ", by default," do
before do before do
@xcconfig = Pod::Installer.new(Pod::Podfile.new { platform :ios }).target_installers.first.xcconfig.to_hash @xcconfig = Pod::Installer.new(Pod::Podfile.new do
platform :ios
dependency 'JSONKit'
end).target_installers.first.xcconfig.to_hash
end end
it "sets the header search paths where installed Pod headers can be found" do it "sets the header search paths where installed Pod headers can be found" do
...@@ -45,6 +48,17 @@ describe "Pod::Installer" do ...@@ -45,6 +48,17 @@ describe "Pod::Installer" do
installer.target_installers.first.bridge_support_generator.headers.should == expected installer.target_installers.first.bridge_support_generator.headers.should == expected
end end
it "omits empty target definitions" do
podfile = Pod::Podfile.new do
platform :ios
target :not_empty do
dependency 'JSONKit'
end
end
installer = Pod::Installer.new(podfile)
installer.target_installers.map(&:definition).map(&:name).should == [:not_empty]
end
it "moves the compile and link phases to the end of the build phases list, so Pod headers are copied first and sources can use the same header dir structure" do it "moves the compile and link phases to the end of the build phases list, so Pod headers are copied first and sources can use the same header dir structure" do
podfile = Pod::Podfile.new do podfile = Pod::Podfile.new do
platform :osx platform :osx
......
...@@ -60,6 +60,14 @@ describe "Pod::Podfile" do ...@@ -60,6 +60,14 @@ describe "Pod::Podfile" do
end end
describe "concerning targets (dependency groups)" do describe "concerning targets (dependency groups)" do
it "returns wether or not a target has any dependencies" do
Pod::Podfile.new do
end.target_definitions[:default].should.be.empty
Pod::Podfile.new do
dependency 'JSONKit'
end.target_definitions[:default].should.not.be.empty
end
before do before do
@podfile = Pod::Podfile.new do @podfile = Pod::Podfile.new do
target :debug do target :debug do
...@@ -68,6 +76,9 @@ describe "Pod::Podfile" do ...@@ -68,6 +76,9 @@ describe "Pod::Podfile" do
target :test, :exclusive => true do target :test, :exclusive => true do
dependency 'JSONKit' dependency 'JSONKit'
target :subtarget do
dependency 'Reachability'
end
end end
dependency 'ASIHTTPRequest' dependency 'ASIHTTPRequest'
...@@ -75,7 +86,7 @@ describe "Pod::Podfile" do ...@@ -75,7 +86,7 @@ describe "Pod::Podfile" do
end end
it "returns all dependencies of all targets combined, which is used during resolving to enusre compatible dependencies" do it "returns all dependencies of all targets combined, which is used during resolving to enusre compatible dependencies" do
@podfile.dependencies.map(&:name).sort.should == %w{ ASIHTTPRequest JSONKit SSZipArchive } @podfile.dependencies.map(&:name).sort.should == %w{ ASIHTTPRequest JSONKit Reachability SSZipArchive }
end end
it "adds dependencies outside of any explicit target block to the default target" do it "adds dependencies outside of any explicit target block to the default target" do
...@@ -98,6 +109,12 @@ describe "Pod::Podfile" do ...@@ -98,6 +109,12 @@ describe "Pod::Podfile" do
target.lib_name.should == 'Pods-test' target.lib_name.should == 'Pods-test'
target.dependencies.should == [Pod::Dependency.new('JSONKit')] target.dependencies.should == [Pod::Dependency.new('JSONKit')]
end end
it "adds dependencies of the outer target to nested targets" do
target = @podfile.target_definitions[:subtarget]
target.lib_name.should == 'Pods-test-subtarget'
target.dependencies.should == [Pod::Dependency.new('Reachability'), Pod::Dependency.new('JSONKit')]
end
end end
describe "concerning validations" do describe "concerning validations" 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