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
1d5a218c
Commit
1d5a218c
authored
Sep 06, 2013
by
Fabio Pelosin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FileReferencesInstaller] Move headers linking logic to the installer.
parent
d059c4cb
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
133 additions
and
114 deletions
+133
-114
installer.rb
lib/cocoapods/installer.rb
+58
-0
file_references_installer.rb
...aller/pods_project_generator/file_references_installer.rb
+0
-59
file_references_installer_spec.rb
.../pods_project_generator/file_references_installer_spec.rb
+0
-53
installer_spec.rb
spec/unit/installer_spec.rb
+75
-2
No files found.
lib/cocoapods/installer.rb
View file @
1d5a218c
...
@@ -101,6 +101,7 @@ module Pod
...
@@ -101,6 +101,7 @@ module Pod
install_pod_sources
install_pod_sources
run_pre_install_hooks
run_pre_install_hooks
clean_pod_sources
clean_pod_sources
link_headers
end
end
end
end
...
@@ -274,7 +275,64 @@ module Pod
...
@@ -274,7 +275,64 @@ module Pod
end
end
end
end
# Creates the link to the headers of the Pod in the sandbox.
#
# @return [void]
#
def
link_headers
UI
.
section
"Linking headers"
do
pod_targets
.
each
do
|
pod_target
|
pod_target
.
file_accessors
.
each
do
|
file_accessor
|
headers_sandbox
=
Pathname
.
new
(
file_accessor
.
spec
.
root
.
name
)
pod_target
.
build_headers
.
add_search_path
(
headers_sandbox
)
sandbox
.
public_headers
.
add_search_path
(
headers_sandbox
)
header_mappings
(
headers_sandbox
,
file_accessor
,
file_accessor
.
headers
).
each
do
|
namespaced_path
,
files
|
pod_target
.
build_headers
.
add_files
(
namespaced_path
,
files
)
end
header_mappings
(
headers_sandbox
,
file_accessor
,
file_accessor
.
public_headers
).
each
do
|
namespaced_path
,
files
|
sandbox
.
public_headers
.
add_files
(
namespaced_path
,
files
)
end
end
end
end
end
# Computes the destination sub-directory in the sandbox
#
# @param [Pathname] headers_sandbox
# The sandbox where the headers links should be stored for this
# Pod.
#
# @param [Specification::Consumer] consumer
# The consumer for which the headers need to be linked.
#
# @param [Array<Pathname>] headers
# The absolute paths of the headers which need to be mapped.
#
# @return [Hash{Pathname => Array<Pathname>}] A hash containing the
# headers folders as the keys and the absolute paths of the
# header files as the values.
#
def
header_mappings
(
headers_sandbox
,
file_accessor
,
headers
)
consumer
=
file_accessor
.
spec_consumer
dir
=
headers_sandbox
dir
=
dir
+
consumer
.
header_dir
if
consumer
.
header_dir
mappings
=
{}
headers
.
each
do
|
header
|
sub_dir
=
dir
if
consumer
.
header_mappings_dir
header_mappings_dir
=
file_accessor
.
path_list
.
root
+
consumer
.
header_mappings_dir
relative_path
=
header
.
relative_path_from
(
header_mappings_dir
)
sub_dir
=
sub_dir
+
relative_path
.
dirname
end
mappings
[
sub_dir
]
||=
[]
mappings
[
sub_dir
]
<<
header
end
mappings
end
# Writes the Podfile and the lock files.
# Writes the Podfile and the lock files.
#
#
...
...
lib/cocoapods/installer/pods_project_generator/file_references_installer.rb
View file @
1d5a218c
...
@@ -39,7 +39,6 @@ module Pod
...
@@ -39,7 +39,6 @@ module Pod
add_frameworks_bundles
add_frameworks_bundles
add_vendored_libraries
add_vendored_libraries
add_resources
add_resources
link_headers
end
end
#-----------------------------------------------------------------------#
#-----------------------------------------------------------------------#
...
@@ -108,29 +107,6 @@ module Pod
...
@@ -108,29 +107,6 @@ module Pod
end
end
end
end
# Creates the link to the headers of the Pod in the sandbox.
#
# @return [void]
#
def
link_headers
UI
.
message
"- Linking headers"
do
libraries
.
each
do
|
library
|
library
.
file_accessors
.
each
do
|
file_accessor
|
headers_sandbox
=
Pathname
.
new
(
file_accessor
.
spec
.
root
.
name
)
library
.
build_headers
.
add_search_path
(
headers_sandbox
)
sandbox
.
public_headers
.
add_search_path
(
headers_sandbox
)
header_mappings
(
headers_sandbox
,
file_accessor
,
file_accessor
.
headers
).
each
do
|
namespaced_path
,
files
|
library
.
build_headers
.
add_files
(
namespaced_path
,
files
)
end
header_mappings
(
headers_sandbox
,
file_accessor
,
file_accessor
.
public_headers
).
each
do
|
namespaced_path
,
files
|
sandbox
.
public_headers
.
add_files
(
namespaced_path
,
files
)
end
end
end
end
end
#-----------------------------------------------------------------------#
#-----------------------------------------------------------------------#
...
@@ -167,41 +143,6 @@ module Pod
...
@@ -167,41 +143,6 @@ module Pod
end
end
end
end
# Computes the destination sub-directory in the sandbox
#
# @param [Pathname] headers_sandbox
# The sandbox where the headers links should be stored for this
# Pod.
#
# @param [Specification::Consumer] consumer
# The consumer for which the headers need to be linked.
#
# @param [Array<Pathname>] headers
# The absolute paths of the headers which need to be mapped.
#
# @return [Hash{Pathname => Array<Pathname>}] A hash containing the
# headers folders as the keys and the absolute paths of the
# header files as the values.
#
def
header_mappings
(
headers_sandbox
,
file_accessor
,
headers
)
consumer
=
file_accessor
.
spec_consumer
dir
=
headers_sandbox
dir
=
dir
+
consumer
.
header_dir
if
consumer
.
header_dir
mappings
=
{}
headers
.
each
do
|
header
|
sub_dir
=
dir
if
consumer
.
header_mappings_dir
header_mappings_dir
=
file_accessor
.
path_list
.
root
+
consumer
.
header_mappings_dir
relative_path
=
header
.
relative_path_from
(
header_mappings_dir
)
sub_dir
=
sub_dir
+
relative_path
.
dirname
end
mappings
[
sub_dir
]
||=
[]
mappings
[
sub_dir
]
<<
header
end
mappings
end
#-----------------------------------------------------------------------#
#-----------------------------------------------------------------------#
end
end
...
...
spec/unit/installer/pods_project_generator/file_references_installer_spec.rb
View file @
1d5a218c
...
@@ -44,24 +44,6 @@ module Pod
...
@@ -44,24 +44,6 @@ module Pod
file_ref
.
path
.
should
==
"Resources/logo-sidebar.png"
file_ref
.
path
.
should
==
"Resources/logo-sidebar.png"
end
end
it
"links the build headers"
do
@installer
.
install!
headers_root
=
@pod_target
.
build_headers
.
root
public_header
=
headers_root
+
'BananaLib/Banana.h'
private_header
=
headers_root
+
'BananaLib/BananaPrivate.h'
public_header
.
should
.
exist
private_header
.
should
.
exist
end
it
"links the public headers"
do
@installer
.
install!
headers_root
=
config
.
sandbox
.
public_headers
.
root
public_header
=
headers_root
+
'BananaLib/Banana.h'
private_header
=
headers_root
+
'BananaLib/BananaPrivate.h'
public_header
.
should
.
exist
private_header
.
should
.
not
.
exist
end
end
end
#-------------------------------------------------------------------------#
#-------------------------------------------------------------------------#
...
@@ -92,41 +74,6 @@ module Pod
...
@@ -92,41 +74,6 @@ module Pod
end
end
end
end
describe
"#add_file_accessors_paths_to_pods_group"
do
it
"returns the header mappings"
do
headers_sandbox
=
Pathname
.
new
(
'BananaLib'
)
headers
=
[
Pathname
.
new
(
'BananaLib/Banana.h'
)]
mappings
=
@installer
.
send
(
:header_mappings
,
headers_sandbox
,
@file_accessor
,
headers
)
mappings
.
should
==
{
headers_sandbox
=>
[
Pathname
.
new
(
'BananaLib/Banana.h'
)]
}
end
it
"takes into account the header dir specified in the spec"
do
headers_sandbox
=
Pathname
.
new
(
'BananaLib'
)
headers
=
[
Pathname
.
new
(
'BananaLib/Banana.h'
)]
@file_accessor
.
spec_consumer
.
stubs
(
:header_dir
).
returns
(
'Sub_dir'
)
mappings
=
@installer
.
send
(
:header_mappings
,
headers_sandbox
,
@file_accessor
,
headers
)
mappings
.
should
==
{
(
headers_sandbox
+
'Sub_dir'
)
=>
[
Pathname
.
new
(
'BananaLib/Banana.h'
)]
}
end
it
"takes into account the header mappings dir specified in the spec"
do
headers_sandbox
=
Pathname
.
new
(
'BananaLib'
)
header_1
=
@file_accessor
.
root
+
'BananaLib/sub_dir/dir_1/banana_1.h'
header_2
=
@file_accessor
.
root
+
'BananaLib/sub_dir/dir_2/banana_2.h'
headers
=
[
header_1
,
header_2
]
@file_accessor
.
spec_consumer
.
stubs
(
:header_mappings_dir
).
returns
(
'BananaLib/sub_dir'
)
mappings
=
@installer
.
send
(
:header_mappings
,
headers_sandbox
,
@file_accessor
,
headers
)
mappings
.
should
==
{
(
headers_sandbox
+
'dir_1'
)
=>
[
header_1
],
(
headers_sandbox
+
'dir_2'
)
=>
[
header_2
],
}
end
end
end
end
#-------------------------------------------------------------------------#
#-------------------------------------------------------------------------#
...
...
spec/unit/installer_spec.rb
View file @
1d5a218c
...
@@ -49,6 +49,7 @@ module Pod
...
@@ -49,6 +49,7 @@ module Pod
@installer
.
unstub
(
:download_dependencies
)
@installer
.
unstub
(
:download_dependencies
)
@installer
.
stubs
(
:create_file_accessors
)
@installer
.
stubs
(
:create_file_accessors
)
@installer
.
stubs
(
:install_pod_sources
)
@installer
.
stubs
(
:install_pod_sources
)
@installer
.
stubs
(
:link_headers
)
def
@installer
.
run_pre_install_hooks
def
@installer
.
run_pre_install_hooks
@hook_called
=
true
@hook_called
=
true
end
end
...
@@ -179,15 +180,86 @@ module Pod
...
@@ -179,15 +180,86 @@ module Pod
#--------------------------------------#
#--------------------------------------#
describe
"#clean"
do
describe
"#clean
_pod_sources
"
do
it
"it cleans only if the config instructs to do it"
do
it
"it cleans only if the config instructs to do it"
do
config
.
clean
=
false
config
.
clean
=
false
Installer
::
PodSourceInstaller
.
any_instance
.
expects
(
:clean!
).
never
@installer
.
send
(
:clean_pod_sources
)
@installer
.
send
(
:clean_pod_sources
)
Installer
::
PodSourceInstaller
.
any_instance
.
expects
(
:install!
).
never
end
end
end
end
#--------------------------------------#
describe
"#link_headers"
do
it
"links the build headers"
do
pod_target
=
PodTarget
.
new
(
nil
,
nil
,
config
.
sandbox
)
pod_target
.
file_accessors
=
[
fixture_file_accessor
(
'banana-lib/BananaLib.podspec'
)]
@installer
.
stubs
(
:pod_targets
).
returns
([
pod_target
])
@installer
.
send
(
:link_headers
)
headers_root
=
pod_target
.
build_headers
.
root
public_header
=
headers_root
+
'BananaLib/Banana.h'
private_header
=
headers_root
+
'BananaLib/BananaPrivate.h'
public_header
.
should
.
exist
private_header
.
should
.
exist
end
it
"links the public headers"
do
pod_target
=
PodTarget
.
new
(
nil
,
nil
,
config
.
sandbox
)
pod_target
.
file_accessors
=
[
fixture_file_accessor
(
'banana-lib/BananaLib.podspec'
)]
@installer
.
stubs
(
:pod_targets
).
returns
([
pod_target
])
@installer
.
send
(
:link_headers
)
headers_root
=
config
.
sandbox
.
public_headers
.
root
public_header
=
headers_root
+
'BananaLib/Banana.h'
private_header
=
headers_root
+
'BananaLib/BananaPrivate.h'
public_header
.
should
.
exist
private_header
.
should
.
not
.
exist
end
describe
"#header_mappings"
do
before
do
@file_accessor
=
fixture_file_accessor
(
'banana-lib/BananaLib.podspec'
)
end
it
"returns the header mappings"
do
headers_sandbox
=
Pathname
.
new
(
'BananaLib'
)
headers
=
[
Pathname
.
new
(
'BananaLib/Banana.h'
)]
mappings
=
@installer
.
send
(
:header_mappings
,
headers_sandbox
,
@file_accessor
,
headers
)
mappings
.
should
==
{
headers_sandbox
=>
[
Pathname
.
new
(
'BananaLib/Banana.h'
)]
}
end
it
"takes into account the header dir specified in the spec"
do
headers_sandbox
=
Pathname
.
new
(
'BananaLib'
)
headers
=
[
Pathname
.
new
(
'BananaLib/Banana.h'
)]
@file_accessor
.
spec_consumer
.
stubs
(
:header_dir
).
returns
(
'Sub_dir'
)
mappings
=
@installer
.
send
(
:header_mappings
,
headers_sandbox
,
@file_accessor
,
headers
)
mappings
.
should
==
{
(
headers_sandbox
+
'Sub_dir'
)
=>
[
Pathname
.
new
(
'BananaLib/Banana.h'
)]
}
end
it
"takes into account the header mappings dir specified in the spec"
do
headers_sandbox
=
Pathname
.
new
(
'BananaLib'
)
header_1
=
@file_accessor
.
root
+
'BananaLib/sub_dir/dir_1/banana_1.h'
header_2
=
@file_accessor
.
root
+
'BananaLib/sub_dir/dir_2/banana_2.h'
headers
=
[
header_1
,
header_2
]
@file_accessor
.
spec_consumer
.
stubs
(
:header_mappings_dir
).
returns
(
'BananaLib/sub_dir'
)
mappings
=
@installer
.
send
(
:header_mappings
,
headers_sandbox
,
@file_accessor
,
headers
)
mappings
.
should
==
{
(
headers_sandbox
+
'dir_1'
)
=>
[
header_1
],
(
headers_sandbox
+
'dir_2'
)
=>
[
header_2
],
}
end
end
end
end
end
end
end
...
@@ -210,6 +282,7 @@ module Pod
...
@@ -210,6 +282,7 @@ module Pod
end
end
it
"in runs the post-install hooks before serializing the Pods project"
do
it
"in runs the post-install hooks before serializing the Pods project"
do
Installer
::
PodsProjectGenerator
.
any_instance
.
expects
(
:install
)
def
@installer
.
run_post_install_hooks
def
@installer
.
run_post_install_hooks
Installer
::
PodsProjectGenerator
.
any_instance
.
expects
(
:write_pod_project
)
Installer
::
PodsProjectGenerator
.
any_instance
.
expects
(
:write_pod_project
)
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