Commit 38eaf223 authored by Fabio Pelosin's avatar Fabio Pelosin

"[Specification] Allow to require_arc in subspecs."

Closes #464.
parent 7c5ed225
...@@ -51,8 +51,9 @@ module Pod ...@@ -51,8 +51,9 @@ module Pod
compiler_flags ].each do |attr| compiler_flags ].each do |attr|
instance_variable_set( "@#{attr}", { :ios => [], :osx => [] } ) instance_variable_set( "@#{attr}", { :ios => [], :osx => [] } )
end end
@xcconfig = { :ios => Xcodeproj::Config.new, :osx => Xcodeproj::Config.new } @xcconfig = { :ios => Xcodeproj::Config.new, :osx => Xcodeproj::Config.new }
@header_dir = { :ios => nil, :osx => nil } @header_dir = { :ios => nil, :osx => nil }
@requires_arc = { :ios => nil, :osx => nil }
yield self if block_given? yield self if block_given?
end end
...@@ -137,6 +138,7 @@ module Pod ...@@ -137,6 +138,7 @@ module Pod
compiler_flags= compiler_flags=
deployment_target= deployment_target=
header_dir= header_dir=
requires_arc
dependency }.each do |method| dependency }.each do |method|
define_method(method) do |args| define_method(method) do |args|
@specification._on_platform(@platform) do @specification._on_platform(@platform) do
...@@ -194,7 +196,6 @@ module Pod ...@@ -194,7 +196,6 @@ module Pod
top_attr_accessor :homepage top_attr_accessor :homepage
top_attr_accessor :summary top_attr_accessor :summary
top_attr_accessor :documentation top_attr_accessor :documentation
top_attr_accessor :requires_arc
top_attr_accessor :version, lambda { |v| Version.new(v) } top_attr_accessor :version, lambda { |v| Version.new(v) }
top_attr_reader :description, lambda { |instance, ivar| ivar || instance.summary } top_attr_reader :description, lambda { |instance, ivar| ivar || instance.summary }
...@@ -255,6 +256,24 @@ module Pod ...@@ -255,6 +256,24 @@ module Pod
alias_method :weak_framework=, :weak_frameworks= alias_method :weak_framework=, :weak_frameworks=
alias_method :library=, :libraries= alias_method :library=, :libraries=
# @!method requires_arc=
#
# @abstract Wether the `-fobjc-arc' flag should be added to the compiler
# flags.
#
# @param [Bool] Wether the source files require ARC.
#
platform_attr_writer :requires_arc
def requires_arc
requires_arc = @requires_arc[active_platform]
if requires_arc.nil?
requires_arc = @parent ? @parent.requires_arc : false
end
requires_arc
end
# @!method header_dir= # @!method header_dir=
# #
# @abstract The directory where to name space the headers files of # @abstract The directory where to name space the headers files of
......
...@@ -305,6 +305,7 @@ describe "A Pod::Specification subspec" do ...@@ -305,6 +305,7 @@ describe "A Pod::Specification subspec" do
fss.subspec 'SecondSubSpec' do |sss| fss.subspec 'SecondSubSpec' do |sss|
sss.source_files = 'subsubspec.m' sss.source_files = 'subsubspec.m'
sss.requires_arc = false
end end
end end
end end
...@@ -329,7 +330,7 @@ describe "A Pod::Specification subspec" do ...@@ -329,7 +330,7 @@ describe "A Pod::Specification subspec" do
it "automatically forwards top level attributes to the top level parent" do it "automatically forwards top level attributes to the top level parent" do
@spec.activate_platform(:ios) @spec.activate_platform(:ios)
[:version, :license, :authors, :requires_arc, :compiler_flags].each do |attr| [:version, :license, :authors, :compiler_flags].each do |attr|
@spec.subspecs.first.send(attr).should == @spec.send(attr) @spec.subspecs.first.send(attr).should == @spec.send(attr)
@spec.subspecs.first.subspecs.first.send(attr).should == @spec.send(attr) @spec.subspecs.first.subspecs.first.send(attr).should == @spec.send(attr)
end end
...@@ -346,6 +347,13 @@ describe "A Pod::Specification subspec" do ...@@ -346,6 +347,13 @@ describe "A Pod::Specification subspec" do
@subsubspec.compiler_flags.should == ' -fobjc-arc -Wdeprecated-implementations' @subsubspec.compiler_flags.should == ' -fobjc-arc -Wdeprecated-implementations'
end end
it "allows to specify arc settings for subspecs" do
@spec.activate_platform(:ios)
@spec.requires_arc.should == true
@subspec.requires_arc.should == true
@subsubspec.requires_arc.should == false
end
it "returns empty arrays for chained attributes with no value in the chain" do it "returns empty arrays for chained attributes with no value in the chain" do
@spec = Pod::Spec.new do |s| @spec = Pod::Spec.new do |s|
s.name = 'MainSpec' s.name = 'MainSpec'
......
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