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
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
30 additions
and
27 deletions
+30
-27
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
+7
-4
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
verify_no_static_framework_transitive_dependencies
verify_framework_usage
generate_pods_project
integrate_user_project
if
integrate_targets?
integrate_user_project
if
in
stallation_options
.
in
tegrate_targets?
perform_post_install_actions
end
...
...
@@ -324,7 +324,7 @@ module Pod
end
@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_installer
end
...
...
@@ -346,7 +346,7 @@ module Pod
# @todo Why the @pod_installers might be empty?
#
def
clean_pod_sources
return
unless
clean?
return
unless
installation_options
.
clean?
return
unless
@pod_installers
@pod_installers
.
each
(
&
:clean!
)
end
...
...
@@ -368,7 +368,7 @@ module Pod
# @todo Why the @pod_installers might be empty?
#
def
lock_pod_sources
return
unless
lock_pod_sources?
return
unless
installation_options
.
lock_pod_sources?
return
unless
@pod_installers
@pod_installers
.
each
do
|
installer
|
pod_target
=
pod_targets
.
find
{
|
target
|
target
.
pod_name
==
installer
.
name
}
...
...
@@ -712,7 +712,7 @@ module Pod
pods_project
.
development_pods
.
remove_from_project
if
pods_project
.
development_pods
.
empty?
pods_project
.
sort
(
:groups_position
=>
:below
)
pods_project
.
recreate_user_schemes
(
false
)
if
deterministic_uuids?
if
installation_options
.
deterministic_uuids?
UI
.
message
(
'- Generating deterministic UUIDs'
)
{
pods_project
.
predictabilize_uuids
}
end
pods_project
.
save
...
...
lib/cocoapods/installer/analyzer.rb
View file @
7a1b2ad6
...
...
@@ -60,7 +60,7 @@ module Pod
validate_podfile!
validate_lockfile_version!
@result
=
AnalysisResult
.
new
if
integrate_targets?
if
in
stallation_options
.
in
tegrate_targets?
@result
.
target_inspections
=
inspect_targets_to_integrate
else
verify_platforms_specified!
...
...
@@ -252,7 +252,7 @@ module Pod
target
=
AggregateTarget
.
new
(
target_definition
,
sandbox
)
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
]
raise
"missing inspection:
#{
target_definition
.
name
}
"
unless
target_inspection
target
.
user_project
=
target_inspection
.
project
...
...
@@ -285,7 +285,7 @@ module Pod
# @return [Array<PodTarget>]
#
def
generate_pod_targets
(
specs_by_target
)
if
deduplicate_targets?
if
installation_options
.
deduplicate_targets?
dedupe_cache
=
{}
all_specs
=
specs_by_target
.
flat_map
do
|
target_definition
,
dependent_specs
|
...
...
@@ -380,7 +380,7 @@ module Pod
def
generate_pod_target
(
target_definitions
,
pod_specs
)
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
pod_target
.
user_build_configurations
=
target_inspections
.
map
(
&
:build_configurations
).
reduce
({},
&
:merge
)
pod_target
.
archs
=
target_inspections
.
flat_map
(
&
:archs
).
compact
.
uniq
.
sort
...
...
@@ -465,7 +465,7 @@ module Pod
else
source
=
ExternalSources
.
from_dependency
(
dependency
,
podfile
.
defined_in_file
)
end
source
.
can_cache
=
clean?
source
.
can_cache
=
installation_options
.
clean?
source
.
fetch
(
sandbox
)
end
...
...
@@ -654,7 +654,7 @@ module Pod
# @return [void]
#
def
verify_platforms_specified!
unless
integrate_targets?
unless
in
stallation_options
.
in
tegrate_targets?
podfile
.
target_definition_list
.
each
do
|
target_definition
|
if
!
target_definition
.
empty?
&&
target_definition
.
platform
.
nil?
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
def
self
.
option
(
name
,
default
,
boolean:
true
)
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
attr_accessor
name
alias_method
"
#{
name
}
?"
,
name
if
boolean
...
...
@@ -47,18 +47,19 @@ module Pod
module
Mixin
def
Mixin
.
included
(
mod
)
mod
.
send
(
:attr_accessor
,
:installation_options
)
def
mod
.
delegate_installation_options
(
&
blk
)
define_method
(
:installation_options
)
do
@installation_options
||=
InstallationOptions
.
from_podfile
(
instance_eval
(
&
blk
))
end
end
end
def
respond_to_missing?
(
name
,
*
args
)
def
mod
.
delegate_installation_option_attributes!
define_method
(
:respond_to_missing?
)
do
|
name
,
*
args
|
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
)
installation_options
.
send
(
name
,
*
args
,
&
blk
)
else
...
...
@@ -68,4 +69,6 @@ module Pod
end
end
end
end
end
end
spec/unit/installer/analyzer_spec.rb
View file @
7a1b2ad6
...
...
@@ -247,7 +247,7 @@ module Pod
end
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
.
client_root
.
should
==
config
.
installation_root
...
...
@@ -721,7 +721,7 @@ module Pod
downloader
.
expects
(
:fetch
)
downloader
.
expects
(
:can_cache
=
).
with
(
false
).
once
@analyzer
.
clean
=
false
@analyzer
.
installation_options
.
clean
=
false
@analyzer
.
send
(
:fetch_external_sources
)
end
...
...
spec/unit/installer_spec.rb
View file @
7a1b2ad6
...
...
@@ -52,7 +52,7 @@ module Pod
podfile
=
generate_podfile
lockfile
=
generate_lockfile
@installer
=
Installer
.
new
(
config
.
sandbox
,
podfile
,
lockfile
)
@installer
.
integrate_targets
=
false
@installer
.
in
stallation_options
.
in
tegrate_targets
=
false
end
#-------------------------------------------------------------------------#
...
...
@@ -150,13 +150,13 @@ module Pod
end
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
.
install!
end
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
.
install!
end
...
...
@@ -245,7 +245,7 @@ module Pod
lockfile
=
generate_lockfile
@installer
=
Installer
.
new
(
config
.
sandbox
,
podfile
,
lockfile
)
@installer
.
integrate_targets
=
false
@installer
.
in
stallation_options
.
in
tegrate_targets
=
false
@installer
.
install!
target
=
@installer
.
aggregate_targets
.
first
...
...
@@ -279,7 +279,7 @@ module Pod
lockfile
=
generate_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/
end
...
...
@@ -364,7 +364,7 @@ module Pod
lockfile
=
generate_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/
end
end
...
...
@@ -543,7 +543,7 @@ module Pod
describe
'#clean'
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
::
PodSourceInstaller
.
any_instance
.
expects
(
:install!
).
never
end
...
...
@@ -562,14 +562,14 @@ module Pod
end
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
(
:prepare_pods_project
)
@installer
.
pods_project
.
build_configurations
.
map
(
&
:name
).
sort
.
should
==
[
'App Store'
,
'Debug'
,
'Release'
,
'Test'
]
end
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
(
:prepare_pods_project
)
@installer
.
pods_project
.
build_settings
(
'Debug'
)[
'STRIP_INSTALLED_PRODUCT'
].
should
==
'NO'
...
...
@@ -925,7 +925,7 @@ module Pod
platform
:ios
end
@installer
=
Installer
.
new
(
config
.
sandbox
,
podfile
)
@installer
.
integrate_targets
=
false
@installer
.
in
stallation_options
.
in
tegrate_targets
=
false
end
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