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
ef1a511e
Commit
ef1a511e
authored
Jun 03, 2015
by
Marius Rackwitz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Analyzer] Don't deduplicate PodTargets whose transitive dependencies can't be deduplicated
parent
65c77adb
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
107 additions
and
1 deletion
+107
-1
analyzer.rb
lib/cocoapods/installer/analyzer.rb
+40
-1
fixture.rb
spec/spec_helper/fixture.rb
+4
-0
analyzer_spec.rb
spec/unit/installer/analyzer_spec.rb
+63
-0
No files found.
lib/cocoapods/installer/analyzer.rb
View file @
ef1a511e
...
...
@@ -289,7 +289,7 @@ module Pod
(
hash
[
root_spec
][[
specs
,
target_definition
.
platform
]]
||=
[])
<<
target_definition
end
distinct_targets
.
values
.
flat_map
do
|
targets_by_distinctors
|
pod_targets
=
distinct_targets
.
flat_map
do
|
_
,
targets_by_distinctors
|
if
targets_by_distinctors
.
count
>
1
# There are different sets of subspecs or the spec is used across different platforms
targets_by_distinctors
.
map
do
|
distinctor
,
target_definitions
|
...
...
@@ -301,6 +301,17 @@ module Pod
generate_pod_target
(
target_definitions
,
specs
)
end
end
# A `PodTarget` can't be deduplicated if any of its
# transitive dependencies can't be deduplicated.
pod_targets
.
flat_map
do
|
target
|
dependent_targets
=
transitive_dependencies_for_pod_target
(
target
,
pod_targets
)
if
dependent_targets
.
any?
(
&
:scoped?
)
target
.
scoped
else
target
end
end
else
specs_by_target
.
flat_map
do
|
target_definition
,
specs
|
grouped_specs
=
specs
.
group_by
.
group_by
(
&
:root
).
values
.
uniq
...
...
@@ -311,6 +322,34 @@ module Pod
end
end
# Finds the names of the Pods on which the given target _transitively_
# depends.
#
# @note: This is implemented in the analyzer, because we don't have to
# care about the requirements after dependency resolution.
#
# @param [PodTarget] pod_target
# The pod target, whose dependencies should be returned.
#
# @param [Array<PodTarget>] targets
# All pod targets, which are integrated alongside.
#
# @return [Array<PodTarget>]
#
def
transitive_dependencies_for_pod_target
(
pod_target
,
targets
)
if
targets
.
any?
dependent_targets
=
pod_target
.
dependencies
.
flat_map
do
|
dep
|
targets
.
select
{
|
t
|
t
.
pod_name
==
dep
}
end
remaining_targets
=
targets
-
dependent_targets
dependent_targets
+
dependent_targets
.
flat_map
do
|
target
|
transitive_dependencies_for_pod_target
(
target
,
remaining_targets
)
end
else
[]
end
end
# Create a target for each spec group
#
# @param [TargetDefinitions] target_definitions
...
...
spec/spec_helper/fixture.rb
View file @
ef1a511e
...
...
@@ -9,6 +9,10 @@ module SpecHelper
fixture_copy_path
+
"
#{
fixture_name
}
.xcodeproj"
end
def
self
.
test_repo_url
'https://github.com/CocoaPods/test_repo.git'
end
module
Fixture
ROOT
=
::
ROOT
+
'spec/fixtures'
...
...
spec/unit/installer/analyzer_spec.rb
View file @
ef1a511e
...
...
@@ -114,6 +114,69 @@ module Pod
target
.
platform
.
to_s
.
should
==
'iOS 6.0'
end
describe
'deduplication'
do
before
do
repos
=
[
fixture
(
'spec-repos/test_repo'
),
fixture
(
'spec-repos/master'
)]
aggregate
=
Pod
::
Source
::
Aggregate
.
new
(
repos
)
Pod
::
SourcesManager
.
stubs
(
:aggregate
).
returns
(
aggregate
)
aggregate
.
sources
.
first
.
stubs
(
:url
).
returns
(
SpecHelper
.
test_repo_url
)
end
it
'deduplicate targets if possible'
do
podfile
=
Pod
::
Podfile
.
new
do
source
SpecHelper
.
test_repo_url
platform
:ios
,
'6.0'
xcodeproj
'SampleProject/SampleProject'
pod
'BananaLib'
pod
'monkey'
target
'TestRunner'
do
pod
'BananaLib'
pod
'monkey'
end
end
analyzer
=
Pod
::
Installer
::
Analyzer
.
new
(
config
.
sandbox
,
podfile
)
analyzer
.
analyze
analyzer
.
analyze
.
targets
.
flat_map
{
|
at
|
at
.
pod_targets
.
map
{
|
pt
|
"
#{
at
.
name
}
/
#{
pt
.
name
}
"
}
}.
sort
.
should
==
%w(
Pods/BananaLib
Pods/monkey
Pods-TestRunner/BananaLib
Pods-TestRunner/monkey
)
.
sort
end
it
"doesn't deduplicate targets, where transitive dependencies can't be deduplicated"
do
podfile
=
Pod
::
Podfile
.
new
do
source
SpecHelper
.
test_repo_url
platform
:ios
,
'6.0'
xcodeproj
'SampleProject/SampleProject'
pod
'BananaLib'
pod
'monkey'
target
'TestRunner'
do
pod
'BananaLib'
pod
'monkey'
end
target
'CLITool'
do
platform
:osx
,
'10.10'
pod
'monkey'
end
end
analyzer
=
Pod
::
Installer
::
Analyzer
.
new
(
config
.
sandbox
,
podfile
)
analyzer
.
analyze
analyzer
.
analyze
.
targets
.
flat_map
{
|
at
|
at
.
pod_targets
.
map
{
|
pt
|
"
#{
at
.
name
}
/
#{
pt
.
name
}
"
}
}.
sort
.
should
==
%w(
Pods/Pods-BananaLib
Pods/Pods-monkey
Pods-TestRunner/Pods-TestRunner-BananaLib
Pods-TestRunner/Pods-monkey
Pods-CLITool/Pods-CLITool-monkey
)
.
sort
end
end
it
'generates the integration library appropriately if the installation will not integrate'
do
config
.
integrate_targets
=
false
target
=
@analyzer
.
analyze
.
targets
.
first
...
...
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