Commit 5adc5c74 authored by Fabio Pelosin's avatar Fabio Pelosin

[Xcconfig] Refactor file structure

parent 1b09daca
......@@ -62,9 +62,10 @@ module Pod
autoload :DummySource, 'cocoapods/generator/dummy_source'
autoload :PrefixHeader, 'cocoapods/generator/prefix_header'
autoload :TargetEnvironmentHeader, 'cocoapods/generator/target_environment_header'
autoload :AggregateXCConfig, 'cocoapods/generator/xcconfig'
autoload :PublicPodXCConfig, 'cocoapods/generator/xcconfig'
autoload :PrivatePodXCConfig, 'cocoapods/generator/xcconfig'
autoload :XCConfig, 'cocoapods/generator/xcconfig'
autoload :AggregateXCConfig, 'cocoapods/generator/xcconfig/aggregate_xcconfig'
autoload :PublicPodXCConfig, 'cocoapods/generator/xcconfig/public_pod_xcconfig'
autoload :PrivatePodXCConfig, 'cocoapods/generator/xcconfig/private_pod_xcconfig'
end
module Hooks
......
......@@ -111,123 +111,6 @@ module Pod
#-----------------------------------------------------------------------#
end
#-------------------------------------------------------------------------#
class AggregateXCConfig < XCConfig
# Generates the xcconfig for the Pod integration target.
#
# @note The xcconfig file for a Pods integration target includes the
# namespaced xcconfig files for each spec target dependency.
# Each namespaced configuration value is merged into the Pod
# xcconfig file.
#
# @return [Xcodeproj::Config]
#
def generate
ld_flags = '-ObjC'
if aggregate_target.target_definition.podfile.set_arc_compatibility_flag?
ld_flags << ' -fobjc-arc'
end
config = {
'ALWAYS_SEARCH_USER_PATHS' => 'YES',
'OTHER_LDFLAGS' => ld_flags,
'HEADER_SEARCH_PATHS' => quote(sandbox.public_headers.search_paths),
'PODS_ROOT' => aggregate_target.relative_pods_root,
'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) COCOAPODS=1',
}
aggregate_target.pod_targets.each do |lib|
consumer_xcconfig(lib.consumer).to_hash.each do |k, v|
prefixed_key = lib.xcconfig_prefix + k
config[k] = "#{config[k]} ${#{prefixed_key}}"
end
end
@xcconfig = Xcodeproj::Config.new(config)
@xcconfig.includes = aggregate_target.pod_targets.map(&:name)
@xcconfig
end
end
#-------------------------------------------------------------------------#
class PublicPodXCConfig < XCConfig
# Generates and saves the xcconfig to the given path.
#
# @param [Pathname] path
# the path where the prefix header should be stored.
#
# @note The public xcconfig file for a spec target is completely
# namespaced to prevent configuration value collision with other
# spec configurations.
#
# @return [void]
#
def save_as(path)
generate.save_as(path, aggregate_target.xcconfig_prefix)
end
# Generates the xcconfig for the aggregate_target.
#
# @note The xcconfig file for a public spec target includes the
# standard podspec defined values including libraries,
# frameworks, weak frameworks and xcconfig overrides.
#
# @return [Xcodeproj::Config]
#
def generate
@xcconfig = consumer_xcconfig(aggregate_target.consumer)
@xcconfig
end
end
#-------------------------------------------------------------------------#
class PrivatePodXCConfig < XCConfig
# Generates the xcconfig for the aggregate_target.
#
# @note The private xcconfig file for a spec target includes the public
# namespaced xcconfig file and merges the configuration values
# with the default private configuration values.
#
# @return [Xcodeproj::Config]
#
def generate
ld_flags = '-ObjC'
if aggregate_target.consumer.requires_arc?
ld_flags << ' -fobjc-arc'
end
config = {
'ALWAYS_SEARCH_USER_PATHS' => 'YES',
'OTHER_LDFLAGS' => ld_flags,
'PODS_ROOT' => '${SRCROOT}',
'HEADER_SEARCH_PATHS' => quote(aggregate_target.build_headers.search_paths) + ' ' + quote(sandbox.public_headers.search_paths),
'GCC_PREPROCESSOR_DEFINITIONS' => 'COCOAPODS=1',
# 'USE_HEADERMAP' => 'NO'
}
consumer_xcconfig(aggregate_target.consumer).to_hash.each do |k, v|
prefixed_key = aggregate_target.xcconfig_prefix + k
config[k] = "#{config[k]} ${#{prefixed_key}}"
end
@xcconfig = Xcodeproj::Config.new(config)
@xcconfig.includes = [aggregate_target.name]
@xcconfig
end
end
#-------------------------------------------------------------------------#
end
end
module Pod
module Generator
#
class AggregateXCConfig < XCConfig
# Generates the xcconfig for the Pod integration target.
#
# @note The xcconfig file for a Pods integration target includes the
# namespaced xcconfig files for each spec target dependency.
# Each namespaced configuration value is merged into the Pod
# xcconfig file.
#
# @return [Xcodeproj::Config]
#
def generate
ld_flags = '-ObjC'
if aggregate_target.target_definition.podfile.set_arc_compatibility_flag?
ld_flags << ' -fobjc-arc'
end
config = {
'ALWAYS_SEARCH_USER_PATHS' => 'YES',
'OTHER_LDFLAGS' => ld_flags,
'HEADER_SEARCH_PATHS' => quote(sandbox.public_headers.search_paths),
'PODS_ROOT' => aggregate_target.relative_pods_root,
'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) COCOAPODS=1',
}
aggregate_target.pod_targets.each do |lib|
consumer_xcconfig(lib.consumer).to_hash.each do |k, v|
prefixed_key = lib.xcconfig_prefix + k
config[k] = "#{config[k]} ${#{prefixed_key}}"
end
end
@xcconfig = Xcodeproj::Config.new(config)
@xcconfig.includes = aggregate_target.pod_targets.map(&:name)
@xcconfig
end
#-----------------------------------------------------------------------#
end
end
end
module Pod
module Generator
#
class PrivatePodXCConfig < XCConfig
# Generates the xcconfig for the aggregate_target.
#
# @note The private xcconfig file for a spec target includes the public
# namespaced xcconfig file and merges the configuration values
# with the default private configuration values.
#
# @return [Xcodeproj::Config]
#
def generate
ld_flags = '-ObjC'
if aggregate_target.consumer.requires_arc?
ld_flags << ' -fobjc-arc'
end
config = {
'ALWAYS_SEARCH_USER_PATHS' => 'YES',
'OTHER_LDFLAGS' => ld_flags,
'PODS_ROOT' => '${SRCROOT}',
'HEADER_SEARCH_PATHS' => quote(aggregate_target.build_headers.search_paths) + ' ' + quote(sandbox.public_headers.search_paths),
'GCC_PREPROCESSOR_DEFINITIONS' => 'COCOAPODS=1',
# 'USE_HEADERMAP' => 'NO'
}
consumer_xcconfig(aggregate_target.consumer).to_hash.each do |k, v|
prefixed_key = aggregate_target.xcconfig_prefix + k
config[k] = "#{config[k]} ${#{prefixed_key}}"
end
@xcconfig = Xcodeproj::Config.new(config)
@xcconfig.includes = [aggregate_target.name]
@xcconfig
end
#-----------------------------------------------------------------------#
end
end
end
module Pod
module Generator
#
class PublicPodXCConfig < XCConfig
# Generates and saves the xcconfig to the given path.
#
# @param [Pathname] path
# the path where the prefix header should be stored.
#
# @note The public xcconfig file for a spec target is completely
# namespaced to prevent configuration value collision with other
# spec configurations.
#
# @return [void]
#
def save_as(path)
generate.save_as(path, aggregate_target.xcconfig_prefix)
end
# Generates the xcconfig for the aggregate_target.
#
# @note The xcconfig file for a public spec target includes the
# standard podspec defined values including libraries,
# frameworks, weak frameworks and xcconfig overrides.
#
# @return [Xcodeproj::Config]
#
def generate
@xcconfig = consumer_xcconfig(aggregate_target.consumer)
@xcconfig
end
#-----------------------------------------------------------------------#
end
end
end
require File.expand_path('../../../spec_helper', __FILE__)
module Pod
describe Generator::AggregateXCConfig do
end
end
require File.expand_path('../../../spec_helper', __FILE__)
module Pod
describe Generator::PrivatePodXCConfig do
end
end
require File.expand_path('../../../spec_helper', __FILE__)
module Pod
describe Generator::PublicPodXCConfig do
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