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
e65536b2
Commit
e65536b2
authored
Sep 11, 2011
by
Eloy Duran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure that a pod's spec is not installed if it's only part of other pods.
parent
2b933ce8
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
93 additions
and
46 deletions
+93
-46
install.rb
lib/cocoa_pods/command/install.rb
+2
-1
config.rb
lib/cocoa_pods/config.rb
+10
-1
dependency.rb
lib/cocoa_pods/dependency.rb
+1
-0
downloader.rb
lib/cocoa_pods/downloader.rb
+23
-19
resolver.rb
lib/cocoa_pods/resolver.rb
+2
-1
specification.rb
lib/cocoa_pods/specification.rb
+51
-24
set.rb
lib/cocoa_pods/specification/set.rb
+4
-0
No files found.
lib/cocoa_pods/command/install.rb
View file @
e65536b2
...
...
@@ -3,7 +3,8 @@ module Pod
class
Install
<
Command
def
run
if
spec
=
Specification
.
from_podfile
(
podfile
)
spec
.
install_dependent_specifications!
(
pods_root
,
true
)
#config.clean = false
spec
.
install_dependent_specifications!
else
$stderr
.
puts
"No Podfile found in current working directory."
end
...
...
lib/cocoa_pods/config.rb
View file @
e65536b2
...
...
@@ -10,10 +10,19 @@ module Pod
@instance
=
instance
end
attr_accessor
:repos_dir
attr_accessor
:repos_dir
,
:clean
def
initialize
@repos_dir
=
Pathname
.
new
(
File
.
expand_path
(
"~/.cocoa-pods"
))
@clean
=
true
end
def
project_root
Pathname
.
new
(
Dir
.
pwd
)
end
def
project_pods_root
project_root
+
'Pods'
end
module
Mixin
...
...
lib/cocoa_pods/dependency.rb
View file @
e65536b2
...
...
@@ -4,5 +4,6 @@ require 'rubygems/dependency'
module
Pod
class
Dependency
<
Gem
::
Dependency
attr_accessor
:part_of_other_pod
end
end
lib/cocoa_pods/downloader.rb
View file @
e65536b2
...
...
@@ -22,32 +22,36 @@ module Pod
# * sync output
executable
:git
def
source_dir
@pod_root
+
'source'
end
def
download
if
tag
=
@options
[
:tag
]
source_dir
.
mkdir
Dir
.
chdir
(
source_dir
)
do
git
"init"
git
"remote add origin '
#{
@url
}
'"
git
"fetch origin tags/
#{
tag
}
2>&1"
git
"reset --hard FETCH_HEAD"
git
"checkout -b activated-pod-commit 2>&1"
end
elsif
commit
=
@options
[
:commit
]
git
"clone '
#{
@url
}
' '
#{
source_dir
}
'"
Dir
.
chdir
(
source_dir
)
do
git
"checkout -b activated-pod-commit
#{
commit
}
2>&1"
end
if
@options
[
:tag
]
download_tag
elsif
@options
[
:commit
]
download_commit
else
raise
"Either a tag or a commit has to be specified."
end
end
def
download_tag
@pod_root
.
mkdir
Dir
.
chdir
(
@pod_root
)
do
git
"init"
git
"remote add origin '
#{
@url
}
'"
git
"fetch origin tags/
#{
@options
[
:tag
]
}
2>&1"
git
"reset --hard FETCH_HEAD"
git
"checkout -b activated-pod-commit 2>&1"
end
end
def
download_commit
git
"clone '
#{
@url
}
' '
#{
@pod_root
}
'"
Dir
.
chdir
(
@pod_root
)
do
git
"checkout -b activated-pod-commit
#{
@options
[
:commit
]
}
2>&1"
end
end
def
clean
(
source_dir
+
'.git'
).
rmtree
(
@pod_root
+
'.git'
).
rmtree
end
end
end
...
...
lib/cocoa_pods/resolver.rb
View file @
e65536b2
...
...
@@ -7,7 +7,8 @@ module Pod
def
resolve
@sets
=
[]
find_dependency_sets
(
@specification
)
@sets
.
map
(
&
:podspec
)
#@sets.reject(&:only_part_of_other_pod?).map(&:podspec)
@sets
end
def
find_dependency_sets
(
specification
)
...
...
lib/cocoa_pods/specification.rb
View file @
e65536b2
...
...
@@ -64,6 +64,7 @@ module Pod
def
part_of
(
name
,
*
version_requirements
)
#@part_of = Dependency.new(name, *version_requirements)
@part_of
=
dependency
(
name
,
*
version_requirements
)
@part_of
.
part_of_other_pod
=
true
end
def
source_files
(
*
patterns
)
...
...
@@ -83,42 +84,68 @@ module Pod
# Not attributes
def
resolved_dependent_specifications
@resolved_dependent_specifications
||=
Resolver
.
new
(
self
).
resolve
# This also includes those that are only part of other specs, but are not
# actually being used themselves.
def
resolved_dependent_specification_sets
@resolved_dependent_specifications_sets
||=
Resolver
.
new
(
self
).
resolve
end
def
install_dependent_specifications!
(
root
,
clean
)
resolved_dependent_specifications
.
each
do
|
spec
|
install_spec
=
spec
if
part_of_spec_dep
=
spec
.
read
(
:part_of
)
install_spec
=
resolved_dependent_specifications
.
find
{
|
s
|
s
.
read
(
:name
)
==
part_of_spec_dep
.
name
}
puts
"-- Installing:
#{
install_spec
}
for
#{
spec
}
"
else
puts
"-- Installing:
#{
install_spec
}
"
def
install_dependent_specifications!
sets
=
resolved_dependent_specification_sets
sets
.
each
do
|
set
|
# In case the set is only part of other pods we don't need to install
# the pod itself.
next
if
set
.
only_part_of_other_pod?
spec
=
set
.
podspec
spec
.
install!
# In case spec is part of another pod we need to dowload the other
# pod's source.
if
spec
.
part_of_other_pod?
# Find the specification of the pod that spec's source is a part of.
part_of_name
=
spec
.
read
(
:part_of
).
name
spec
=
sets
.
find
{
|
set
|
set
.
name
==
part_of_name
}.
podspec
end
install_spec
.
install!
(
root
,
clean
)
spec
.
download_if_necessary!
end
end
# User can override this for custom installation
def
install!
(
pods_root
,
clean
)
include
Config
::
Mixin
def
pod_destroot
config
.
project_pods_root
+
"
#{
@name
}
-
#{
@version
}
"
end
# Places the activated podspec in the project's pods directory.
def
install!
puts
"==> Installing:
#{
self
}
"
config
.
project_pods_root
.
mkpath
require
'fileutils'
pods_root
.
mkpath
pod_root
=
pods_root
+
"
#{
@name
}
-
#{
@version
}
"
if
pod_root
.
exist?
puts
" Skipping, the pod already exists:
#{
pod_root
}
"
FileUtils
.
cp
(
@defined_in_file
,
config
.
project_pods_root
)
end
def
download_if_necessary!
if
pod_destroot
.
exist?
puts
" * Skipping download of
#{
self
}
, pod already downloaded"
else
pod_root
.
mkdir
FileUtils
.
cp
(
@defined_in_file
,
pod_root
)
download_to
(
pod_root
,
clean
)
puts
" * Downloading:
#{
self
}
"
download!
end
end
# User can override this for custom downloading
def
download_to
(
pod_root
,
clean
)
downloader
=
Downloader
.
for_source
(
@source
,
pod_root
)
# Downloads the source of the pod and places it in the project's pods
# directory.
#
# You can override this for custom downloading.
def
download!
downloader
=
Downloader
.
for_source
(
@source
,
pod_destroot
)
downloader
.
download
downloader
.
clean
if
clean
downloader
.
clean
if
config
.
clean
end
def
part_of_other_pod?
!
@part_of
.
nil?
end
def
from_podfile?
...
...
lib/cocoa_pods/specification/set.rb
View file @
e65536b2
...
...
@@ -20,6 +20,10 @@ module Pod
@required_by
.
inject
(
Dependency
.
new
(
name
))
{
|
previous
,
(
_
,
dep
)
|
previous
.
merge
(
dep
)
}
end
def
only_part_of_other_pod?
@required_by
.
all?
{
|
_
,
dep
|
dep
.
part_of_other_pod
}
end
def
name
@pod_dir
.
basename
.
to_s
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