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
17702a1b
Commit
17702a1b
authored
Dec 30, 2015
by
Samuel Giddins
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Project] Change config defines to be prefixed
parent
7a838899
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
9 deletions
+33
-9
project.rb
lib/cocoapods/project.rb
+15
-4
project_spec.rb
spec/unit/project_spec.rb
+18
-5
No files found.
lib/cocoapods/project.rb
View file @
17702a1b
...
@@ -240,18 +240,29 @@ module Pod
...
@@ -240,18 +240,29 @@ module Pod
#
#
def
add_build_configuration
(
name
,
type
)
def
add_build_configuration
(
name
,
type
)
build_configuration
=
super
build_configuration
=
super
values
=
[
"
#{
name
.
gsub
(
/[^a-zA-Z0-9_]/
,
'_'
).
sub
(
/(^[0-9])/
,
'_\1'
).
upcase
}
=1"
]
settings
=
build_configuration
.
build_settings
settings
=
build_configuration
.
build_settings
definitions
=
Array
(
settings
[
'GCC_PREPROCESSOR_DEFINITIONS'
])
definitions
=
settings
[
'GCC_PREPROCESSOR_DEFINITIONS'
]
||
[
'$(inherited)'
]
values
.
each
do
|
value
|
defines
=
[
define_for_build_configuration
(
name
)]
defines
<<
'DEBUG'
if
type
==
:debug
defines
.
each
do
|
define
|
value
=
"
#{
define
}
=1"
unless
definitions
.
include?
(
value
)
unless
definitions
.
include?
(
value
)
definitions
<<
value
definitions
.
unshift
(
value
)
end
end
end
end
settings
[
'GCC_PREPROCESSOR_DEFINITIONS'
]
=
definitions
settings
[
'GCC_PREPROCESSOR_DEFINITIONS'
]
=
definitions
build_configuration
build_configuration
end
end
# @param [String] name
# The name of the build configuration.
#
# @return [String] The preprocessor definition to set for the configuration.
#
def
define_for_build_configuration
(
name
)
"POD_CONFIGURATION_
#{
name
}
"
.
gsub
(
/[^a-zA-Z0-9_]/
,
'_'
).
upcase
end
private
private
# @!group Private helpers
# @!group Private helpers
...
...
spec/unit/project_spec.rb
View file @
17702a1b
...
@@ -383,25 +383,30 @@ module Pod
...
@@ -383,25 +383,30 @@ module Pod
it
'adds a preprocessor definition for build configurations'
do
it
'adds a preprocessor definition for build configurations'
do
configuration
=
@project
.
add_build_configuration
(
'Release'
,
:release
)
configuration
=
@project
.
add_build_configuration
(
'Release'
,
:release
)
settings
=
configuration
.
build_settings
settings
=
configuration
.
build_settings
settings
[
'GCC_PREPROCESSOR_DEFINITIONS'
].
should
.
include
(
'RELEASE=1'
)
settings
[
'GCC_PREPROCESSOR_DEFINITIONS'
].
should
==
[
'POD_CONFIGURATION_RELEASE=1'
,
'$(inherited)'
]
end
end
it
"doesn't create invalid preprocessor definitions for configurations"
do
it
"doesn't create invalid preprocessor definitions for configurations"
do
configuration
=
@project
.
add_build_configuration
(
'1 Release-Foo.bar'
,
:release
)
configuration
=
@project
.
add_build_configuration
(
'1 Release-Foo.bar'
,
:release
)
settings
=
configuration
.
build_settings
settings
=
configuration
.
build_settings
settings
[
'GCC_PREPROCESSOR_DEFINITIONS'
].
should
.
include
(
'_1_RELEASE_FOO_BAR=1'
)
settings
[
'GCC_PREPROCESSOR_DEFINITIONS'
].
should
.
include
(
'
POD_CONFIGURATION
_1_RELEASE_FOO_BAR=1'
)
end
end
it
"doesn't duplicate values"
do
it
"doesn't duplicate values"
do
original
=
@project
.
build_configuration_list
[
'Debug'
]
original
=
@project
.
build_configuration_list
[
'Debug'
]
original_settings
=
original
.
build_settings
original_settings
=
original
.
build_settings
original_settings
[
'GCC_PREPROCESSOR_DEFINITIONS'
].
should
==
original_settings
[
'GCC_PREPROCESSOR_DEFINITIONS'
].
should
==
[
'DEBUG=1'
,
'$(inherited)'
]
[
'
POD_CONFIGURATION_DEBUG=1'
,
'
DEBUG=1'
,
'$(inherited)'
]
configuration
=
@project
.
add_build_configuration
(
'Debug'
,
:debug
)
configuration
=
@project
.
add_build_configuration
(
'Debug'
,
:debug
)
settings
=
configuration
.
build_settings
settings
=
configuration
.
build_settings
settings
[
'GCC_PREPROCESSOR_DEFINITIONS'
].
should
==
settings
[
'GCC_PREPROCESSOR_DEFINITIONS'
].
should
==
[
'DEBUG=1'
,
'$(inherited)'
]
[
'POD_CONFIGURATION_DEBUG=1'
,
'DEBUG=1'
,
'$(inherited)'
]
configuration
=
@project
.
add_build_configuration
(
'Debug-Based'
,
:debug
)
settings
=
configuration
.
build_settings
settings
[
'GCC_PREPROCESSOR_DEFINITIONS'
].
should
==
[
'POD_CONFIGURATION_DEBUG_BASED=1'
,
'DEBUG=1'
,
'$(inherited)'
]
end
end
it
'normalizes the name of the configuration'
do
it
'normalizes the name of the configuration'
do
...
@@ -409,7 +414,15 @@ module Pod
...
@@ -409,7 +414,15 @@ module Pod
'My Awesome Configuration'
,
:release
)
'My Awesome Configuration'
,
:release
)
settings
=
configuration
.
build_settings
settings
=
configuration
.
build_settings
settings
[
'GCC_PREPROCESSOR_DEFINITIONS'
].
should
==
settings
[
'GCC_PREPROCESSOR_DEFINITIONS'
].
should
==
[
'MY_AWESOME_CONFIGURATION=1'
]
[
'POD_CONFIGURATION_MY_AWESOME_CONFIGURATION=1'
,
"$(inherited)"
]
end
it
'adds DEBUG for configurations based upon :debug'
do
configuration
=
@project
.
add_build_configuration
(
'Config'
,
:debug
)
settings
=
configuration
.
build_settings
settings
[
'GCC_PREPROCESSOR_DEFINITIONS'
].
should
==
[
"POD_CONFIGURATION_CONFIG=1"
,
"DEBUG=1"
,
"$(inherited)"
]
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