Commit b446d8c9 authored by Eloy Duran's avatar Eloy Duran

Add Podfile#link_with which takes a target (or an array of targets) to link the library with.

parent 07fad458
module Pod
class Podfile
class TargetDefinition
attr_reader :name, :parent, :target_dependencies
attr_reader :name, :target_dependencies
def initialize(name, parent = nil)
@name, @parent, @target_dependencies = name, parent, []
attr_accessor :link_with, :parent
def initialize(name, options = {})
@name, @target_dependencies = name, []
options.each { |k, v| send("#{k}=", v) }
end
def link_with=(targets)
@link_with = targets.is_a?(Array) ? targets : [targets]
end
def lib_name
......@@ -59,6 +66,10 @@ module Pod
platform ? @platform = Platform.new(platform, options) : @platform
end
def link_with(targets = nil)
targets ? @target_definition.link_with = targets : @target_definition.link_with
end
# Specifies a dependency of the project.
#
# A dependency requirement is defined by the name of the Pod and _optionally_
......@@ -156,8 +167,8 @@ module Pod
@target_definition.target_dependencies << Dependency.new(*name_and_version_requirements, &block)
end
# Specifies that a BridgeSupport metadata should be generated from the
# headers of all installed Pods.
# Specifies that a BridgeSupport metadata document should be generated from
# the headers of all installed Pods.
#
# This is for scripting languages such as MacRuby, Nu, and JSCocoa, which use
# it to bridge types, functions, etc better.
......@@ -193,7 +204,8 @@ module Pod
# dependency (JSONKit).
def target(name, options = {})
parent = @target_definition
@target_definitions[name] = @target_definition = TargetDefinition.new(name, options[:exclusive] ? nil : parent)
options[:parent] = parent unless options.delete(:exclusive)
@target_definitions[name] = @target_definition = TargetDefinition.new(name, options)
yield
ensure
@target_definition = parent
......
......@@ -74,7 +74,7 @@ describe "Pod::Podfile" do
dependency 'SSZipArchive'
end
target :test, :exclusive => true do
target :test, :exclusive => true, :link_with => 'TestRunner' do
dependency 'JSONKit'
target :subtarget do
dependency 'Reachability'
......@@ -115,6 +115,16 @@ describe "Pod::Podfile" do
target.lib_name.should == 'Pods-test-subtarget'
target.dependencies.should == [Pod::Dependency.new('Reachability'), Pod::Dependency.new('JSONKit')]
end
it "leaves the name of the target, to link with, to be automatically resolved" do
target = @podfile.target_definitions[:default]
target.link_with.should == nil
end
it "returns the name of the explicit target to link with" do
target = @podfile.target_definitions[:test]
target.link_with.should == ['TestRunner']
end
end
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