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
99d20425
Commit
99d20425
authored
May 09, 2012
by
Fabio Pelosin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplified resolution process and implemented `main_subspec' substitution.
parent
87778d87
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
33 additions
and
29 deletions
+33
-29
dependency.rb
lib/cocoapods/dependency.rb
+1
-1
resolver.rb
lib/cocoapods/resolver.rb
+2
-13
source.rb
lib/cocoapods/source.rb
+1
-1
specification.rb
lib/cocoapods/specification.rb
+16
-11
set.rb
lib/cocoapods/specification/set.rb
+8
-1
resolver_spec.rb
spec/unit/resolver_spec.rb
+5
-2
No files found.
lib/cocoapods/dependency.rb
View file @
99d20425
...
@@ -14,7 +14,7 @@ module Pod
...
@@ -14,7 +14,7 @@ module Pod
def
initialize
(
*
name_and_version_requirements
,
&
block
)
def
initialize
(
*
name_and_version_requirements
,
&
block
)
if
name_and_version_requirements
.
empty?
&&
block
if
name_and_version_requirements
.
empty?
&&
block
@inline_podspec
=
true
@inline_podspec
=
true
@specification
=
Specification
.
new
(
&
block
)
@specification
=
Specification
.
new
(
&
block
)
.
main_subspec
super
(
@specification
.
name
,
@specification
.
version
)
super
(
@specification
.
name
,
@specification
.
version
)
elsif
!
name_and_version_requirements
.
empty?
&&
block
.
nil?
elsif
!
name_and_version_requirements
.
empty?
&&
block
.
nil?
...
...
lib/cocoapods/resolver.rb
View file @
99d20425
...
@@ -22,13 +22,11 @@ module Pod
...
@@ -22,13 +22,11 @@ module Pod
@podfile
.
target_definitions
.
values
.
each
do
|
target_definition
|
@podfile
.
target_definitions
.
values
.
each
do
|
target_definition
|
puts
"
\n
Resolving dependencies for target `
#{
target_definition
.
name
}
' (
#{
target_definition
.
platform
}
)"
.
green
if
config
.
verbose?
puts
"
\n
Resolving dependencies for target `
#{
target_definition
.
name
}
' (
#{
target_definition
.
platform
}
)"
.
green
if
config
.
verbose?
@loaded_specs
=
[]
@loaded_specs
=
[]
# TODO @podfile.platform will change to target_definition.platform
find_dependency_sets
(
@podfile
,
target_definition
.
dependencies
,
target_definition
)
find_dependency_sets
(
@podfile
,
target_definition
.
dependencies
,
target_definition
)
targets_and_specs
[
target_definition
]
=
@specs
.
values_at
(
*
@loaded_specs
).
sort_by
(
&
:name
)
targets_and_specs
[
target_definition
]
=
@specs
.
values_at
(
*
@loaded_specs
).
sort_by
(
&
:name
)
end
end
@specs
.
values
.
sort_by
(
&
:name
)
@specs
.
values
.
sort_by
(
&
:name
)
targets_and_specs
targets_and_specs
end
end
...
@@ -59,20 +57,11 @@ module Pod
...
@@ -59,20 +57,11 @@ module Pod
set
.
required_by
(
dependent_specification
)
set
.
required_by
(
dependent_specification
)
# Ensure we don't resolve the same spec twice for one target
# Ensure we don't resolve the same spec twice for one target
unless
@loaded_specs
.
include?
(
dependency
.
name
)
unless
@loaded_specs
.
include?
(
dependency
.
name
)
# Get a reference to the spec that’s actually being loaded.
spec
=
set
.
specification_by_name
(
dependency
.
name
)
# If it’s a subspec dependency, e.g. 'RestKit/Network', then
# find that subspec.
spec
=
set
.
specification
if
dependency
.
subspec_dependency?
spec
=
spec
.
subspec_by_name
(
dependency
.
name
)
end
@loaded_specs
<<
spec
.
name
@loaded_specs
<<
spec
.
name
@specs
[
spec
.
name
]
=
spec
@specs
[
spec
.
name
]
=
spec
# And recursively load the dependencies of the spec.
# And recursively load the dependencies of the spec.
# TODO fix the need to return an empty arrayf if there are no deps for the given platform
find_dependency_sets
(
spec
,
(
spec
.
dependencies
[
target_definition
.
platform
.
to_sym
]),
target_definition
)
if
spec
.
dependencies
[
target_definition
.
platform
.
to_sym
]
find_dependency_sets
(
spec
,
(
spec
.
dependencies
[
target_definition
.
platform
.
to_sym
]
||
[]),
target_definition
)
end
end
validate_platform!
(
spec
||
@specs
[
dependency
.
name
],
target_definition
)
validate_platform!
(
spec
||
@specs
[
dependency
.
name
],
target_definition
)
end
end
...
...
lib/cocoapods/source.rb
View file @
99d20425
...
@@ -68,7 +68,7 @@ module Pod
...
@@ -68,7 +68,7 @@ module Pod
set
.
name
==
dependency
.
top_level_spec_name
&&
set
.
name
==
dependency
.
top_level_spec_name
&&
# Now either check if it's a dependency on the top level spec, or if it's not
# Now either check if it's a dependency on the top level spec, or if it's not
# check if the requested subspec exists in the top level spec.
# check if the requested subspec exists in the top level spec.
(
!
dependency
.
subspec_dependency?
||
!
set
.
specification
.
subspec_by_name
(
dependency
.
name
).
nil?
)
set
.
specification
.
subspec_by_name
(
dependency
.
name
)
end
end
end
end
...
...
lib/cocoapods/specification.rb
View file @
99d20425
...
@@ -74,7 +74,12 @@ module Pod
...
@@ -74,7 +74,12 @@ module Pod
@platform
.
nil?
?
@define_for_platforms
.
map
{
|
platform
|
Platform
.
new
(
platform
,
@deployment_target
[
platform
])
}
:
[
platform
]
@platform
.
nil?
?
@define_for_platforms
.
map
{
|
platform
|
Platform
.
new
(
platform
,
@deployment_target
[
platform
])
}
:
[
platform
]
end
end
attr_accessor
:main_subspec
attr_writer
:main_subspec
def
main_subspec
return
self
unless
@main_subspec
subspecs
.
find
{
|
s
|
s
.
name
==
"
#{
self
.
name
}
/
#{
@main_subspec
}
"
}
end
### Top level attributes. These attributes represent the unique features of pod and can't be specified by subspecs.
### Top level attributes. These attributes represent the unique features of pod and can't be specified by subspecs.
...
@@ -256,7 +261,7 @@ module Pod
...
@@ -256,7 +261,7 @@ module Pod
def
dependencies
def
dependencies
result
=
{}
result
=
{}
@define_for_platforms
.
each
do
|
platform
|
@define_for_platforms
.
each
do
|
platform
|
inherited_subspecs
=
main_subspec
?
[
Dependency
.
new
(
"
#{
name
}
/
#{
main_subspec
}
"
,
version
)]
:
subspecs
.
map
{
|
s
|
Dependency
.
new
(
s
.
name
,
version
)
}
inherited_subspecs
=
subspecs
.
map
{
|
s
|
Dependency
.
new
(
s
.
name
,
version
)
}
result
[
platform
]
=
@dependencies
[
platform
]
+
inherited_subspecs
result
[
platform
]
=
@dependencies
[
platform
]
+
inherited_subspecs
end
end
result
result
...
@@ -306,7 +311,7 @@ module Pod
...
@@ -306,7 +311,7 @@ module Pod
end
end
def
subspec_by_name
(
name
)
def
subspec_by_name
(
name
)
return
self
if
name
.
nil?
||
name
==
self
.
name
return
main_subspec
if
name
.
nil?
||
name
==
self
.
name
# Remove this spec's name from the beginning of the name we’re looking for
# Remove this spec's name from the beginning of the name we’re looking for
# and take the first component from the remainder, which is the spec we need
# and take the first component from the remainder, which is the spec we need
# to find now.
# to find now.
...
@@ -390,6 +395,14 @@ module Pod
...
@@ -390,6 +395,14 @@ module Pod
false
false
end
end
def
dependency_by_top_level_spec_name
(
name
)
@dependencies
.
each
do
|
_
,
platform_deps
|
platform_deps
.
each
do
|
dep
|
return
dep
if
dep
.
top_level_spec_name
==
name
end
end
end
def
to_s
def
to_s
"
#{
name
}
(
#{
version
}
)"
"
#{
name
}
(
#{
version
}
)"
end
end
...
@@ -398,14 +411,6 @@ module Pod
...
@@ -398,14 +411,6 @@ module Pod
"#<
#{
self
.
class
.
name
}
for
#{
to_s
}
>"
"#<
#{
self
.
class
.
name
}
for
#{
to_s
}
>"
end
end
def
dependency_by_top_level_spec_name
(
name
)
dependencies
.
each
do
|
_
,
platform_deps
|
platform_deps
.
each
do
|
dep
|
return
dep
if
dep
.
top_level_spec_name
==
name
end
end
end
def
==
(
other
)
def
==
(
other
)
object_id
==
other
.
object_id
||
object_id
==
other
.
object_id
||
(
self
.
class
===
other
&&
(
self
.
class
===
other
&&
...
...
lib/cocoapods/specification/set.rb
View file @
99d20425
...
@@ -9,6 +9,9 @@ module Pod
...
@@ -9,6 +9,9 @@ module Pod
end
end
def
required_by
(
specification
)
def
required_by
(
specification
)
# Skip subspecs because the can't require a different version of the top level parent
return
if
!
specification
.
podfile?
&&
specification
.
top_level_parent
.
name
==
name
dependency
=
specification
.
dependency_by_top_level_spec_name
(
name
)
dependency
=
specification
.
dependency_by_top_level_spec_name
(
name
)
# TODO we don’t actually do anything in our Version subclass. Maybe we should just remove that.
# TODO we don’t actually do anything in our Version subclass. Maybe we should just remove that.
unless
@required_by
.
empty?
||
dependency
.
requirement
.
satisfied_by?
(
Gem
::
Version
.
new
(
required_version
.
to_s
))
unless
@required_by
.
empty?
||
dependency
.
requirement
.
satisfied_by?
(
Gem
::
Version
.
new
(
required_version
.
to_s
))
...
@@ -21,6 +24,10 @@ module Pod
...
@@ -21,6 +24,10 @@ module Pod
@required_by
<<
specification
@required_by
<<
specification
end
end
def
specification_by_name
(
name
)
specification
.
top_level_parent
.
subspec_by_name
(
name
)
end
def
dependency
def
dependency
@required_by
.
inject
(
Dependency
.
new
(
name
))
do
|
previous
,
spec
|
@required_by
.
inject
(
Dependency
.
new
(
name
))
do
|
previous
,
spec
|
previous
.
merge
(
spec
.
dependency_by_top_level_spec_name
(
name
).
to_top_level_spec_dependency
)
previous
.
merge
(
spec
.
dependency_by_top_level_spec_name
(
name
).
to_top_level_spec_dependency
)
...
@@ -70,7 +77,7 @@ module Pod
...
@@ -70,7 +77,7 @@ module Pod
end
end
def
name
def
name
@specification
.
name
@specification
.
top_level_parent
.
name
end
end
def
==
(
other
)
def
==
(
other
)
...
...
spec/unit/resolver_spec.rb
View file @
99d20425
...
@@ -131,7 +131,9 @@ describe "Pod::Resolver" do
...
@@ -131,7 +131,9 @@ describe "Pod::Resolver" do
js
.
dependency
'RestKit/ObjectMapping/CoreData'
js
.
dependency
'RestKit/ObjectMapping/CoreData'
end
end
s
.
subspec
'Network'
s
.
subspec
'Network'
do
|
ns
|
ns
.
dependency
'LibComponentLogging-NSLog'
,
'>= 1.0.4'
end
s
.
subspec
'UI'
s
.
subspec
'UI'
s
.
subspec
'ObjectMapping'
do
|
os
|
s
.
subspec
'ObjectMapping'
do
|
os
|
os
.
subspec
'JSON'
os
.
subspec
'JSON'
...
@@ -142,7 +144,8 @@ describe "Pod::Resolver" do
...
@@ -142,7 +144,8 @@ describe "Pod::Resolver" do
end
end
resolver
=
Pod
::
Resolver
.
new
(
@podfile
,
stub
(
'sandbox'
))
resolver
=
Pod
::
Resolver
.
new
(
@podfile
,
stub
(
'sandbox'
))
resolver
.
resolve
.
values
.
flatten
.
map
(
&
:name
).
sort
.
should
==
%w{
resolver
.
resolve
.
values
.
flatten
.
map
(
&
:name
).
sort
.
should
==
%w{
RestKit
LibComponentLogging-Core
LibComponentLogging-NSLog
RestKit/JSON
RestKit/JSON
RestKit/Network
RestKit/Network
RestKit/ObjectMapping/CoreData
RestKit/ObjectMapping/CoreData
...
...
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