Commit 13b78034 authored by Samuel E. Giddins's avatar Samuel E. Giddins

Merge pull request #4702 from CocoaPods/seg-config-defines

[Project] Change config defines to be prefixed
parents 7a838899 615ca31d
...@@ -36,6 +36,11 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ...@@ -36,6 +36,11 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
[Samuel Giddins](https://github.com/segiddins) [Samuel Giddins](https://github.com/segiddins)
[Core#284](https://github.com/CocoaPods/Core/issues/284) [Core#284](https://github.com/CocoaPods/Core/issues/284)
* Build configuration names are no longer set as pre-processor defines, but
rather `POD_CONFIGURATION_$CONFIGURATION_NAME` is defined in order to lessen
conflicts with pod code.
[#4143](https://github.com/CocoaPods/CocoaPods/issues/4143)
##### Highlighted Enhancements That Need Testing ##### Highlighted Enhancements That Need Testing
* The Podfile DSL has been cleaned up, with the removal of confusing options and * The Podfile DSL has been cleaned up, with the removal of confusing options and
...@@ -238,6 +243,11 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ...@@ -238,6 +243,11 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
[Samuel Giddins](https://github.com/segiddins) [Samuel Giddins](https://github.com/segiddins)
[#3617](https://github.com/CocoaPods/CocoaPods/issues/3617) [#3617](https://github.com/CocoaPods/CocoaPods/issues/3617)
* The pre-processor define for `DEBUG` will be set for all debug-based build
configurations when building pods.
[Samuel Giddins](https://github.com/segiddins)
[#4148](https://github.com/CocoaPods/CocoaPods/issues/4148)
## 0.39.0 (2015-10-09) ## 0.39.0 (2015-10-09)
......
...@@ -24,7 +24,7 @@ GIT ...@@ -24,7 +24,7 @@ GIT
GIT GIT
remote: https://github.com/CocoaPods/Xcodeproj.git remote: https://github.com/CocoaPods/Xcodeproj.git
revision: ffeadb7ca0edc5afafbac0304cf088c4e4b75ae5 revision: 31051f598c475307906ef9e437f44d98f600a28f
branch: master branch: master
specs: specs:
xcodeproj (0.28.2) xcodeproj (0.28.2)
......
require 'xcodeproj' require 'xcodeproj'
require 'active_support/core_ext/string/inflections'
module Pod module Pod
# The Pods project. # The Pods project.
...@@ -240,18 +241,29 @@ module Pod ...@@ -240,18 +241,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 = [defininition_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 defininition_for_build_configuration(name)
"POD_CONFIGURATION_#{name.underscore}".gsub(/[^a-zA-Z0-9_]/, '_').upcase
end
private private
# @!group Private helpers # @!group Private helpers
......
Subproject commit 75f5c4b33eb3b371a4d383b007a3bfd2933563e3 Subproject commit b0af34fb0ea6244379a1be1b5054a29b099d470d
...@@ -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,23 @@ module Pod ...@@ -409,7 +414,23 @@ 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 'transforms camel-cased configuration names to snake case' do
configuration = @project.add_build_configuration(
'MyAwesomeConfiguration', :release)
settings = configuration.build_settings
settings['GCC_PREPROCESSOR_DEFINITIONS'].should ==
['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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment