Commit 252494b6 authored by Marius Rackwitz's avatar Marius Rackwitz

Combine common setup in XCConfigHelper#add_settings_for_dependent_targets

parent ff3a38be
...@@ -70,6 +70,7 @@ module Pod ...@@ -70,6 +70,7 @@ module Pod
generate_settings_to_import_pod_targets generate_settings_to_import_pod_targets
XCConfigHelper.add_target_specific_settings(target, @xcconfig) XCConfigHelper.add_target_specific_settings(target, @xcconfig)
XCConfigHelper.add_settings_for_dependent_targets(target, pod_targets, @xcconfig)
generate_vendored_build_settings generate_vendored_build_settings
generate_other_ld_flags generate_other_ld_flags
...@@ -108,11 +109,6 @@ module Pod ...@@ -108,11 +109,6 @@ module Pod
build_settings['HEADER_SEARCH_PATHS'] = '$(inherited) ' + XCConfigHelper.quote(library_header_search_paths) build_settings['HEADER_SEARCH_PATHS'] = '$(inherited) ' + XCConfigHelper.quote(library_header_search_paths)
build_settings['OTHER_CFLAGS'] += ' ' + XCConfigHelper.quote(library_header_search_paths, '-isystem') build_settings['OTHER_CFLAGS'] += ' ' + XCConfigHelper.quote(library_header_search_paths, '-isystem')
end end
scoped_pod_targets = build_pod_targets.select(&:scoped?)
unless scoped_pod_targets.empty?
framework_search_paths = scoped_pod_targets.map(&:relative_configuration_build_dir).uniq
build_settings['FRAMEWORK_SEARCH_PATHS'] = XCConfigHelper.quote(framework_search_paths)
end
build_settings build_settings
else else
# Make headers discoverable from $PODS_ROOT/Headers directory # Make headers discoverable from $PODS_ROOT/Headers directory
......
...@@ -8,13 +8,6 @@ module Pod ...@@ -8,13 +8,6 @@ module Pod
# required by CocoaPods. # required by CocoaPods.
# #
class PodXCConfig class PodXCConfig
# @return [String] Defined to hold the default Xcode build path, so
# that when this is overridden per {PodTarget}, it is still
# possible to reference other build products relative to the
# original path.
#
SHARED_BUILD_DIR_VARIABLE = 'PODS_SHARED_BUILD_DIR'.freeze
# @return [Target] the target represented by this xcconfig. # @return [Target] the target represented by this xcconfig.
# #
attr_reader :target attr_reader :target
...@@ -57,33 +50,18 @@ module Pod ...@@ -57,33 +50,18 @@ module Pod
'HEADER_SEARCH_PATHS' => XCConfigHelper.quote(search_paths), 'HEADER_SEARCH_PATHS' => XCConfigHelper.quote(search_paths),
'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) COCOAPODS=1', 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) COCOAPODS=1',
'SKIP_INSTALL' => 'YES', 'SKIP_INSTALL' => 'YES',
'FRAMEWORK_SEARCH_PATHS' => '$(inherited) ',
'PRODUCT_BUNDLE_IDENTIFIER' => 'org.cocoapods.${PRODUCT_NAME:rfc1034identifier}', 'PRODUCT_BUNDLE_IDENTIFIER' => 'org.cocoapods.${PRODUCT_NAME:rfc1034identifier}',
# 'USE_HEADERMAP' => 'NO' # 'USE_HEADERMAP' => 'NO'
} }
@xcconfig = Xcodeproj::Config.new(config) @xcconfig = Xcodeproj::Config.new(config)
if target.requires_frameworks?
build_settings = {
SHARED_BUILD_DIR_VARIABLE => '$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)',
'CONFIGURATION_BUILD_DIR' => target.configuration_build_dir,
}
scoped_dependent_targets = target.dependent_targets.select { |t| t.should_build? && t.scoped? }
unless scoped_dependent_targets.empty?
framework_search_paths = scoped_dependent_targets.map do |target|
target.relative_configuration_build_dir("$#{SHARED_BUILD_DIR_VARIABLE}")
end
build_settings['FRAMEWORK_SEARCH_PATHS'] = XCConfigHelper.quote(framework_search_paths)
end
@xcconfig.merge!(build_settings)
end
XCConfigHelper.add_settings_for_file_accessors_of_target(target, @xcconfig) XCConfigHelper.add_settings_for_file_accessors_of_target(target, @xcconfig)
target.file_accessors.each do |file_accessor| target.file_accessors.each do |file_accessor|
@xcconfig.merge!(file_accessor.spec_consumer.pod_target_xcconfig) @xcconfig.merge!(file_accessor.spec_consumer.pod_target_xcconfig)
end end
XCConfigHelper.add_target_specific_settings(target, @xcconfig) XCConfigHelper.add_target_specific_settings(target, @xcconfig)
XCConfigHelper.add_settings_for_dependent_targets(target, target.dependent_targets, @xcconfig)
@xcconfig @xcconfig
end end
......
...@@ -4,6 +4,13 @@ module Pod ...@@ -4,6 +4,13 @@ module Pod
# Stores the shared logic of the classes of the XCConfig module. # Stores the shared logic of the classes of the XCConfig module.
# #
module XCConfigHelper module XCConfigHelper
# @return [String] Defined to hold the default Xcode build path, so
# that when this is overridden per {PodTarget}, it is still
# possible to reference other build products relative to the
# original path.
#
SHARED_BUILD_DIR_VARIABLE = 'PODS_SHARED_BUILD_DIR'.freeze
# Converts an array of strings to a single string where the each string # Converts an array of strings to a single string where the each string
# is surrounded by double quotes and separated by a space. Used to # is surrounded by double quotes and separated by a space. Used to
# represent strings in a xcconfig file. # represent strings in a xcconfig file.
...@@ -196,6 +203,47 @@ module Pod ...@@ -196,6 +203,47 @@ module Pod
add_language_specific_settings(target, xcconfig) add_language_specific_settings(target, xcconfig)
end end
# Add the search paths for frameworks and libraries the given target
# depends on, so that it can be correctly built and linked.
#
# @param [Target] target
# The target.
#
# @param [Array<PodTarget>] dependent_targets
# The pod targets the given target depends on.
#
# @param [Xcodeproj::Config] xcconfig
# The xcconfig to edit.
#
def self.add_settings_for_dependent_targets(target, dependent_targets, xcconfig)
dependent_targets = dependent_targets.select(&:should_build?)
has_configuration_build_dir = target.respond_to?(:configuration_build_dir)
if has_configuration_build_dir
build_settings = {
'CONFIGURATION_BUILD_DIR' => target.configuration_build_dir,
SHARED_BUILD_DIR_VARIABLE => '$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)',
}
build_dir_var = "$#{SHARED_BUILD_DIR_VARIABLE}"
else
build_settings = {}
build_dir_var = '$CONFIGURATION_BUILD_DIR'
end
unless dependent_targets.empty?
framework_search_paths = []
library_search_paths = []
dependent_targets.each do |dependent_target|
if dependent_target.requires_frameworks?
framework_search_paths << dependent_target.relative_configuration_build_dir(build_dir_var)
else
library_search_paths << dependent_target.relative_configuration_build_dir(build_dir_var)
end
end
build_settings['FRAMEWORK_SEARCH_PATHS'] = '$(inherited) ' + XCConfigHelper.quote(framework_search_paths.uniq) unless framework_search_paths.empty?
build_settings['LIBRARY_SEARCH_PATHS'] = '$(inherited) ' + XCConfigHelper.quote(library_search_paths.uniq) unless library_search_paths.empty?
end
xcconfig.merge!(build_settings)
end
# Checks if the given target requires language specific settings and # Checks if the given target requires language specific settings and
# configures the given Xcconfig. # configures the given Xcconfig.
# #
......
...@@ -171,7 +171,7 @@ module Pod ...@@ -171,7 +171,7 @@ module Pod
end end
it 'includes the public header paths as system headers' do it 'includes the public header paths as system headers' do
expected = '$(inherited) -iquote "$CONFIGURATION_BUILD_DIR/OrangeFramework.framework/Headers" -isystem "${PODS_ROOT}/Headers/Public"' expected = '$(inherited) -iquote "$CONFIGURATION_BUILD_DIR/OrangeFramework/OrangeFramework.framework/Headers" -isystem "${PODS_ROOT}/Headers/Public"'
@generator.stubs(:pod_targets).returns([@pod_targets.first, pod_target(fixture_spec('orange-framework/OrangeFramework.podspec'), @target_definition)]) @generator.stubs(:pod_targets).returns([@pod_targets.first, pod_target(fixture_spec('orange-framework/OrangeFramework.podspec'), @target_definition)])
@xcconfig = @generator.generate @xcconfig = @generator.generate
@xcconfig.to_hash['OTHER_CFLAGS'].should == expected @xcconfig.to_hash['OTHER_CFLAGS'].should == expected
...@@ -216,11 +216,11 @@ module Pod ...@@ -216,11 +216,11 @@ module Pod
describe 'with an unscoped pod target' do describe 'with an unscoped pod target' do
it 'adds the framework build path to the xcconfig, with quotes, as framework search paths' do it 'adds the framework build path to the xcconfig, with quotes, as framework search paths' do
@xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS'].should.be.nil @xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS'].should == '$(inherited) "$CONFIGURATION_BUILD_DIR/OrangeFramework"'
end end
it 'adds the framework header paths to the xcconfig, with quotes, as local headers' do it 'adds the framework header paths to the xcconfig, with quotes, as local headers' do
expected = '$(inherited) -iquote "$CONFIGURATION_BUILD_DIR/OrangeFramework.framework/Headers"' expected = '$(inherited) -iquote "$CONFIGURATION_BUILD_DIR/OrangeFramework/OrangeFramework.framework/Headers"'
@xcconfig.to_hash['OTHER_CFLAGS'].should == expected @xcconfig.to_hash['OTHER_CFLAGS'].should == expected
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