Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
cocoapods
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gengmeiios
cocoapods
Commits
6c15ca8b
Commit
6c15ca8b
authored
Nov 13, 2014
by
Samuel E. Giddins
Committed by
Kyle Fuller
Nov 15, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[PodTargetInstaller] Support the specification of file patterns for `requires_arc`
parent
6ceb4f1d
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
89 additions
and
27 deletions
+89
-27
Gemfile.lock
Gemfile.lock
+1
-1
pod_target_installer.rb
...oapods/installer/target_installer/pod_target_installer.rb
+16
-8
file_accessor.rb
lib/cocoapods/sandbox/file_accessor.rb
+21
-0
pod_target_installer_spec.rb
...t/installer/target_installer/pod_target_installer_spec.rb
+14
-18
file_accessor_spec.rb
spec/unit/sandbox/file_accessor_spec.rb
+37
-0
No files found.
Gemfile.lock
View file @
6c15ca8b
...
@@ -7,7 +7,7 @@ GIT
...
@@ -7,7 +7,7 @@ GIT
GIT
GIT
remote: https://github.com/CocoaPods/Core.git
remote: https://github.com/CocoaPods/Core.git
revision:
a00e38bc4ad61cb4cf23a5accba4ef25e48871a5
revision:
60a486e8141323390dc5ff7f6676cf893a251a48
branch: master
branch: master
specs:
specs:
cocoapods-core (0.35.0.rc2)
cocoapods-core (0.35.0.rc2)
...
...
lib/cocoapods/installer/target_installer/pod_target_installer.rb
View file @
6c15ca8b
...
@@ -35,12 +35,20 @@ module Pod
...
@@ -35,12 +35,20 @@ module Pod
def
add_files_to_build_phases
def
add_files_to_build_phases
target
.
file_accessors
.
each
do
|
file_accessor
|
target
.
file_accessors
.
each
do
|
file_accessor
|
consumer
=
file_accessor
.
spec_consumer
consumer
=
file_accessor
.
spec_consumer
flags
=
compiler_flags_for_consumer
(
consumer
)
all_source_files
=
file_accessor
.
source_files
other_source_files
=
file_accessor
.
source_files
.
select
{
|
sf
|
sf
.
extname
==
'.d'
}
regular_source_files
=
all_source_files
.
reject
{
|
sf
|
sf
.
extname
==
'.d'
}
regular_file_refs
=
regular_source_files
.
map
{
|
sf
|
project
.
reference_for_path
(
sf
)
}
{
native_target
.
add_file_references
(
regular_file_refs
,
flags
)
true
=>
file_accessor
.
arc_source_files
,
other_file_refs
=
(
all_source_files
-
regular_source_files
).
map
{
|
sf
|
project
.
reference_for_path
(
sf
)
}
false
=>
file_accessor
.
non_arc_source_files
,
}.
each
do
|
arc
,
files
|
files
=
files
-
other_source_files
flags
=
compiler_flags_for_consumer
(
consumer
,
arc
)
regular_file_refs
=
files
.
map
{
|
sf
|
project
.
reference_for_path
(
sf
)
}
native_target
.
add_file_references
(
regular_file_refs
,
flags
)
end
other_file_refs
=
other_source_files
.
map
{
|
sf
|
project
.
reference_for_path
(
sf
)
}
native_target
.
add_file_references
(
other_file_refs
,
nil
)
native_target
.
add_file_references
(
other_file_refs
,
nil
)
end
end
end
end
...
@@ -152,9 +160,9 @@ module Pod
...
@@ -152,9 +160,9 @@ module Pod
#
#
# @return [String] The compiler flags.
# @return [String] The compiler flags.
#
#
def
compiler_flags_for_consumer
(
consumer
)
def
compiler_flags_for_consumer
(
consumer
,
arc
)
flags
=
consumer
.
compiler_flags
.
dup
flags
=
consumer
.
compiler_flags
.
dup
if
!
consumer
.
requires_
arc
if
!
arc
flags
<<
'-fno-objc-arc'
flags
<<
'-fno-objc-arc'
else
else
platform_name
=
consumer
.
platform_name
platform_name
=
consumer
.
platform_name
...
...
lib/cocoapods/sandbox/file_accessor.rb
View file @
6c15ca8b
...
@@ -78,6 +78,27 @@ module Pod
...
@@ -78,6 +78,27 @@ module Pod
paths_for_attribute
(
:source_files
)
paths_for_attribute
(
:source_files
)
end
end
# @return [Array<Pathname>] the source files of the specification that
# use ARC.
#
def
arc_source_files
case
spec_consumer
.
requires_arc
when
TrueClass
source_files
when
FalseClass
[]
else
paths_for_attribute
(
:requires_arc
)
&
source_files
end
end
# @return [Array<Pathname>] the source files of the specification that
# do not use ARC.
#
def
non_arc_source_files
source_files
-
arc_source_files
end
# @return [Array<Pathname>] the headers of the specification.
# @return [Array<Pathname>] the headers of the specification.
#
#
def
headers
def
headers
...
...
spec/unit/installer/target_installer/pod_target_installer_spec.rb
View file @
6c15ca8b
...
@@ -161,8 +161,8 @@ module Pod
...
@@ -161,8 +161,8 @@ module Pod
@installer
.
target
.
target_definition
.
stubs
(
:inhibits_warnings_for_pod?
).
returns
(
true
)
@installer
.
target
.
target_definition
.
stubs
(
:inhibits_warnings_for_pod?
).
returns
(
true
)
@installer
.
install!
@installer
.
install!
dtrace_files
=
@installer
.
target
.
native_target
.
source_build_phase
.
files
.
rej
ect
do
|
sf
|
dtrace_files
=
@installer
.
target
.
native_target
.
source_build_phase
.
files
.
sel
ect
do
|
sf
|
!
(
File
.
extname
(
sf
.
file_ref
.
path
)
==
'.d'
)
File
.
extname
(
sf
.
file_ref
.
path
)
==
'.d'
end
end
dtrace_files
.
each
do
|
dt
|
dtrace_files
.
each
do
|
dt
|
dt
.
settings
.
should
.
be
.
nil
dt
.
settings
.
should
.
be
.
nil
...
@@ -171,64 +171,60 @@ module Pod
...
@@ -171,64 +171,60 @@ module Pod
it
'adds -w per pod if target definition inhibits warnings for that pod'
do
it
'adds -w per pod if target definition inhibits warnings for that pod'
do
@installer
.
target
.
target_definition
.
stubs
(
:inhibits_warnings_for_pod?
).
returns
(
true
)
@installer
.
target
.
target_definition
.
stubs
(
:inhibits_warnings_for_pod?
).
returns
(
true
)
flags
=
@installer
.
send
(
:compiler_flags_for_consumer
,
@spec
.
consumer
(
:ios
))
flags
=
@installer
.
send
(
:compiler_flags_for_consumer
,
@spec
.
consumer
(
:ios
)
,
true
)
flags
.
should
.
include?
(
'-w'
)
flags
.
should
.
include?
(
'-w'
)
end
end
it
"doesn't inhibit warnings by default"
do
it
"doesn't inhibit warnings by default"
do
flags
=
@installer
.
send
(
:compiler_flags_for_consumer
,
@spec
.
consumer
(
:ios
))
flags
=
@installer
.
send
(
:compiler_flags_for_consumer
,
@spec
.
consumer
(
:ios
)
,
true
)
flags
.
should
.
not
.
include?
(
'-w'
)
flags
.
should
.
not
.
include?
(
'-w'
)
end
end
it
'adds -Xanalyzer -analyzer-disable-checker per pod'
do
it
'adds -Xanalyzer -analyzer-disable-checker per pod'
do
@installer
.
target
.
target_definition
.
stubs
(
:inhibits_warnings_for_pod?
).
returns
(
true
)
@installer
.
target
.
target_definition
.
stubs
(
:inhibits_warnings_for_pod?
).
returns
(
true
)
flags
=
@installer
.
send
(
:compiler_flags_for_consumer
,
@spec
.
consumer
(
:ios
))
flags
=
@installer
.
send
(
:compiler_flags_for_consumer
,
@spec
.
consumer
(
:ios
)
,
true
)
flags
.
should
.
include?
(
'-Xanalyzer -analyzer-disable-checker'
)
flags
.
should
.
include?
(
'-Xanalyzer -analyzer-disable-checker'
)
end
end
it
"doesn't inhibit analyzer warnings by default"
do
it
"doesn't inhibit analyzer warnings by default"
do
flags
=
@installer
.
send
(
:compiler_flags_for_consumer
,
@spec
.
consumer
(
:ios
))
flags
=
@installer
.
send
(
:compiler_flags_for_consumer
,
@spec
.
consumer
(
:ios
)
,
true
)
flags
.
should
.
not
.
include?
(
'-Xanalyzer -analyzer-disable-checker'
)
flags
.
should
.
not
.
include?
(
'-Xanalyzer -analyzer-disable-checker'
)
end
end
describe
'concerning ARC before and after iOS 6.0 and OS X 10.8'
do
describe
'concerning ARC before and after iOS 6.0 and OS X 10.8'
do
it
'does not do anything if ARC is *not* required'
do
it
'does not do anything if ARC is *not* required'
do
@spec
.
requires_arc
=
false
@spec
.
ios
.
deployment_target
=
'5'
@spec
.
ios
.
deployment_target
=
'5'
@spec
.
osx
.
deployment_target
=
'10.6'
@spec
.
osx
.
deployment_target
=
'10.6'
ios_flags
=
@installer
.
send
(
:compiler_flags_for_consumer
,
@spec
.
consumer
(
:ios
))
ios_flags
=
@installer
.
send
(
:compiler_flags_for_consumer
,
@spec
.
consumer
(
:ios
)
,
false
)
osx_flags
=
@installer
.
send
(
:compiler_flags_for_consumer
,
@spec
.
consumer
(
:osx
))
osx_flags
=
@installer
.
send
(
:compiler_flags_for_consumer
,
@spec
.
consumer
(
:osx
)
,
false
)
ios_flags
.
should
.
not
.
include
'-DOS_OBJECT_USE_OBJC'
ios_flags
.
should
.
not
.
include
'-DOS_OBJECT_USE_OBJC'
osx_flags
.
should
.
not
.
include
'-DOS_OBJECT_USE_OBJC'
osx_flags
.
should
.
not
.
include
'-DOS_OBJECT_USE_OBJC'
end
end
it
'does *not* disable the `OS_OBJECT_USE_OBJC` flag if ARC is required and has a deployment target of >= iOS 6.0 or OS X 10.8'
do
it
'does *not* disable the `OS_OBJECT_USE_OBJC` flag if ARC is required and has a deployment target of >= iOS 6.0 or OS X 10.8'
do
@spec
.
requires_arc
=
false
@spec
.
ios
.
deployment_target
=
'6'
@spec
.
ios
.
deployment_target
=
'6'
@spec
.
osx
.
deployment_target
=
'10.8'
@spec
.
osx
.
deployment_target
=
'10.8'
ios_flags
=
@installer
.
send
(
:compiler_flags_for_consumer
,
@spec
.
consumer
(
:ios
))
ios_flags
=
@installer
.
send
(
:compiler_flags_for_consumer
,
@spec
.
consumer
(
:ios
)
,
false
)
osx_flags
=
@installer
.
send
(
:compiler_flags_for_consumer
,
@spec
.
consumer
(
:osx
))
osx_flags
=
@installer
.
send
(
:compiler_flags_for_consumer
,
@spec
.
consumer
(
:osx
)
,
false
)
ios_flags
.
should
.
not
.
include
'-DOS_OBJECT_USE_OBJC'
ios_flags
.
should
.
not
.
include
'-DOS_OBJECT_USE_OBJC'
osx_flags
.
should
.
not
.
include
'-DOS_OBJECT_USE_OBJC'
osx_flags
.
should
.
not
.
include
'-DOS_OBJECT_USE_OBJC'
end
end
it
'*does* disable the `OS_OBJECT_USE_OBJC` flag if ARC is required but has a deployment target < iOS 6.0 or OS X 10.8'
do
it
'*does* disable the `OS_OBJECT_USE_OBJC` flag if ARC is required but has a deployment target < iOS 6.0 or OS X 10.8'
do
@spec
.
requires_arc
=
true
@spec
.
ios
.
deployment_target
=
'5.1'
@spec
.
ios
.
deployment_target
=
'5.1'
@spec
.
osx
.
deployment_target
=
'10.7.2'
@spec
.
osx
.
deployment_target
=
'10.7.2'
ios_flags
=
@installer
.
send
(
:compiler_flags_for_consumer
,
@spec
.
consumer
(
:ios
))
ios_flags
=
@installer
.
send
(
:compiler_flags_for_consumer
,
@spec
.
consumer
(
:ios
)
,
true
)
osx_flags
=
@installer
.
send
(
:compiler_flags_for_consumer
,
@spec
.
consumer
(
:osx
))
osx_flags
=
@installer
.
send
(
:compiler_flags_for_consumer
,
@spec
.
consumer
(
:osx
)
,
true
)
ios_flags
.
should
.
include
'-DOS_OBJECT_USE_OBJC'
ios_flags
.
should
.
include
'-DOS_OBJECT_USE_OBJC'
osx_flags
.
should
.
include
'-DOS_OBJECT_USE_OBJC'
osx_flags
.
should
.
include
'-DOS_OBJECT_USE_OBJC'
end
end
it
'*does* disable the `OS_OBJECT_USE_OBJC` flag if ARC is required and *no* deployment target is specified'
do
it
'*does* disable the `OS_OBJECT_USE_OBJC` flag if ARC is required and *no* deployment target is specified'
do
@spec
.
requires_arc
=
true
ios_flags
=
@installer
.
send
(
:compiler_flags_for_consumer
,
@spec
.
consumer
(
:ios
),
true
)
ios_flags
=
@installer
.
send
(
:compiler_flags_for_consumer
,
@spec
.
consumer
(
:ios
))
osx_flags
=
@installer
.
send
(
:compiler_flags_for_consumer
,
@spec
.
consumer
(
:osx
),
true
)
osx_flags
=
@installer
.
send
(
:compiler_flags_for_consumer
,
@spec
.
consumer
(
:osx
))
ios_flags
.
should
.
include
'-DOS_OBJECT_USE_OBJC'
ios_flags
.
should
.
include
'-DOS_OBJECT_USE_OBJC'
osx_flags
.
should
.
include
'-DOS_OBJECT_USE_OBJC'
osx_flags
.
should
.
include
'-DOS_OBJECT_USE_OBJC'
end
end
...
...
spec/unit/sandbox/file_accessor_spec.rb
View file @
6c15ca8b
...
@@ -53,6 +53,19 @@ module Pod
...
@@ -53,6 +53,19 @@ module Pod
]
]
end
end
it
'returns the source files that use arc'
do
@accessor
.
arc_source_files
.
sort
.
should
==
[
@root
+
'Classes/Banana.h'
,
@root
+
'Classes/Banana.m'
,
@root
+
'Classes/BananaPrivate.h'
,
@root
+
'Classes/BananaTrace.d'
,
]
end
it
'returns the source files that do not use arc'
do
@accessor
.
non_arc_source_files
.
sort
.
should
==
[]
end
it
'returns the header files'
do
it
'returns the header files'
do
@accessor
.
headers
.
sort
.
should
==
[
@accessor
.
headers
.
sort
.
should
==
[
@root
+
'Classes/Banana.h'
,
@root
+
'Classes/Banana.h'
,
...
@@ -166,6 +179,30 @@ module Pod
...
@@ -166,6 +179,30 @@ module Pod
]
]
end
end
describe
'using requires_arc'
do
it
'when false returns all source files as non-arc'
do
@spec_consumer
.
stubs
(
:requires_arc
).
returns
(
false
)
@accessor
.
non_arc_source_files
.
should
==
@accessor
.
source_files
@accessor
.
arc_source_files
.
should
.
be
.
empty?
end
it
'when true returns all source files as arc'
do
@spec_consumer
.
stubs
(
:requires_arc
).
returns
(
true
)
@accessor
.
arc_source_files
.
should
==
@accessor
.
source_files
@accessor
.
non_arc_source_files
.
should
.
be
.
empty?
end
it
'when a file pattern returns all source files as arc that match'
do
@spec_consumer
.
stubs
(
:requires_arc
).
returns
([
'Classes/Banana.m'
])
@accessor
.
arc_source_files
.
should
==
[
@root
+
'Classes/Banana.m'
]
@accessor
.
non_arc_source_files
.
sort
.
should
==
[
@root
+
'Classes/Banana.h'
,
@root
+
'Classes/BananaPrivate.h'
,
@root
+
'Classes/BananaTrace.d'
,
]
end
end
end
end
#-------------------------------------------------------------------------#
#-------------------------------------------------------------------------#
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment