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
78e90aa2
Commit
78e90aa2
authored
May 08, 2015
by
Marius Rackwitz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Deduplicate pod targets
parent
279ff119
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
67 additions
and
18 deletions
+67
-18
aggregate_xcconfig.rb
lib/cocoapods/generator/xcconfig/aggregate_xcconfig.rb
+8
-2
private_pod_xcconfig.rb
lib/cocoapods/generator/xcconfig/private_pod_xcconfig.rb
+2
-2
analyzer.rb
lib/cocoapods/installer/analyzer.rb
+25
-5
pod_target_installer.rb
...oapods/installer/target_installer/pod_target_installer.rb
+1
-1
pod_target.rb
lib/cocoapods/target/pod_target.rb
+12
-2
analyzer_spec.rb
spec/unit/installer/analyzer_spec.rb
+19
-6
No files found.
lib/cocoapods/generator/xcconfig/aggregate_xcconfig.rb
View file @
78e90aa2
...
@@ -57,13 +57,19 @@ module Pod
...
@@ -57,13 +57,19 @@ module Pod
if
target
.
requires_frameworks?
if
target
.
requires_frameworks?
# Framework headers are automatically discoverable by `#import <…>`.
# Framework headers are automatically discoverable by `#import <…>`.
header_search_paths
=
pod_targets
.
map
{
|
target
|
"$PODS_FRAMEWORK_BUILD_PATH/
#{
target
.
product_name
}
/Headers"
}
header_search_paths
=
pod_targets
.
map
do
|
target
|
if
target
.
scoped?
"$PODS_FRAMEWORK_BUILD_PATH/
#{
target
.
product_name
}
/Headers"
else
"$CONFIGURATION_BUILD_DIR/
#{
target
.
product_name
}
/Headers"
end
end
build_settings
=
{
build_settings
=
{
'PODS_FRAMEWORK_BUILD_PATH'
=>
target
.
configuration_build_dir
,
'PODS_FRAMEWORK_BUILD_PATH'
=>
target
.
configuration_build_dir
,
# Make headers discoverable by `import "…"`
# Make headers discoverable by `import "…"`
'OTHER_CFLAGS'
=>
'$(inherited) '
+
XCConfigHelper
.
quote
(
header_search_paths
,
'-iquote'
),
'OTHER_CFLAGS'
=>
'$(inherited) '
+
XCConfigHelper
.
quote
(
header_search_paths
,
'-iquote'
),
}
}
if
target
.
pod_targets
.
any?
(
&
:should_build?
)
if
target
.
pod_targets
.
any?
{
|
t
|
t
.
should_build?
&&
t
.
scoped?
}
build_settings
[
'FRAMEWORK_SEARCH_PATHS'
]
=
'$(inherited) "$PODS_FRAMEWORK_BUILD_PATH"'
build_settings
[
'FRAMEWORK_SEARCH_PATHS'
]
=
'$(inherited) "$PODS_FRAMEWORK_BUILD_PATH"'
end
end
config
.
merge!
(
build_settings
)
config
.
merge!
(
build_settings
)
...
...
lib/cocoapods/generator/xcconfig/private_pod_xcconfig.rb
View file @
78e90aa2
...
@@ -60,13 +60,13 @@ module Pod
...
@@ -60,13 +60,13 @@ module Pod
# 'USE_HEADERMAP' => 'NO'
# 'USE_HEADERMAP' => 'NO'
}
}
if
target
.
requires_frameworks?
if
target
.
requires_frameworks?
&&
target
.
scoped?
# Only quote the FRAMEWORK_SEARCH_PATHS entry, because it’s a setting that takes multiple values.
# Only quote the FRAMEWORK_SEARCH_PATHS entry, because it’s a setting that takes multiple values.
# In addition, quoting CONFIGURATION_BUILD_DIR would make it be interpreted as a relative path.
# In addition, quoting CONFIGURATION_BUILD_DIR would make it be interpreted as a relative path.
build_settings
=
{
build_settings
=
{
'PODS_FRAMEWORK_BUILD_PATH'
=>
target
.
configuration_build_dir
,
'PODS_FRAMEWORK_BUILD_PATH'
=>
target
.
configuration_build_dir
,
'CONFIGURATION_BUILD_DIR'
=>
'$PODS_FRAMEWORK_BUILD_PATH'
,
'FRAMEWORK_SEARCH_PATHS'
=>
'"$PODS_FRAMEWORK_BUILD_PATH"'
,
'FRAMEWORK_SEARCH_PATHS'
=>
'"$PODS_FRAMEWORK_BUILD_PATH"'
,
'CONFIGURATION_BUILD_DIR'
=>
'$PODS_FRAMEWORK_BUILD_PATH'
,
}
}
config
.
merge!
(
build_settings
)
config
.
merge!
(
build_settings
)
end
end
...
...
lib/cocoapods/installer/analyzer.rb
View file @
78e90aa2
...
@@ -220,7 +220,7 @@ module Pod
...
@@ -220,7 +220,7 @@ module Pod
def
generate_targets
def
generate_targets
targets
=
[]
targets
=
[]
result
.
specs_by_target
.
each
do
|
target_definition
,
specs
|
result
.
specs_by_target
.
each
do
|
target_definition
,
specs
|
targets
<<
generate_target
(
target_definition
,
specs
)
targets
<<
generate_target
(
target_definition
,
specs
,
targets
.
map
(
&
:pod_targets
).
flatten
)
end
end
targets
targets
end
end
...
@@ -234,9 +234,12 @@ module Pod
...
@@ -234,9 +234,12 @@ module Pod
# the specifications that need to be installed grouped by the
# the specifications that need to be installed grouped by the
# given target definition.
# given target definition.
#
#
# @param [Array<PodTarget>] pod_targets
# the pod targets, which were generated so far.
#
# @return [AggregateTarget]
# @return [AggregateTarget]
#
#
def
generate_target
(
target_definition
,
specs
)
def
generate_target
(
target_definition
,
specs
,
pod_targets
)
target
=
AggregateTarget
.
new
(
target_definition
,
sandbox
)
target
=
AggregateTarget
.
new
(
target_definition
,
sandbox
)
target
.
host_requires_frameworks
|=
target_definition
.
uses_frameworks?
target
.
host_requires_frameworks
|=
target_definition
.
uses_frameworks?
...
@@ -259,7 +262,7 @@ module Pod
...
@@ -259,7 +262,7 @@ module Pod
end
end
end
end
target
.
pod_targets
=
generate_pod_targets
(
target
,
specs
)
target
.
pod_targets
=
generate_pod_targets
(
target
,
specs
,
pod_targets
)
target
target
end
end
...
@@ -273,12 +276,29 @@ module Pod
...
@@ -273,12 +276,29 @@ module Pod
# @param [Array<Specification>] specs
# @param [Array<Specification>] specs
# the specifications that need to be installed.
# the specifications that need to be installed.
#
#
# @param [Array<PodTarget>] pod_targets
# the pod targets, which were generated so far.
#
# @return [Array<PodTarget>]
# @return [Array<PodTarget>]
#
#
def
generate_pod_targets
(
target
,
specs
)
def
generate_pod_targets
(
target
,
specs
,
pod_targets
)
grouped_specs
=
specs
.
group_by
(
&
:root
).
values
.
uniq
grouped_specs
=
specs
.
group_by
(
&
:root
).
values
.
uniq
grouped_specs
.
map
do
|
pod_specs
|
grouped_specs
.
map
do
|
pod_specs
|
generate_pod_target
(
target
,
pod_specs
)
# If there are no or already multiple pod targets with a common root,
# or the one which exists differs in the activated subspec set, then
# we need to generate another pod target
root_spec
=
pod_specs
.
first
.
root
common_root_pod_targets
=
pod_targets
.
select
{
|
t
|
t
.
root_spec
==
root_spec
}
if
common_root_pod_targets
.
count
!=
1
||
common_root_pod_targets
.
first
.
specs
!=
pod_specs
pod_target
=
generate_pod_target
(
target
,
pod_specs
)
unless
common_root_pod_targets
.
empty?
common_root_pod_targets
.
each
{
|
t
|
t
.
scoped
=
true
}
pod_target
.
scoped
=
true
end
pod_target
else
common_root_pod_targets
.
first
end
end
end
end
end
...
...
lib/cocoapods/installer/target_installer/pod_target_installer.rb
View file @
78e90aa2
...
@@ -130,7 +130,7 @@ module Pod
...
@@ -130,7 +130,7 @@ module Pod
bundle_target
.
build_configurations
.
each
do
|
c
|
bundle_target
.
build_configurations
.
each
do
|
c
|
c
.
build_settings
[
'PRODUCT_NAME'
]
=
bundle_name
c
.
build_settings
[
'PRODUCT_NAME'
]
=
bundle_name
if
target
.
requires_frameworks?
if
target
.
requires_frameworks?
&&
target
.
scoped?
c
.
build_settings
[
'CONFIGURATION_BUILD_DIR'
]
=
target
.
configuration_build_dir
c
.
build_settings
[
'CONFIGURATION_BUILD_DIR'
]
=
target
.
configuration_build_dir
end
end
end
end
...
...
lib/cocoapods/target/pod_target.rb
View file @
78e90aa2
...
@@ -3,7 +3,7 @@ module Pod
...
@@ -3,7 +3,7 @@ module Pod
# A pod can have one or more activated spec/subspecs.
# A pod can have one or more activated spec/subspecs.
#
#
class
PodTarget
<
Target
class
PodTarget
<
Target
# @return [
Specification] the spec
for the target.
# @return [
Array<Specification>] the spec and subspecs
for the target.
#
#
attr_reader
:specs
attr_reader
:specs
...
@@ -11,6 +11,12 @@ module Pod
...
@@ -11,6 +11,12 @@ module Pod
#
#
attr_reader
:build_headers
attr_reader
:build_headers
# @return [Bool] whether the target needs to be scoped by target definition,
# because the spec is used with different subspec sets across them.
#
attr_accessor
:scoped
alias_method
:scoped?
,
:scoped
# @param [Specification] spec @see spec
# @param [Specification] spec @see spec
# @param [TargetDefinition] target_definition @see target_definition
# @param [TargetDefinition] target_definition @see target_definition
# @param [Sandbox] sandbox @see sandbox
# @param [Sandbox] sandbox @see sandbox
...
@@ -27,7 +33,11 @@ module Pod
...
@@ -27,7 +33,11 @@ module Pod
# @return [String] the label for the target.
# @return [String] the label for the target.
#
#
def
label
def
label
"
#{
target_definition
.
label
}
-
#{
root_spec
.
name
}
"
if
scoped?
"
#{
target_definition
.
label
}
-
#{
root_spec
.
name
}
"
else
root_spec
.
name
end
end
end
# @return [String] The name to use for the source code module constructed
# @return [String] The name to use for the source code module constructed
...
...
spec/unit/installer/analyzer_spec.rb
View file @
78e90aa2
...
@@ -13,6 +13,11 @@ module Pod
...
@@ -13,6 +13,11 @@ module Pod
pod
'AFNetworking'
,
'1.0.1'
pod
'AFNetworking'
,
'1.0.1'
pod
'SVPullToRefresh'
,
'0.4'
pod
'SVPullToRefresh'
,
'0.4'
pod
'libextobjc/EXTKeyPathCoding'
,
'0.2.3'
pod
'libextobjc/EXTKeyPathCoding'
,
'0.2.3'
target
'TestRunner'
do
pod
'libextobjc/EXTKeyPathCoding'
,
'0.2.3'
pod
'libextobjc/EXTSynthesize'
,
'0.2.3'
end
end
end
hash
=
{}
hash
=
{}
...
@@ -44,7 +49,7 @@ module Pod
...
@@ -44,7 +49,7 @@ module Pod
it
'computes the state of the Podfile respect to the Lockfile'
do
it
'computes the state of the Podfile respect to the Lockfile'
do
state
=
@analyzer
.
analyze
.
podfile_state
state
=
@analyzer
.
analyze
.
podfile_state
state
.
added
.
should
==
%w(AFNetworking libextobjc/EXTKeyPathCoding)
state
.
added
.
should
==
%w(AFNetworking libextobjc/EXTKeyPathCoding
libextobjc/EXTSynthesize
)
state
.
changed
.
should
==
%w()
state
.
changed
.
should
==
%w()
state
.
unchanged
.
should
==
%w(JSONKit SVPullToRefresh)
state
.
unchanged
.
should
==
%w(JSONKit SVPullToRefresh)
state
.
deleted
.
should
==
%w(NUI)
state
.
deleted
.
should
==
%w(NUI)
...
@@ -87,12 +92,12 @@ module Pod
...
@@ -87,12 +92,12 @@ module Pod
#--------------------------------------#
#--------------------------------------#
it
'generates the
libraries which
represent the target definitions'
do
it
'generates the
model to
represent the target definitions'
do
target
=
@analyzer
.
analyze
.
targets
.
first
target
=
@analyzer
.
analyze
.
targets
.
first
target
.
pod_targets
.
map
(
&
:name
).
sort
.
should
==
[
target
.
pod_targets
.
map
(
&
:name
).
sort
.
should
==
[
'
Pods-
JSONKit'
,
'JSONKit'
,
'
Pods-
AFNetworking'
,
'AFNetworking'
,
'
Pods-
SVPullToRefresh'
,
'SVPullToRefresh'
,
'Pods-libextobjc'
,
'Pods-libextobjc'
,
].
sort
].
sort
target
.
support_files_dir
.
should
==
config
.
sandbox
.
target_support_files_dir
(
'Pods'
)
target
.
support_files_dir
.
should
==
config
.
sandbox
.
target_support_files_dir
(
'Pods'
)
...
@@ -256,6 +261,7 @@ module Pod
...
@@ -256,6 +261,7 @@ module Pod
'JSONKit (1.5pre)'
,
'JSONKit (1.5pre)'
,
'SVPullToRefresh (0.4)'
,
'SVPullToRefresh (0.4)'
,
'libextobjc/EXTKeyPathCoding (0.2.3)'
,
'libextobjc/EXTKeyPathCoding (0.2.3)'
,
'libextobjc/EXTSynthesize (0.2.3)'
,
]
]
end
end
...
@@ -275,11 +281,18 @@ module Pod
...
@@ -275,11 +281,18 @@ module Pod
end
end
it
'adds the specifications to the correspondent libraries'
do
it
'adds the specifications to the correspondent libraries'
do
@analyzer
.
analyze
.
targets
.
first
.
pod_targets
.
map
(
&
:specs
).
flatten
.
map
(
&
:to_s
).
should
==
[
@analyzer
.
analyze
.
targets
[
0
].
pod_targets
.
map
(
&
:specs
).
flatten
.
map
(
&
:to_s
).
should
==
[
'AFNetworking (1.0.1)'
,
'JSONKit (1.5pre)'
,
'SVPullToRefresh (0.4)'
,
'libextobjc/EXTKeyPathCoding (0.2.3)'
,
]
@analyzer
.
analyze
.
targets
[
1
].
pod_targets
.
map
(
&
:specs
).
flatten
.
map
(
&
:to_s
).
should
==
[
'AFNetworking (1.0.1)'
,
'AFNetworking (1.0.1)'
,
'JSONKit (1.5pre)'
,
'JSONKit (1.5pre)'
,
'SVPullToRefresh (0.4)'
,
'SVPullToRefresh (0.4)'
,
'libextobjc/EXTKeyPathCoding (0.2.3)'
,
'libextobjc/EXTKeyPathCoding (0.2.3)'
,
'libextobjc/EXTSynthesize (0.2.3)'
,
]
]
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