Commit e24428b4 authored by Boris Bügling's avatar Boris Bügling

Do not generate targets for Pods without sources

If a PodTarget should not be build:
- Do not install a target
- Skip the non-existing native targets in Installer
- Do not add linker flags to XCConfig
parent e588d2c2
......@@ -73,6 +73,7 @@ module Pod
# Add pod static lib to list of libraries that are to be linked with
# the user’s project.
next unless pod_target.should_build
@xcconfig.merge!('OTHER_LDFLAGS' => %(-l "#{pod_target.name}"))
end
......
......@@ -435,16 +435,19 @@ module Pod
pod_targets.sort_by(&:name).each do |pod_target|
pod_target.file_accessors.each do |file_accessor|
file_accessor.spec_consumer.frameworks.each do |framework|
if pod_target.should_build
pod_target.native_target.add_system_framework(framework)
end
end
end
end
end
end
def set_target_dependencies
aggregate_targets.each do |aggregate_target|
aggregate_target.pod_targets.each do |pod_target|
next unless pod_target.should_build
aggregate_target.native_target.add_dependency(pod_target.native_target)
pod_target.dependencies.each do |dep|
......
......@@ -9,6 +9,8 @@ module Pod
# @return [void]
#
def install!
return unless target.should_build
UI.message "- Installing target `#{target.name}` #{target.platform}" do
add_target
create_support_files_dir
......
......@@ -34,6 +34,16 @@ module Pod
#
attr_accessor :file_accessors
# @return [Bool] Whether or not this target should be build.
#
# A target should not be build if it has no source files.
#
def should_build
file_accessors.map do |fa|
fa.source_files.count
end.inject(0, :+) > 0
end
# @return [Array<Specification::Consumer>] the specification consumers for
# the target.
#
......
......@@ -17,6 +17,8 @@ module Pod
@pod_target = PodTarget.new([@spec], target_definition, config.sandbox)
@pod_target.stubs(:platform).returns(:ios)
@pod_target.stubs(:spec_consumers).returns([@consumer])
file_accessor = fixture_file_accessor('banana-lib/BananaLib.podspec')
@pod_target.stubs(:file_accessors).returns([file_accessor])
@target.pod_targets = [@pod_target]
@generator = AggregateXCConfig.new(@target, 'Release')
end
......@@ -79,6 +81,12 @@ module Pod
@xcconfig.to_hash['OTHER_LDFLAGS'].should.include '-l"Pods-BananaLib"'
end
it 'does not link with the aggregate integration library target if it does not contain source files' do
@pod_target.file_accessors.first.stubs(:source_files).returns([])
@xcconfig = @generator.generate
@xcconfig.to_hash['OTHER_LDFLAGS'].should.not.include '-l"Pods-BananaLib"'
end
it 'does not links the pod targets with the aggregate integration library target for non-whitelisted configuration' do
@generator = AggregateXCConfig.new(@target, 'Debug')
@xcconfig = @generator.generate
......
......@@ -151,6 +151,14 @@ module Pod
dummy.read.should.include?('@interface PodsDummy_Pods')
end
#--------------------------------------------------------------------------------#
it 'does not create a target if the specification does not define source files' do
@pod_target.file_accessors.first.stubs(:source_files).returns([])
@installer.install!
@project.targets.should == []
end
#--------------------------------------------------------------------------------#
describe 'concerning compiler flags' do
before 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