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
cccca4ff
Commit
cccca4ff
authored
Aug 07, 2014
by
Fabio Pelosin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[AggretateTarget] Expose specs by build configuration
parent
b3a77a6f
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
56 additions
and
12 deletions
+56
-12
target_environment_header.rb
lib/cocoapods/generator/target_environment_header.rb
+16
-5
aggregate_target_installer.rb
.../installer/target_installer/aggregate_target_installer.rb
+1
-1
aggregate_target.rb
lib/cocoapods/target/aggregate_target.rb
+13
-0
target_environment_header_spec.rb
spec/unit/generator/target_environment_header_spec.rb
+1
-1
aggregate_target_spec.rb
spec/unit/target/aggregate_target_spec.rb
+25
-5
No files found.
lib/cocoapods/generator/target_environment_header.rb
View file @
cccca4ff
require
'active_support/core_ext/string/strip'
module
Pod
module
Pod
module
Generator
module
Generator
...
@@ -23,14 +25,15 @@ module Pod
...
@@ -23,14 +25,15 @@ module Pod
#
#
class
TargetEnvironmentHeader
class
TargetEnvironmentHeader
# @return [Array<LocalPod>] the specifications installed for the target.
# @return [Hash{String => LocalPod}] the specifications installed for
# the target by build configuration name.
#
#
attr_reader
:specs
attr_reader
:specs
_by_build_configuration
# @param [Array<LocalPod>] pods @see pods
# @param [Array<LocalPod>] pods @see pods
#
#
def
initialize
(
specs
)
def
initialize
(
specs
_by_build_configuration
)
@specs
=
specs
@specs
_by_build_configuration
=
specs_by_build_configuration
end
end
# Generates and saves the file.
# Generates and saves the file.
...
@@ -50,7 +53,7 @@ module Pod
...
@@ -50,7 +53,7 @@ module Pod
source
.
puts
"// project."
source
.
puts
"// project."
source
.
puts
source
.
puts
source
.
puts
source
.
puts
specs
.
each
do
|
spec
|
common_specs
(
specs_by_build_configuration
)
.
each
do
|
spec
|
spec_name
=
safe_spec_name
(
spec
.
name
)
spec_name
=
safe_spec_name
(
spec
.
name
)
source
.
puts
"//
#{
spec
.
name
}
"
source
.
puts
"//
#{
spec
.
name
}
"
source
.
puts
"#define COCOAPODS_POD_AVAILABLE_
#{
spec_name
}
"
source
.
puts
"#define COCOAPODS_POD_AVAILABLE_
#{
spec_name
}
"
...
@@ -79,6 +82,14 @@ module Pod
...
@@ -79,6 +82,14 @@ module Pod
spec_name
.
gsub
(
/[^\w]/
,
'_'
)
spec_name
.
gsub
(
/[^\w]/
,
'_'
)
end
end
def
common_specs
(
specs_by_build_configuration
)
result
=
specs_by_build_configuration
.
values
.
flatten
.
uniq
specs_by_build_configuration
.
values
.
each
do
|
build_configuration_specs
|
result
=
result
&
build_configuration_specs
end
result
end
#-----------------------------------------------------------------------#
#-----------------------------------------------------------------------#
end
end
...
...
lib/cocoapods/installer/target_installer/aggregate_target_installer.rb
View file @
cccca4ff
...
@@ -50,7 +50,7 @@ module Pod
...
@@ -50,7 +50,7 @@ module Pod
def
create_target_environment_header
def
create_target_environment_header
path
=
library
.
target_environment_header_path
path
=
library
.
target_environment_header_path
UI
.
message
"- Generating target environment header at
#{
UI
.
path
(
path
)
}
"
do
UI
.
message
"- Generating target environment header at
#{
UI
.
path
(
path
)
}
"
do
generator
=
Generator
::
TargetEnvironmentHeader
.
new
(
library
.
pod_targets
.
map
{
|
l
|
l
.
specs
}.
flatte
n
)
generator
=
Generator
::
TargetEnvironmentHeader
.
new
(
library
.
specs_by_build_configuratio
n
)
generator
.
save_as
(
path
)
generator
.
save_as
(
path
)
add_file_to_support_group
(
path
)
add_file_to_support_group
(
path
)
end
end
...
...
lib/cocoapods/target/aggregate_target.rb
View file @
cccca4ff
...
@@ -64,6 +64,19 @@ module Pod
...
@@ -64,6 +64,19 @@ module Pod
pod_targets
.
map
(
&
:specs
).
flatten
pod_targets
.
map
(
&
:specs
).
flatten
end
end
# @return [Hash{Symbol => Array<PodTarget>}] The pod targets for each
# build configuration.
#
def
specs_by_build_configuration
result
=
{}
user_build_configurations
.
keys
.
each
do
|
build_configuration
|
result
[
build_configuration
]
=
pod_targets
.
select
do
|
pod_target
|
pod_target
.
include_in_build_config?
(
build_configuration
)
end
.
map
(
&
:specs
).
flatten
end
result
end
# @return [Array<Specification::Consumer>] The consumers of the Pod.
# @return [Array<Specification::Consumer>] The consumers of the Pod.
#
#
def
spec_consumers
def
spec_consumers
...
...
spec/unit/generator/target_environment_header_spec.rb
View file @
cccca4ff
...
@@ -4,7 +4,7 @@ describe Pod::Generator::TargetEnvironmentHeader do
...
@@ -4,7 +4,7 @@ describe Pod::Generator::TargetEnvironmentHeader do
before
do
before
do
specification
=
fixture_spec
(
'banana-lib/BananaLib.podspec'
)
specification
=
fixture_spec
(
'banana-lib/BananaLib.podspec'
)
@gen
=
Pod
::
Generator
::
TargetEnvironmentHeader
.
new
(
[
specification
]
)
@gen
=
Pod
::
Generator
::
TargetEnvironmentHeader
.
new
(
{
'Debug'
=>
[
specification
]}
)
end
end
it
"generates a header files which include macro definitions for installed Pods"
do
it
"generates a header files which include macro definitions for installed Pods"
do
...
...
spec/unit/target/aggregate_target_spec.rb
View file @
cccca4ff
...
@@ -71,12 +71,32 @@ module Pod
...
@@ -71,12 +71,32 @@ module Pod
describe
"Pod targets"
do
describe
"Pod targets"
do
before
do
before
do
spec
=
fixture_spec
(
'banana-lib/BananaLib.podspec'
)
@
spec
=
fixture_spec
(
'banana-lib/BananaLib.podspec'
)
target_definition
=
Podfile
::
TargetDefinition
.
new
(
'Pods'
,
nil
)
@
target_definition
=
Podfile
::
TargetDefinition
.
new
(
'Pods'
,
nil
)
pod_target
=
PodTarget
.
new
([
spec
],
target_definition
,
config
.
sandbox
)
@pod_target
=
PodTarget
.
new
([
@spec
],
@
target_definition
,
config
.
sandbox
)
@target
=
AggregateTarget
.
new
(
target_definition
,
config
.
sandbox
)
@target
=
AggregateTarget
.
new
(
@
target_definition
,
config
.
sandbox
)
@target
.
stubs
(
:platform
).
returns
(
:ios
)
@target
.
stubs
(
:platform
).
returns
(
:ios
)
@target
.
pod_targets
=
[
pod_target
]
@target
.
pod_targets
=
[
@pod_target
]
end
it
"returns pod targets by build configuration"
do
pod_target_release
=
PodTarget
.
new
([
@spec
],
@target_definition
,
config
.
sandbox
)
pod_target_release
.
expects
(
:include_in_build_config?
).
with
(
"Debug"
).
returns
(
false
)
pod_target_release
.
expects
(
:include_in_build_config?
).
with
(
"Release"
).
returns
(
true
)
@target
.
pod_targets
=
[
@pod_target
,
pod_target_release
]
@target
.
user_build_configurations
=
{
"Debug"
=>
:debug
,
"Release"
=>
:release
}
expected
=
{
"Debug"
=>
@pod_target
.
specs
,
"Release"
=>
(
@pod_target
.
specs
+
pod_target_release
.
specs
)
}
@target
.
specs_by_build_configuration
.
should
==
expected
end
it
"returns the specs of the Pods used by this aggregate target"
do
@target
.
specs
.
map
(
&
:name
).
should
==
[
"BananaLib"
]
end
end
it
"returns the specs of the Pods used by this aggregate target"
do
it
"returns the specs of the Pods used by this aggregate target"
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