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
7a1b2ad6
Commit
7a1b2ad6
authored
Dec 25, 2015
by
Samuel Giddins
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[InstallationOptions] Refactor to make automatic delegation opt-in
parent
eb59c774
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
36 additions
and
33 deletions
+36
-33
installer.rb
lib/cocoapods/installer.rb
+5
-5
analyzer.rb
lib/cocoapods/installer/analyzer.rb
+6
-6
installation_options.rb
lib/cocoapods/installer/installation_options.rb
+13
-10
analyzer_spec.rb
spec/unit/installer/analyzer_spec.rb
+2
-2
installer_spec.rb
spec/unit/installer_spec.rb
+10
-10
No files found.
lib/cocoapods/installer.rb
View file @
7a1b2ad6
...
@@ -113,7 +113,7 @@ module Pod
...
@@ -113,7 +113,7 @@ module Pod
verify_no_static_framework_transitive_dependencies
verify_no_static_framework_transitive_dependencies
verify_framework_usage
verify_framework_usage
generate_pods_project
generate_pods_project
integrate_user_project
if
integrate_targets?
integrate_user_project
if
in
stallation_options
.
in
tegrate_targets?
perform_post_install_actions
perform_post_install_actions
end
end
...
@@ -324,7 +324,7 @@ module Pod
...
@@ -324,7 +324,7 @@ module Pod
end
end
@pod_installers
||=
[]
@pod_installers
||=
[]
pod_installer
=
PodSourceInstaller
.
new
(
sandbox
,
specs_by_platform
,
can_cache:
clean?
)
pod_installer
=
PodSourceInstaller
.
new
(
sandbox
,
specs_by_platform
,
can_cache:
installation_options
.
clean?
)
@pod_installers
<<
pod_installer
@pod_installers
<<
pod_installer
pod_installer
pod_installer
end
end
...
@@ -346,7 +346,7 @@ module Pod
...
@@ -346,7 +346,7 @@ module Pod
# @todo Why the @pod_installers might be empty?
# @todo Why the @pod_installers might be empty?
#
#
def
clean_pod_sources
def
clean_pod_sources
return
unless
clean?
return
unless
installation_options
.
clean?
return
unless
@pod_installers
return
unless
@pod_installers
@pod_installers
.
each
(
&
:clean!
)
@pod_installers
.
each
(
&
:clean!
)
end
end
...
@@ -368,7 +368,7 @@ module Pod
...
@@ -368,7 +368,7 @@ module Pod
# @todo Why the @pod_installers might be empty?
# @todo Why the @pod_installers might be empty?
#
#
def
lock_pod_sources
def
lock_pod_sources
return
unless
lock_pod_sources?
return
unless
installation_options
.
lock_pod_sources?
return
unless
@pod_installers
return
unless
@pod_installers
@pod_installers
.
each
do
|
installer
|
@pod_installers
.
each
do
|
installer
|
pod_target
=
pod_targets
.
find
{
|
target
|
target
.
pod_name
==
installer
.
name
}
pod_target
=
pod_targets
.
find
{
|
target
|
target
.
pod_name
==
installer
.
name
}
...
@@ -712,7 +712,7 @@ module Pod
...
@@ -712,7 +712,7 @@ module Pod
pods_project
.
development_pods
.
remove_from_project
if
pods_project
.
development_pods
.
empty?
pods_project
.
development_pods
.
remove_from_project
if
pods_project
.
development_pods
.
empty?
pods_project
.
sort
(
:groups_position
=>
:below
)
pods_project
.
sort
(
:groups_position
=>
:below
)
pods_project
.
recreate_user_schemes
(
false
)
pods_project
.
recreate_user_schemes
(
false
)
if
deterministic_uuids?
if
installation_options
.
deterministic_uuids?
UI
.
message
(
'- Generating deterministic UUIDs'
)
{
pods_project
.
predictabilize_uuids
}
UI
.
message
(
'- Generating deterministic UUIDs'
)
{
pods_project
.
predictabilize_uuids
}
end
end
pods_project
.
save
pods_project
.
save
...
...
lib/cocoapods/installer/analyzer.rb
View file @
7a1b2ad6
...
@@ -60,7 +60,7 @@ module Pod
...
@@ -60,7 +60,7 @@ module Pod
validate_podfile!
validate_podfile!
validate_lockfile_version!
validate_lockfile_version!
@result
=
AnalysisResult
.
new
@result
=
AnalysisResult
.
new
if
integrate_targets?
if
in
stallation_options
.
in
tegrate_targets?
@result
.
target_inspections
=
inspect_targets_to_integrate
@result
.
target_inspections
=
inspect_targets_to_integrate
else
else
verify_platforms_specified!
verify_platforms_specified!
...
@@ -252,7 +252,7 @@ module Pod
...
@@ -252,7 +252,7 @@ module Pod
target
=
AggregateTarget
.
new
(
target_definition
,
sandbox
)
target
=
AggregateTarget
.
new
(
target_definition
,
sandbox
)
target
.
host_requires_frameworks
|=
target_definition
.
uses_frameworks?
target
.
host_requires_frameworks
|=
target_definition
.
uses_frameworks?
if
integrate_targets?
if
in
stallation_options
.
in
tegrate_targets?
target_inspection
=
result
.
target_inspections
[
target_definition
]
target_inspection
=
result
.
target_inspections
[
target_definition
]
raise
"missing inspection:
#{
target_definition
.
name
}
"
unless
target_inspection
raise
"missing inspection:
#{
target_definition
.
name
}
"
unless
target_inspection
target
.
user_project
=
target_inspection
.
project
target
.
user_project
=
target_inspection
.
project
...
@@ -285,7 +285,7 @@ module Pod
...
@@ -285,7 +285,7 @@ module Pod
# @return [Array<PodTarget>]
# @return [Array<PodTarget>]
#
#
def
generate_pod_targets
(
specs_by_target
)
def
generate_pod_targets
(
specs_by_target
)
if
deduplicate_targets?
if
installation_options
.
deduplicate_targets?
dedupe_cache
=
{}
dedupe_cache
=
{}
all_specs
=
specs_by_target
.
flat_map
do
|
target_definition
,
dependent_specs
|
all_specs
=
specs_by_target
.
flat_map
do
|
target_definition
,
dependent_specs
|
...
@@ -380,7 +380,7 @@ module Pod
...
@@ -380,7 +380,7 @@ module Pod
def
generate_pod_target
(
target_definitions
,
pod_specs
)
def
generate_pod_target
(
target_definitions
,
pod_specs
)
pod_target
=
PodTarget
.
new
(
pod_specs
,
target_definitions
,
sandbox
)
pod_target
=
PodTarget
.
new
(
pod_specs
,
target_definitions
,
sandbox
)
if
integrate_targets?
if
in
stallation_options
.
in
tegrate_targets?
target_inspections
=
result
.
target_inspections
.
select
{
|
t
,
_
|
target_definitions
.
include?
(
t
)
}.
values
target_inspections
=
result
.
target_inspections
.
select
{
|
t
,
_
|
target_definitions
.
include?
(
t
)
}.
values
pod_target
.
user_build_configurations
=
target_inspections
.
map
(
&
:build_configurations
).
reduce
({},
&
:merge
)
pod_target
.
user_build_configurations
=
target_inspections
.
map
(
&
:build_configurations
).
reduce
({},
&
:merge
)
pod_target
.
archs
=
target_inspections
.
flat_map
(
&
:archs
).
compact
.
uniq
.
sort
pod_target
.
archs
=
target_inspections
.
flat_map
(
&
:archs
).
compact
.
uniq
.
sort
...
@@ -465,7 +465,7 @@ module Pod
...
@@ -465,7 +465,7 @@ module Pod
else
else
source
=
ExternalSources
.
from_dependency
(
dependency
,
podfile
.
defined_in_file
)
source
=
ExternalSources
.
from_dependency
(
dependency
,
podfile
.
defined_in_file
)
end
end
source
.
can_cache
=
clean?
source
.
can_cache
=
installation_options
.
clean?
source
.
fetch
(
sandbox
)
source
.
fetch
(
sandbox
)
end
end
...
@@ -654,7 +654,7 @@ module Pod
...
@@ -654,7 +654,7 @@ module Pod
# @return [void]
# @return [void]
#
#
def
verify_platforms_specified!
def
verify_platforms_specified!
unless
integrate_targets?
unless
in
stallation_options
.
in
tegrate_targets?
podfile
.
target_definition_list
.
each
do
|
target_definition
|
podfile
.
target_definition_list
.
each
do
|
target_definition
|
if
!
target_definition
.
empty?
&&
target_definition
.
platform
.
nil?
if
!
target_definition
.
empty?
&&
target_definition
.
platform
.
nil?
raise
Informative
,
'It is necessary to specify the platform in the Podfile if not integrating.'
raise
Informative
,
'It is necessary to specify the platform in the Podfile if not integrating.'
...
...
lib/cocoapods/installer/installation_options.rb
View file @
7a1b2ad6
...
@@ -14,7 +14,7 @@ module Pod
...
@@ -14,7 +14,7 @@ module Pod
def
self
.
option
(
name
,
default
,
boolean:
true
)
def
self
.
option
(
name
,
default
,
boolean:
true
)
name
=
name
.
to_s
name
=
name
.
to_s
raise
'existing'
if
defaults
.
key?
(
name
)
raise
ArgumentError
,
"The
#{
name
}
option is already defined"
if
defaults
.
key?
(
name
)
defaults
[
name
]
=
default
defaults
[
name
]
=
default
attr_accessor
name
attr_accessor
name
alias_method
"
#{
name
}
?"
,
name
if
boolean
alias_method
"
#{
name
}
?"
,
name
if
boolean
...
@@ -47,22 +47,25 @@ module Pod
...
@@ -47,22 +47,25 @@ module Pod
module
Mixin
module
Mixin
def
Mixin
.
included
(
mod
)
def
Mixin
.
included
(
mod
)
mod
.
send
(
:attr_accessor
,
:installation_options
)
mod
.
send
(
:attr_accessor
,
:installation_options
)
def
mod
.
delegate_installation_options
(
&
blk
)
def
mod
.
delegate_installation_options
(
&
blk
)
define_method
(
:installation_options
)
do
define_method
(
:installation_options
)
do
@installation_options
||=
InstallationOptions
.
from_podfile
(
instance_eval
(
&
blk
))
@installation_options
||=
InstallationOptions
.
from_podfile
(
instance_eval
(
&
blk
))
end
end
end
end
end
def
respond_to_missing?
(
name
,
*
args
)
def
mod
.
delegate_installation_option_attributes!
installation_options
.
respond_to?
(
name
,
*
args
)
||
super
define_method
(
:respond_to_missing?
)
do
|
name
,
*
args
|
end
installation_options
.
respond_to?
(
name
,
*
args
)
||
super
end
def
method_missing
(
name
,
*
args
,
&
blk
)
define_method
(
:method_missing
)
do
|
name
,
*
args
,
&
blk
|
if
installation_options
.
respond_to?
(
name
)
if
installation_options
.
respond_to?
(
name
)
installation_options
.
send
(
name
,
*
args
,
&
blk
)
installation_options
.
send
(
name
,
*
args
,
&
blk
)
else
else
super
super
end
end
end
end
end
end
end
end
...
...
spec/unit/installer/analyzer_spec.rb
View file @
7a1b2ad6
...
@@ -247,7 +247,7 @@ module Pod
...
@@ -247,7 +247,7 @@ module Pod
end
end
it
'generates the integration library appropriately if the installation will not integrate'
do
it
'generates the integration library appropriately if the installation will not integrate'
do
@analyzer
.
integrate_targets
=
false
@analyzer
.
in
stallation_options
.
in
tegrate_targets
=
false
target
=
@analyzer
.
analyze
.
targets
.
first
target
=
@analyzer
.
analyze
.
targets
.
first
target
.
client_root
.
should
==
config
.
installation_root
target
.
client_root
.
should
==
config
.
installation_root
...
@@ -721,7 +721,7 @@ module Pod
...
@@ -721,7 +721,7 @@ module Pod
downloader
.
expects
(
:fetch
)
downloader
.
expects
(
:fetch
)
downloader
.
expects
(
:can_cache
=
).
with
(
false
).
once
downloader
.
expects
(
:can_cache
=
).
with
(
false
).
once
@analyzer
.
clean
=
false
@analyzer
.
installation_options
.
clean
=
false
@analyzer
.
send
(
:fetch_external_sources
)
@analyzer
.
send
(
:fetch_external_sources
)
end
end
...
...
spec/unit/installer_spec.rb
View file @
7a1b2ad6
...
@@ -52,7 +52,7 @@ module Pod
...
@@ -52,7 +52,7 @@ module Pod
podfile
=
generate_podfile
podfile
=
generate_podfile
lockfile
=
generate_lockfile
lockfile
=
generate_lockfile
@installer
=
Installer
.
new
(
config
.
sandbox
,
podfile
,
lockfile
)
@installer
=
Installer
.
new
(
config
.
sandbox
,
podfile
,
lockfile
)
@installer
.
integrate_targets
=
false
@installer
.
in
stallation_options
.
in
tegrate_targets
=
false
end
end
#-------------------------------------------------------------------------#
#-------------------------------------------------------------------------#
...
@@ -150,13 +150,13 @@ module Pod
...
@@ -150,13 +150,13 @@ module Pod
end
end
it
'integrates the user targets if the corresponding config is set'
do
it
'integrates the user targets if the corresponding config is set'
do
@installer
.
integrate_targets
=
true
@installer
.
in
stallation_options
.
in
tegrate_targets
=
true
@installer
.
expects
(
:integrate_user_project
)
@installer
.
expects
(
:integrate_user_project
)
@installer
.
install!
@installer
.
install!
end
end
it
"doesn't integrates the user targets if the corresponding config is not set"
do
it
"doesn't integrates the user targets if the corresponding config is not set"
do
@installer
.
integrate_targets
=
false
@installer
.
in
stallation_options
.
in
tegrate_targets
=
false
@installer
.
expects
(
:integrate_user_project
).
never
@installer
.
expects
(
:integrate_user_project
).
never
@installer
.
install!
@installer
.
install!
end
end
...
@@ -245,7 +245,7 @@ module Pod
...
@@ -245,7 +245,7 @@ module Pod
lockfile
=
generate_lockfile
lockfile
=
generate_lockfile
@installer
=
Installer
.
new
(
config
.
sandbox
,
podfile
,
lockfile
)
@installer
=
Installer
.
new
(
config
.
sandbox
,
podfile
,
lockfile
)
@installer
.
integrate_targets
=
false
@installer
.
in
stallation_options
.
in
tegrate_targets
=
false
@installer
.
install!
@installer
.
install!
target
=
@installer
.
aggregate_targets
.
first
target
=
@installer
.
aggregate_targets
.
first
...
@@ -279,7 +279,7 @@ module Pod
...
@@ -279,7 +279,7 @@ module Pod
lockfile
=
generate_lockfile
lockfile
=
generate_lockfile
@installer
=
Installer
.
new
(
config
.
sandbox
,
podfile
,
lockfile
)
@installer
=
Installer
.
new
(
config
.
sandbox
,
podfile
,
lockfile
)
@installer
.
integrate_targets
=
false
@installer
.
in
stallation_options
.
in
tegrate_targets
=
false
should
.
raise
(
Informative
)
{
@installer
.
install!
}.
message
.
should
.
match
/conflict.*monkey/
should
.
raise
(
Informative
)
{
@installer
.
install!
}.
message
.
should
.
match
/conflict.*monkey/
end
end
...
@@ -364,7 +364,7 @@ module Pod
...
@@ -364,7 +364,7 @@ module Pod
lockfile
=
generate_lockfile
lockfile
=
generate_lockfile
@installer
=
Installer
.
new
(
config
.
sandbox
,
podfile
,
lockfile
)
@installer
=
Installer
.
new
(
config
.
sandbox
,
podfile
,
lockfile
)
@installer
.
integrate_targets
=
false
@installer
.
in
stallation_options
.
in
tegrate_targets
=
false
should
.
raise
(
Informative
)
{
@installer
.
install!
}.
message
.
should
.
match
/use_frameworks/
should
.
raise
(
Informative
)
{
@installer
.
install!
}.
message
.
should
.
match
/use_frameworks/
end
end
end
end
...
@@ -543,7 +543,7 @@ module Pod
...
@@ -543,7 +543,7 @@ module Pod
describe
'#clean'
do
describe
'#clean'
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
@installer
.
clean
=
false
@installer
.
installation_options
.
clean
=
false
@installer
.
send
(
:clean_pod_sources
)
@installer
.
send
(
:clean_pod_sources
)
Installer
::
PodSourceInstaller
.
any_instance
.
expects
(
:install!
).
never
Installer
::
PodSourceInstaller
.
any_instance
.
expects
(
:install!
).
never
end
end
...
@@ -562,14 +562,14 @@ module Pod
...
@@ -562,14 +562,14 @@ module Pod
end
end
it
"creates build configurations for all of the user's targets"
do
it
"creates build configurations for all of the user's targets"
do
@installer
.
integrate_targets
=
true
@installer
.
in
stallation_options
.
in
tegrate_targets
=
true
@installer
.
send
(
:analyze
)
@installer
.
send
(
:analyze
)
@installer
.
send
(
:prepare_pods_project
)
@installer
.
send
(
:prepare_pods_project
)
@installer
.
pods_project
.
build_configurations
.
map
(
&
:name
).
sort
.
should
==
[
'App Store'
,
'Debug'
,
'Release'
,
'Test'
]
@installer
.
pods_project
.
build_configurations
.
map
(
&
:name
).
sort
.
should
==
[
'App Store'
,
'Debug'
,
'Release'
,
'Test'
]
end
end
it
'sets STRIP_INSTALLED_PRODUCT to NO for all configurations for the whole project'
do
it
'sets STRIP_INSTALLED_PRODUCT to NO for all configurations for the whole project'
do
@installer
.
integrate_targets
=
true
@installer
.
in
stallation_options
.
in
tegrate_targets
=
true
@installer
.
send
(
:analyze
)
@installer
.
send
(
:analyze
)
@installer
.
send
(
:prepare_pods_project
)
@installer
.
send
(
:prepare_pods_project
)
@installer
.
pods_project
.
build_settings
(
'Debug'
)[
'STRIP_INSTALLED_PRODUCT'
].
should
==
'NO'
@installer
.
pods_project
.
build_settings
(
'Debug'
)[
'STRIP_INSTALLED_PRODUCT'
].
should
==
'NO'
...
@@ -925,7 +925,7 @@ module Pod
...
@@ -925,7 +925,7 @@ module Pod
platform
:ios
platform
:ios
end
end
@installer
=
Installer
.
new
(
config
.
sandbox
,
podfile
)
@installer
=
Installer
.
new
(
config
.
sandbox
,
podfile
)
@installer
.
integrate_targets
=
false
@installer
.
in
stallation_options
.
in
tegrate_targets
=
false
end
end
it
'runs the pre install hooks'
do
it
'runs the pre install hooks'
do
...
...
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