-
Notifications
You must be signed in to change notification settings - Fork 352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Whitelist Pods by build configuration #154
Changes from 16 commits
affbeae
296df85
cff8c54
73c5a6b
421acb9
1f685c0
c53a14e
9b1567f
6d775a3
01923d7
d793bc0
70272e1
1f6273a
9ec5cf9
fd906f7
cda7ff3
a2f2d24
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -316,6 +316,60 @@ def inhibit_warnings_for_pod(pod_name) | |
|
||
#--------------------------------------# | ||
|
||
# Whether a specific pod should be linked to the target when building for | ||
# a specific configuration. If a pod has not been explicitly whitelisted | ||
# for any configuration, it is implicitly whitelisted. | ||
# | ||
# @param [String] pod_name | ||
# The pod that we're querying about inclusion for in the given | ||
# configuration. | ||
# | ||
# @param [String] configuration_name | ||
# The configuration that we're querying about inclusion of the | ||
# pod in. | ||
# | ||
# @return [Bool] flag | ||
# Whether the pod should be linked with the target | ||
# | ||
def pod_whitelisted_for_configuration?(pod_name, configuration_name) | ||
found = false | ||
configuration_pod_whitelist.each do |configuration, pods| | ||
if pods.include?(pod_name) | ||
found = true | ||
return true if configuration == configuration_name | ||
end | ||
end | ||
!found | ||
end | ||
|
||
# Whitelists a pod for a specific configuration. If a pod is whitelisted | ||
# for any configuration, it will only be linked with the target in the | ||
# configuration(s) specified. If it is not whitelisted for any configuration, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. [83/80] |
||
# it is implicitly included in all configurations. | ||
# | ||
# @param [String] pod_name | ||
# The pod that should be included in the given configuration. | ||
# | ||
# @param [String, Symbol] configuration_name | ||
# The configuration that the pod should be included in | ||
# | ||
# @return [void] | ||
# | ||
def whitelist_pod_for_configuration(pod_name, configuration_name) | ||
configuration_name = configuration_name.to_s | ||
configuration_pod_whitelist[configuration_name] ||= [] | ||
configuration_pod_whitelist[configuration_name] << pod_name | ||
end | ||
|
||
# @return [Array<String>] unique list of all configurations for which | ||
# pods have been whitelisted. | ||
# | ||
def all_whitelisted_configurations | ||
configuration_pod_whitelist.keys.uniq | ||
end | ||
|
||
#--------------------------------------# | ||
|
||
# @return [Platform] the platform of the target definition. | ||
# | ||
# @note If no deployment target has been specified a default value is | ||
|
@@ -384,6 +438,7 @@ def set_platform(name, target = nil) | |
# | ||
def store_pod(name, *requirements) | ||
parse_inhibit_warnings(name, requirements) | ||
parse_configuration_whitelist(name, requirements) | ||
|
||
if requirements && !requirements.empty? | ||
pod = { name => requirements } | ||
|
@@ -444,6 +499,7 @@ def store_podspec(options = nil) | |
build_configurations | ||
dependencies | ||
children | ||
configuration_pod_whitelist | ||
).freeze | ||
|
||
# @return [Hash] The hash representation of the target definition. | ||
|
@@ -537,6 +593,16 @@ def inhibit_warnings_hash | |
get_hash_value('inhibit_warnings', {}) | ||
end | ||
|
||
# Returns the configuration_pod_whitelist hash | ||
# | ||
# @return [Hash<String, Array>] Hash with configuration name as key, | ||
# array of pod names to be linked in builds with that configuration | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. [81/80] |
||
# as value. | ||
# | ||
def configuration_pod_whitelist | ||
get_hash_value('configuration_pod_whitelist', {}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
end | ||
|
||
# @return [Array<Dependency>] The dependencies specified by the user for | ||
# this target definition. | ||
# | ||
|
@@ -619,6 +685,32 @@ def parse_inhibit_warnings(name, requirements) | |
requirements.pop if options.empty? | ||
end | ||
|
||
# Removes :configurations or :configuration from the requirements list, | ||
# and adds the pod's name into the internal hash for which pods should be | ||
# linked in which configuration only. | ||
# | ||
# @param [String] pod name | ||
# | ||
# @param [Array] requirements | ||
# If :configurations is the only key in the hash, the hash | ||
# should be destroyed because it confuses Gem::Dependency. | ||
# | ||
# @return [void] | ||
# | ||
def parse_configuration_whitelist(name, requirements) | ||
options = requirements.last | ||
return requirements unless options.is_a?(Hash) | ||
|
||
configurations = options.delete(:configurations) | ||
configurations ||= options.delete(:configuration) | ||
if configurations | ||
Array(configurations).each do |configuration| | ||
whitelist_pod_for_configuration(name, configuration) | ||
end | ||
end | ||
requirements.pop if options.empty? | ||
end | ||
|
||
#-----------------------------------------------------------------------# | ||
end | ||
end | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,37 @@ module Pod | |
podfile.dependencies.find { |d| d.root_name == 'SSZipArchive' }.should == Dependency.new('SSZipArchive', '>= 0.1') | ||
end | ||
|
||
it 'white-list dependencies on all build configuration by default' do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
podfile = Podfile.new do | ||
pod 'PonyDebugger' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
end | ||
|
||
target = podfile.target_definitions['Pods'] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
target.pod_whitelisted_for_configuration?('PonyDebugger', 'Release').should.be.true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. [91/80] |
||
target.pod_whitelisted_for_configuration?('PonyDebugger', 'Debug').should.be.true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. [89/80] |
||
end | ||
|
||
it 'allows to white-list a dependency on multiple build configuration' do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
podfile = Podfile.new do | ||
pod 'PonyDebugger', :configurations => ['Release', 'App Store'] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the new Ruby 1.9 hash syntax. |
||
end | ||
|
||
target = podfile.target_definitions['Pods'] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
target.pod_whitelisted_for_configuration?('PonyDebugger', 'Release').should.be.true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. [91/80] |
||
target.pod_whitelisted_for_configuration?('PonyDebugger', 'App Store').should.be.true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. [93/80] |
||
target.pod_whitelisted_for_configuration?('PonyDebugger', 'Debug').should.be.false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. [90/80] |
||
end | ||
|
||
it 'allows to white-list a dependency on a build configuration' do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
podfile = Podfile.new do | ||
pod 'PonyDebugger', :configuration => 'Release' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the new Ruby 1.9 hash syntax. |
||
end | ||
|
||
target = podfile.target_definitions['Pods'] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
target.pod_whitelisted_for_configuration?('PonyDebugger', 'Release').should.be.true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. [91/80] |
||
target.pod_whitelisted_for_configuration?('PonyDebugger', 'Debug').should.be.false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. [90/80] |
||
end | ||
|
||
it 'raises if no name is specified for a Pod' do | ||
lambda do | ||
Podfile.new do | ||
|
@@ -92,7 +123,7 @@ module Pod | |
end | ||
end | ||
|
||
it 'allows to specify the user xcode project for a Target definition' do | ||
it 'allows to specify the user Xcode project for a Target definition' do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
podfile = Podfile.new { xcodeproj 'App.xcodeproj' } | ||
podfile.target_definitions['Pods'].user_project_path.should == 'App.xcodeproj' | ||
end | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -230,6 +230,43 @@ module Pod | |
|
||
#--------------------------------------# | ||
|
||
it 'whitelists pods by default' do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
@root.store_pod('ObjectiveSugar') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
@root.should.pod_whitelisted_for_configuration?('ObjectiveSugar', 'Release') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. [84/80] There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. [84/80] |
||
end | ||
|
||
it 'does not enable pods for un-whitelisted configurations if it is whitelisted for another' do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. [101/80] There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. [101/80] |
||
@root.store_pod('ObjectiveSugar') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
@root.whitelist_pod_for_configuration('ObjectiveSugar', 'Release') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
@root.should.not.pod_whitelisted_for_configuration?('ObjectiveSugar', 'Debug') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. [86/80] There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. [86/80] |
||
end | ||
|
||
it 'enables pods for configurations they are whitelisted for' do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
@root.store_pod('ObjectiveSugar', :configuration => 'Release') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the new Ruby 1.9 hash syntax. |
||
@root.should.pod_whitelisted_for_configuration?('ObjectiveSugar', 'Release') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. [84/80] |
||
@root.should.not.pod_whitelisted_for_configuration?('ObjectiveSugar', 'Debug') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. [86/80] |
||
@root.store_pod('AFNetworking', :configurations => ['Debug']) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the new Ruby 1.9 hash syntax. |
||
@root.should.pod_whitelisted_for_configuration?('AFNetworking', 'Debug') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
@root.should.not.pod_whitelisted_for_configuration?('AFNetworking', 'Release') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. [86/80] |
||
end | ||
|
||
it 'coerces configuration names to strings' do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
@root.store_pod('ObjectiveSugar', :configuration => :Release) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the new Ruby 1.9 hash syntax. |
||
@root.should.pod_whitelisted_for_configuration?('ObjectiveSugar', 'Release') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. [84/80] There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. [84/80] |
||
@root.should.not.pod_whitelisted_for_configuration?('ObjectiveSugar', 'Debug') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. [86/80] |
||
end | ||
|
||
it 'returns a unique list of all whitelisted configurations' do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
@root.all_whitelisted_configurations.should == [] | ||
@root.whitelist_pod_for_configuration('ObjectiveSugar', 'Release') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
@root.whitelist_pod_for_configuration('AFNetworking', 'Release') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
@root.all_whitelisted_configurations.should == ['Release'] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
@root.whitelist_pod_for_configuration('Objective-Record', 'Debug') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
@root.all_whitelisted_configurations.should == %w(Release Debug) | ||
end | ||
|
||
#--------------------------------------# | ||
|
||
it 'returns its platform' do | ||
@root.platform.should == Pod::Platform.new(:ios, '6.0') | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use
next
to skip iteration.