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
8a443085
Commit
8a443085
authored
May 15, 2015
by
Marius Rackwitz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[XCConfig] Implement the split of podspec xcconfig
parent
a210a7e7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
115 additions
and
0 deletions
+115
-0
aggregate_xcconfig.rb
lib/cocoapods/generator/xcconfig/aggregate_xcconfig.rb
+51
-0
aggregate_xcconfig_spec.rb
spec/unit/generator/xcconfig/aggregate_xcconfig_spec.rb
+64
-0
No files found.
lib/cocoapods/generator/xcconfig/aggregate_xcconfig.rb
View file @
8a443085
...
...
@@ -103,6 +103,8 @@ module Pod
end
end
@xcconfig
.
merge!
(
merged_user_target_xcconfigs
)
# TODO: Need to decide how we are going to ensure settings like these
# are always excluded from the user's project.
#
...
...
@@ -148,6 +150,55 @@ module Pod
target
.
pod_targets_for_build_configuration
(
@configuration_name
)
end
# Returns the +user_target_xcconfig+ for all pod targets grouped by keys
#
# @return [Hash{String,Hash{Target,String}]
#
def
user_target_xcconfig_values_by_target_by_key
pod_targets
.
each_with_object
({})
do
|
target
,
hash
|
target
.
spec_consumers
.
each
do
|
spec_consumer
|
spec_consumer
.
user_target_xcconfig
.
each
do
|
k
,
v
|
(
hash
[
k
]
||=
{})[
target
]
=
v
end
end
end
end
# Merges the +user_target_xcconfig+ for all pod targets into the
# #xcconfig and warns on conflicting definitions.
#
# @return [Hash{String, String}]
#
def
merged_user_target_xcconfigs
settings
=
user_target_xcconfig_values_by_target_by_key
settings
.
each_with_object
({})
do
|
(
key
,
values_by_target
),
xcconfig
|
uniq_values
=
values_by_target
.
values
.
uniq
values_are_bools
=
values_by_target
.
values
.
all?
{
|
v
|
v
=~
/(yes|no)/i
}
if
values_are_bools
# Boolean build settings
if
uniq_values
.
count
>
1
UI
.
warn
'Can\'t merge user_target_xcconfig for pod targets: '
\
"
#{
values_by_target
.
keys
.
map
(
&
:label
)
}
. Boolean build "
\
"setting
#{
key
}
has different values."
else
xcconfig
[
key
]
=
uniq_values
.
first
end
elsif
key
=~
/S$/
# Plural build settings
xcconfig
[
key
]
=
uniq_values
.
join
(
' '
)
else
# Singular build settings
if
uniq_values
.
count
>
1
UI
.
warn
'Can\'t merge user_target_xcconfig for pod targets: '
\
"
#{
values_by_target
.
keys
.
map
(
&
:label
)
}
. Singular build "
\
"setting
#{
key
}
has different values."
else
xcconfig
[
key
]
=
uniq_values
.
first
end
end
end
end
#---------------------------------------------------------------------#
end
end
...
...
spec/unit/generator/xcconfig/aggregate_xcconfig_spec.rb
View file @
8a443085
...
...
@@ -170,6 +170,70 @@ module Pod
generated
.
class
.
should
==
Xcodeproj
::
Config
end
end
#-----------------------------------------------------------------------#
describe
'with multiple pod targets with user_target_xcconfigs'
do
before
do
spec_b
=
fixture_spec
(
'orange-framework/OrangeFramework.podspec'
)
@pod_target_b
=
fixture_pod_target
(
spec_b
)
@consumer_a
=
@consumer
@consumer_b
=
@pod_target_b
.
spec_consumers
.
last
@target
.
pod_targets
<<
@pod_target_b
end
describe
'with boolean build settings'
do
it
'does not warn if the values are equal'
do
@consumer_a
.
stubs
(
:user_target_xcconfig
).
returns
(
'ENABLE_HEADER_DEPENDENCIES'
=>
'YES'
)
@consumer_b
.
stubs
(
:user_target_xcconfig
).
returns
(
'ENABLE_HEADER_DEPENDENCIES'
=>
'YES'
)
@xcconfig
=
@generator
.
generate
@xcconfig
.
to_hash
[
'ENABLE_HEADER_DEPENDENCIES'
].
should
==
'YES'
end
it
'warns if the values differ'
do
@consumer_a
.
stubs
(
:user_target_xcconfig
).
returns
(
'ENABLE_HEADER_DEPENDENCIES'
=>
'YES'
)
@consumer_b
.
stubs
(
:user_target_xcconfig
).
returns
(
'ENABLE_HEADER_DEPENDENCIES'
=>
'NO'
)
@xcconfig
=
@generator
.
generate
UI
.
warnings
.
should
.
include
'Can\'t merge user_target_xcconfig for pod targets: '
\
'["Pods-BananaLib", "Pods-OrangeFramework"]. Boolean build setting '
\
'ENABLE_HEADER_DEPENDENCIES has different values.'
end
end
describe
'with list build settings'
do
it
'only adds the value once if the values are equal'
do
@consumer_a
.
stubs
(
:user_target_xcconfig
).
returns
(
'OTHER_CPLUSPLUSFLAGS'
=>
'-std=c++1y'
)
@consumer_b
.
stubs
(
:user_target_xcconfig
).
returns
(
'OTHER_CPLUSPLUSFLAGS'
=>
'-std=c++1y'
)
@xcconfig
=
@generator
.
generate
@xcconfig
.
to_hash
[
'OTHER_CPLUSPLUSFLAGS'
].
should
==
'-std=c++1y'
end
it
'adds both values if the values differ'
do
@consumer_a
.
stubs
(
:user_target_xcconfig
).
returns
(
'OTHER_CPLUSPLUSFLAGS'
=>
'-std=c++1y'
)
@consumer_b
.
stubs
(
:user_target_xcconfig
).
returns
(
'OTHER_CPLUSPLUSFLAGS'
=>
'-stdlib=libc++'
)
@xcconfig
=
@generator
.
generate
@xcconfig
.
to_hash
[
'OTHER_CPLUSPLUSFLAGS'
].
should
==
'-std=c++1y -stdlib=libc++'
end
end
describe
'with singular build settings'
do
it
'does not warn if the values are equal'
do
@consumer_a
.
stubs
(
:user_target_xcconfig
).
returns
(
'STRIP_STYLE'
=>
'non-global'
)
@consumer_b
.
stubs
(
:user_target_xcconfig
).
returns
(
'STRIP_STYLE'
=>
'non-global'
)
@xcconfig
=
@generator
.
generate
@xcconfig
.
to_hash
[
'STRIP_STYLE'
].
should
==
'non-global'
end
it
'does warn if the values differ'
do
@consumer_a
.
stubs
(
:user_target_xcconfig
).
returns
(
'STRIP_STYLE'
=>
'non-global'
)
@consumer_b
.
stubs
(
:user_target_xcconfig
).
returns
(
'STRIP_STYLE'
=>
'all'
)
@xcconfig
=
@generator
.
generate
UI
.
warnings
.
should
.
include
'Can\'t merge user_target_xcconfig for pod targets: '
\
'["Pods-BananaLib", "Pods-OrangeFramework"]. Singular build setting '
\
'STRIP_STYLE has different values.'
end
end
end
end
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