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
0ff5b203
Commit
0ff5b203
authored
Jul 04, 2013
by
Fabio Pelosin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[PrivatePodXcconfig] Handle xcconfig conditionals
Closes #1171
parent
cf1643ea
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
132 additions
and
23 deletions
+132
-23
Gemfile.lock
Gemfile.lock
+1
-1
xcconfig.rb
lib/cocoapods/generator/xcconfig.rb
+6
-2
private_pod_xcconfig.rb
lib/cocoapods/generator/xcconfig/private_pod_xcconfig.rb
+60
-9
pod_target_installer.rb
...oapods/installer/target_installer/pod_target_installer.rb
+4
-4
private_pod_xcconfig_spec.rb
spec/unit/generator/xcconfig/private_pod_xcconfig_spec.rb
+61
-7
No files found.
Gemfile.lock
View file @
0ff5b203
...
@@ -7,7 +7,7 @@ GIT
...
@@ -7,7 +7,7 @@ GIT
GIT
GIT
remote: https://github.com/CocoaPods/Core.git
remote: https://github.com/CocoaPods/Core.git
revision:
743a53d70e138fff2759405b9dd5b78f6db47ca5
revision:
e41d277a60b2ff96ff851750ee99135c2d7ecd13
branch: master
branch: master
specs:
specs:
cocoapods-core (0.22.1)
cocoapods-core (0.22.1)
...
...
lib/cocoapods/generator/xcconfig.rb
View file @
0ff5b203
...
@@ -10,13 +10,17 @@ module Pod
...
@@ -10,13 +10,17 @@ module Pod
# @return [Target] the target represented by this xcconfig.
# @return [Target] the target represented by this xcconfig.
#
#
attr_reader
:target
attr_reader
:target
attr_reader
:sandbox
# @param [Target] target @see target
# @param [Target] target @see target
#
#
def
initialize
(
target
)
def
initialize
(
target
)
@target
=
target
@target
=
target
@sandbox
=
target
.
sandbox
end
# @return [Sandbox] the sandbox of this target.
#
def
sandbox
target
.
sandbox
end
end
# @return [Xcodeproj::Config] The generated xcconfig.
# @return [Xcodeproj::Config] The generated xcconfig.
...
...
lib/cocoapods/generator/xcconfig/private_pod_xcconfig.rb
View file @
0ff5b203
...
@@ -9,6 +9,19 @@ module Pod
...
@@ -9,6 +9,19 @@ module Pod
#
#
class
PrivatePodXCConfig
<
XCConfig
class
PrivatePodXCConfig
<
XCConfig
# @return [Xcodeproj::Config] The public xcconfig which this one will
# use.
#
attr_reader
:public_xcconfig
# @param [Target] target @see target
# @param [Xcodeproj::Config] public_xcconfig @see public_xcconfig
#
def
initialize
(
target
,
public_xcconfig
)
super
(
target
)
@public_xcconfig
=
public_xcconfig
end
# Generates the xcconfig.
# Generates the xcconfig.
#
#
# @return [Xcodeproj::Config]
# @return [Xcodeproj::Config]
...
@@ -22,19 +35,57 @@ module Pod
...
@@ -22,19 +35,57 @@ module Pod
# 'USE_HEADERMAP' => 'NO'
# 'USE_HEADERMAP' => 'NO'
}
}
xcconfig
=
Xcodeproj
::
Config
.
new
xcconfig_hash
=
add_xcconfig_namespaced_keys
(
public_xcconfig
.
to_hash
,
config
,
target
.
xcconfig_prefix
)
target
.
spec_consumers
.
each
do
|
consumer
|
@xcconfig
=
Xcodeproj
::
Config
.
new
(
xcconfig_hash
)
add_spec_build_settings_to_xcconfig
(
consumer
,
xcconfig
)
@xcconfig
.
includes
=
[
target
.
name
]
@xcconfig
end
end
xcconfig
.
to_hash
.
each
do
|
k
,
v
|
private
prefixed_key
=
target
.
xcconfig_prefix
+
k
config
[
k
]
=
"
#{
config
[
k
]
}
${
#{
prefixed_key
}
}"
#-----------------------------------------------------------------------#
# !@group Private Helpers
# Returns the hash representation of an xcconfig which inherit from the
# namespaced keys of a given one.
#
# @param [Hash] source_config
# The xcconfig whose keys need to be inherited.
#
# @param [Hash] destination_config
# The config which should inherit the source config keys.
#
# @return [Hash] The inheriting xcconfig.
#
def
add_xcconfig_namespaced_keys
(
source_config
,
destination_config
,
prefix
)
result
=
destination_config
.
dup
source_config
.
each
do
|
key
,
value
|
prefixed_key
=
prefix
+
conditional_less_key
(
key
)
current_value
=
destination_config
[
key
]
if
current_value
result
[
key
]
=
"
#{
current_value
}
${
#{
prefixed_key
}
}"
else
result
[
key
]
=
"${
#{
prefixed_key
}
}"
end
end
result
end
end
@xcconfig
=
Xcodeproj
::
Config
.
new
(
config
)
# Strips the [*]-syntax from the given xcconfig key.
@xcconfig
.
includes
=
[
target
.
name
]
#
@xcconfig
# @param [String] key
# The key to strip.
#
# @return [String] The stripped key.
#
def
conditional_less_key
(
key
)
brackets_index
=
key
.
index
(
'['
)
if
brackets_index
key
[
0
...
brackets_index
]
else
key
end
end
end
#-----------------------------------------------------------------------#
#-----------------------------------------------------------------------#
...
...
lib/cocoapods/installer/target_installer/pod_target_installer.rb
View file @
0ff5b203
...
@@ -55,16 +55,16 @@ module Pod
...
@@ -55,16 +55,16 @@ module Pod
#
#
def
create_xcconfig_file
def
create_xcconfig_file
path
=
library
.
xcconfig_path
path
=
library
.
xcconfig_path
public_gen
=
Generator
::
PublicPodXCConfig
.
new
(
library
)
UI
.
message
"- Generating public xcconfig file at
#{
UI
.
path
(
path
)
}
"
do
UI
.
message
"- Generating public xcconfig file at
#{
UI
.
path
(
path
)
}
"
do
gen
=
Generator
::
PublicPodXCConfig
.
new
(
library
)
public_gen
.
save_as
(
path
)
gen
.
save_as
(
path
)
add_file_to_support_group
(
path
)
add_file_to_support_group
(
path
)
end
end
path
=
library
.
xcconfig_private_path
path
=
library
.
xcconfig_private_path
private_gen
=
Generator
::
PrivatePodXCConfig
.
new
(
library
,
public_gen
.
xcconfig
)
UI
.
message
"- Generating private xcconfig file at
#{
UI
.
path
(
path
)
}
"
do
UI
.
message
"- Generating private xcconfig file at
#{
UI
.
path
(
path
)
}
"
do
gen
=
Generator
::
PrivatePodXCConfig
.
new
(
library
)
private_gen
.
save_as
(
path
)
gen
.
save_as
(
path
)
xcconfig_file_ref
=
add_file_to_support_group
(
path
)
xcconfig_file_ref
=
add_file_to_support_group
(
path
)
target
.
build_configurations
.
each
do
|
c
|
target
.
build_configurations
.
each
do
|
c
|
...
...
spec/unit/generator/xcconfig/private_pod_xcconfig_spec.rb
View file @
0ff5b203
...
@@ -2,21 +2,22 @@ require File.expand_path('../../../../spec_helper', __FILE__)
...
@@ -2,21 +2,22 @@ require File.expand_path('../../../../spec_helper', __FILE__)
module
Pod
module
Pod
describe
Generator
::
PrivatePodXCConfig
do
describe
Generator
::
PrivatePodXCConfig
do
describe
"in general"
do
before
do
before
do
@spec
=
fixture_spec
(
'banana-lib/BananaLib.podspec'
)
@spec
=
fixture_spec
(
'banana-lib/BananaLib.podspec'
)
@consumer
=
@spec
.
consumer
(
:ios
)
@consumer
=
@spec
.
consumer
(
:ios
)
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
)
@pod_target
.
stubs
(
:platform
).
returns
(
:ios
)
@pod_target
.
stubs
(
:platform
).
returns
(
:ios
)
@generator
=
Generator
::
PrivatePodXCConfig
.
new
(
@pod_target
)
public_xcconfig
=
Xcodeproj
::
Config
.
new
({
"OTHER_LDFLAGS"
=>
"-framework SystemConfiguration"
})
@generator
=
Generator
::
PrivatePodXCConfig
.
new
(
@pod_target
,
public_xcconfig
)
end
end
it
"returns the sandbox"
do
it
"returns the sandbox"
do
@generator
.
sandbox
.
class
.
should
==
Sandbox
@generator
.
sandbox
.
class
.
should
==
Sandbox
end
end
#-----------------------------------------------------------------------#
before
do
before
do
@podfile
=
Podfile
.
new
@podfile
=
Podfile
.
new
@pod_target
.
target_definition
.
stubs
(
:podfile
).
returns
(
@podfile
)
@pod_target
.
target_definition
.
stubs
(
:podfile
).
returns
(
@podfile
)
...
@@ -62,14 +63,10 @@ module Pod
...
@@ -62,14 +63,10 @@ module Pod
@xcconfig
.
to_hash
[
'OTHER_LDFLAGS'
].
should
.
include
(
"${
#{
@pod_target
.
xcconfig_prefix
}
OTHER_LDFLAGS}"
)
@xcconfig
.
to_hash
[
'OTHER_LDFLAGS'
].
should
.
include
(
"${
#{
@pod_target
.
xcconfig_prefix
}
OTHER_LDFLAGS}"
)
end
end
#-----------------------------------------------------------------------#
it
'sets the relative path of the pods root for spec libraries to ${SRCROOT}'
do
it
'sets the relative path of the pods root for spec libraries to ${SRCROOT}'
do
@xcconfig
.
to_hash
[
'PODS_ROOT'
].
should
==
'${SRCROOT}'
@xcconfig
.
to_hash
[
'PODS_ROOT'
].
should
==
'${SRCROOT}'
end
end
#-----------------------------------------------------------------------#
it
"saves the xcconfig"
do
it
"saves the xcconfig"
do
path
=
temporary_directory
+
'sample.xcconfig'
path
=
temporary_directory
+
'sample.xcconfig'
@generator
.
save_as
(
path
)
@generator
.
save_as
(
path
)
...
@@ -78,4 +75,61 @@ module Pod
...
@@ -78,4 +75,61 @@ module Pod
end
end
end
end
#-------------------------------------------------------------------------#
describe
"Private Helpers"
do
before
do
@sut
=
Generator
::
PrivatePodXCConfig
.
new
(
stub
(),
stub
())
end
#----------------------------------------#
describe
"#add_xcconfig_namespaced_keys"
do
it
"appends to the values of the keys of the destination the value of the keys of the source"
do
source_config
=
{
'HEADER_SEARCH_PATHS'
=>
'${PODS_ROOT}/MyPod'
}
destination_config
=
{
'HEADER_SEARCH_PATHS'
=>
'${PODS_ROOT}/BuildHeaders'
}
result
=
@sut
.
send
(
:add_xcconfig_namespaced_keys
,
source_config
,
destination_config
,
'PREFIX_'
)
result
.
should
==
{
'HEADER_SEARCH_PATHS'
=>
'${PODS_ROOT}/BuildHeaders ${PREFIX_HEADER_SEARCH_PATHS}'
}
end
it
"uses the key of the destination xcconfig if not present in the source"
do
source_config
=
{
}
destination_config
=
{
'HEADER_SEARCH_PATHS'
=>
'${PODS_ROOT}/BuildHeaders'
}
result
=
@sut
.
send
(
:add_xcconfig_namespaced_keys
,
source_config
,
destination_config
,
'PREFIX_'
)
result
.
should
==
{
'HEADER_SEARCH_PATHS'
=>
'${PODS_ROOT}/BuildHeaders'
}
end
it
"preserves any value of the source not present in the destination"
do
source_config
=
{
'EXCLUDED_SOURCE_FILE_NAMES'
=>
'ZBarReaderViewImpl_Simulator.m'
}
destination_config
=
{
}
result
=
@sut
.
send
(
:add_xcconfig_namespaced_keys
,
source_config
,
destination_config
,
'PREFIX_'
)
result
.
should
==
{
'EXCLUDED_SOURCE_FILE_NAMES'
=>
'${PREFIX_EXCLUDED_SOURCE_FILE_NAMES}'
}
end
end
#----------------------------------------#
describe
"#conditional_less_key"
do
it
"returns the key without the xcconfig conditional syntax if present"
do
result
=
@sut
.
send
(
:conditional_less_key
,
'EXCLUDED_SOURCE_FILE_NAMES[sdk=iphoneos*][arch=*]'
)
result
.
should
==
'EXCLUDED_SOURCE_FILE_NAMES'
end
it
"returns the key as it is if no conditional syntax is present"
do
result
=
@sut
.
send
(
:conditional_less_key
,
'EXCLUDED_SOURCE_FILE_NAMES'
)
result
.
should
==
'EXCLUDED_SOURCE_FILE_NAMES'
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