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
cac18c84
Commit
cac18c84
authored
May 15, 2012
by
Fabio Pelosin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
LocalPod clean up.
parent
b863ece7
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
31 deletions
+43
-31
local_pod.rb
lib/cocoapods/local_pod.rb
+43
-31
No files found.
lib/cocoapods/local_pod.rb
View file @
cac18c84
...
@@ -13,17 +13,20 @@ module Pod
...
@@ -13,17 +13,20 @@ module Pod
new
(
Specification
.
from_file
(
podspec
),
sandbox
,
platform
)
new
(
Specification
.
from_file
(
podspec
),
sandbox
,
platform
)
end
end
def
root
# Method to add the specifications sharing the same top level
@sandbox
.
root
+
top_specification
.
name
# parent. With this information the local pod can determine the
end
# paths to clean and avoid duplication in file processing.
# Adding specifications is idempotent.
# Adding specifications is idempotent
def
add_specification
(
spec
)
def
add_specification
(
spec
)
raise
Informative
,
"[Local Pod] Attempt to add a specification from another pod"
unless
spec
.
top_level_parent
==
top_specification
raise
Informative
,
"[Local Pod] Attempt to add a specification from another pod"
unless
spec
.
top_level_parent
==
top_specification
spec
.
activate_platform
(
platform
)
spec
.
activate_platform
(
platform
)
@specifications
<<
spec
unless
@specifications
.
include?
(
spec
)
@specifications
<<
spec
unless
@specifications
.
include?
(
spec
)
end
end
def
root
@sandbox
.
root
+
top_specification
.
name
end
def
subspecs
def
subspecs
specifications
.
reject
{
|
s
|
s
.
parent
.
nil?
}
specifications
.
reject
{
|
s
|
s
.
parent
.
nil?
}
end
end
...
@@ -42,6 +45,8 @@ module Pod
...
@@ -42,6 +45,8 @@ module Pod
top_specification
.
active_platform
top_specification
.
active_platform
end
end
# Installation methods
def
create
def
create
root
.
mkpath
unless
exists?
root
.
mkpath
unless
exists?
end
end
...
@@ -59,10 +64,10 @@ module Pod
...
@@ -59,10 +64,10 @@ module Pod
root
.
rmtree
if
exists?
root
.
rmtree
if
exists?
end
end
# It deletes all the files identified by clean_paths, then it removes
# all the empty folders or symlinks.
def
clean
def
clean
clean_paths
.
each
{
|
path
|
FileUtils
.
rm_rf
(
path
)
}
clean_paths
.
each
{
|
path
|
FileUtils
.
rm_rf
(
path
)
}
# remove empty diretories
Dir
.
glob
(
"
#{
root
}
/**/{*,.*}"
).
Dir
.
glob
(
"
#{
root
}
/**/{*,.*}"
).
sort_by
(
&
:length
).
reverse
.
# Clean the deepest paths first to determine if the containing folders are empty
sort_by
(
&
:length
).
reverse
.
# Clean the deepest paths first to determine if the containing folders are empty
reject
{
|
d
|
d
=~
/\/\.\.?$/
}
.
# Remove the `.` and `..` paths
reject
{
|
d
|
d
=~
/\/\.\.?$/
}
.
# Remove the `.` and `..` paths
...
@@ -72,6 +77,8 @@ module Pod
...
@@ -72,6 +77,8 @@ module Pod
end
end
end
end
# File attributes
def
prefix_header_file
def
prefix_header_file
if
prefix_header
=
top_specification
.
prefix_header_file
if
prefix_header
=
top_specification
.
prefix_header_file
@sandbox
.
root
+
top_specification
.
name
+
prefix_header
@sandbox
.
root
+
top_specification
.
name
+
prefix_header
...
@@ -110,16 +117,18 @@ module Pod
...
@@ -110,16 +117,18 @@ module Pod
source_files
.
select
{
|
f
|
f
.
extname
==
'.h'
}
source_files
.
select
{
|
f
|
f
.
extname
==
'.h'
}
end
end
def
xcconfig
specifications
.
map
{
|
s
|
s
.
xcconfig
}.
reduce
(
:merge
)
end
# Integration methods
def
link_headers
def
link_headers
copy_header_mappings
.
each
do
|
namespaced_path
,
files
|
copy_header_mappings
.
each
do
|
namespaced_path
,
files
|
@sandbox
.
add_header_files
(
namespaced_path
,
files
)
@sandbox
.
add_header_files
(
namespaced_path
,
files
)
end
end
end
end
def
xcconfig
specifications
.
map
{
|
s
|
s
.
xcconfig
}.
reduce
(
:merge
)
end
def
add_to_target
(
target
)
def
add_to_target
(
target
)
sources_files_by_specification
.
each
do
|
spec
,
files
|
sources_files_by_specification
.
each
do
|
spec
,
files
|
files
.
each
do
|
file
|
files
.
each
do
|
file
|
...
@@ -128,30 +137,13 @@ module Pod
...
@@ -128,30 +137,13 @@ module Pod
end
end
end
end
# returns an hash where the source_files are groupped by specification.
# If the same file is required by two specifications the one at the
# higher level in the inheritance chain wins.
def
sources_files_by_specification
files_by_spec
=
{}
processed_files
=
[]
specifications
.
sort_by
{
|
s
|
s
.
name
.
length
}.
each
do
|
spec
|
files
=
[]
expanded_paths
(
spec
.
source_files
,
:glob
=>
'*.{h,m,mm,c,cpp}'
,
:relative_to_sandbox
=>
true
).
each
do
|
file
|
files
<<
file
unless
processed_files
.
include?
(
file
)
end
files_by_spec
[
spec
]
=
files
processed_files
+=
files
end
files_by_spec
end
def
requires_arc?
def
requires_arc?
top_specification
.
requires_arc
top_specification
.
requires_arc
end
end
def
dependencies
#
def dependencies
top_specification
.
dependencies
#
top_specification.dependencies
end
#
end
private
private
...
@@ -165,6 +157,9 @@ module Pod
...
@@ -165,6 +157,9 @@ module Pod
# TODO this is being overriden in the RestKit 0.9.4 spec, need to do
# TODO this is being overriden in the RestKit 0.9.4 spec, need to do
# something with that, and this method also still exists in Specification.
# something with that, and this method also still exists in Specification.
#
# This is not overriden anymore in specification refactor and the code
# Pod::Specification#copy_header_mapping can be moved here.
def
copy_header_mappings
def
copy_header_mappings
search_path_headers
=
header_files
-
exclude_headers
search_path_headers
=
header_files
-
exclude_headers
search_path_headers
.
inject
({})
do
|
mappings
,
from
|
search_path_headers
.
inject
({})
do
|
mappings
,
from
|
...
@@ -175,6 +170,23 @@ module Pod
...
@@ -175,6 +170,23 @@ module Pod
end
end
end
end
# returns an hash where the source_files are groupped by specification.
# If the same file is required by two specifications the one at the
# higher level in the inheritance chain wins.
def
sources_files_by_specification
files_by_spec
=
{}
processed_files
=
[]
specifications
.
sort_by
{
|
s
|
s
.
name
.
length
}.
each
do
|
spec
|
files
=
[]
expanded_paths
(
spec
.
source_files
,
:glob
=>
'*.{h,m,mm,c,cpp}'
,
:relative_to_sandbox
=>
true
).
each
do
|
file
|
files
<<
file
unless
processed_files
.
include?
(
file
)
end
files_by_spec
[
spec
]
=
files
processed_files
+=
files
end
files_by_spec
end
def
exclude_headers
def
exclude_headers
chained_expanded_paths
(
:exclude_headers
,
:relative_to_sandbox
=>
true
)
chained_expanded_paths
(
:exclude_headers
,
:relative_to_sandbox
=>
true
)
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