Commit 23b8cd37 authored by Fabio Pelosin's avatar Fabio Pelosin

[Target] Refactor

parent 402d214a
...@@ -23,8 +23,8 @@ module Pod ...@@ -23,8 +23,8 @@ module Pod
autoload :Installer, 'cocoapods/installer' autoload :Installer, 'cocoapods/installer'
autoload :SourcesManager, 'cocoapods/sources_manager' autoload :SourcesManager, 'cocoapods/sources_manager'
autoload :Target, 'cocoapods/target' autoload :Target, 'cocoapods/target'
autoload :AggregateTarget, 'cocoapods/target/aggregate_target' autoload :AggregateTarget, 'cocoapods/target'
autoload :PodTarget, 'cocoapods/target/pod_target' autoload :PodTarget, 'cocoapods/target'
autoload :Project, 'cocoapods/project' autoload :Project, 'cocoapods/project'
autoload :Resolver, 'cocoapods/resolver' autoload :Resolver, 'cocoapods/resolver'
autoload :Sandbox, 'cocoapods/sandbox' autoload :Sandbox, 'cocoapods/sandbox'
......
...@@ -2,93 +2,96 @@ module Pod ...@@ -2,93 +2,96 @@ module Pod
module Generator module Generator
module XCConfig module XCConfig
# Generates the xcconfigs for the aggregate targets. # Generates the xcconfigs for the aggregate targets.
#
class AggregateXCConfig
# @return [Target] the target represented by this xcconfig.
# #
attr_reader :target class AggregateXCConfig
# @param [Target] target @see target # @return [Target] the target represented by this xcconfig.
# #
def initialize(target) attr_reader :target
@target = target attr_reader :sandbox_root
end
# @return [Xcodeproj::Config] The generated xcconfig. # @param [Target] target @see target
# #
attr_reader :xcconfig def initialize(target, sandbox_root)
@target = target
@sandbox_root = sandbox_root
end
# Generates and saves the xcconfig to the given path. # @return [Xcodeproj::Config] The generated xcconfig.
# #
# @param [Pathname] path attr_reader :xcconfig
# the path where the prefix header should be stored.
#
# @return [void]
#
def save_as(path)
generate.save_as(path)
end
# Generates the xcconfig. # Generates and saves the xcconfig to the given path.
# #
# @note The xcconfig file for a Pods integration target includes the # @param [Pathname] path
# namespaced xcconfig files for each spec target dependency. # the path where the prefix header should be stored.
# Each namespaced configuration value is merged into the Pod #
# xcconfig file. # @return [void]
# #
# @todo This doesn't include the specs xcconfigs anymore and now the def save_as(path)
# logic is duplicated. generate.save_as(path)
# end
# @return [Xcodeproj::Config]
#
def generate
@xcconfig = Xcodeproj::Config.new({
'OTHER_LDFLAGS' => XCConfigHelper.default_ld_flags(target),
'HEADER_SEARCH_PATHS' => XCConfigHelper.quote(target.sandbox.public_headers.search_paths),
'PODS_ROOT' => relative_pods_root,
'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) COCOAPODS=1',
})
target.pod_targets.each do |pod_target| # Generates the xcconfig.
pod_target.file_accessors.each do |file_accessor| #
XCConfigHelper.add_spec_build_settings_to_xcconfig(file_accessor.spec_consumer, @xcconfig) # @note The xcconfig file for a Pods integration target includes the
file_accessor.vendored_frameworks.each do |vendored_framework| # namespaced xcconfig files for each spec target dependency.
XCConfigHelper.add_framework_build_settings(vendored_framework, @xcconfig, target.sandbox.root) # Each namespaced configuration value is merged into the Pod
end # xcconfig file.
file_accessor.vendored_libraries.each do |vendored_library| #
XCConfigHelper.add_library_build_settings(vendored_library, @xcconfig, target.sandbox.root) # @todo This doesn't include the specs xcconfigs anymore and now the
# logic is duplicated.
#
# @return [Xcodeproj::Config]
#
def generate
@xcconfig = Xcodeproj::Config.new({
'OTHER_LDFLAGS' => XCConfigHelper.default_ld_flags(target),
'HEADER_SEARCH_PATHS' => XCConfigHelper.quote(target.public_headers_store.search_paths),
'PODS_ROOT' => relative_pods_root,
'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) COCOAPODS=1',
})
target.children.each do |pod_target|
pod_target.file_accessors.each do |file_accessor|
XCConfigHelper.add_spec_build_settings_to_xcconfig(file_accessor.spec_consumer, @xcconfig)
file_accessor.vendored_frameworks.each do |vendored_framework|
XCConfigHelper.add_framework_build_settings(vendored_framework, @xcconfig, sandbox_root)
end
file_accessor.vendored_libraries.each do |vendored_library|
XCConfigHelper.add_library_build_settings(vendored_library, @xcconfig, sandbox_root)
end
end end
end end
# TODO Need to decide how we are going to ensure settings like these
# are always excluded from the user's project.
#
# See https://github.com/CocoaPods/CocoaPods/issues/1216
@xcconfig.attributes.delete('USE_HEADERMAP')
@xcconfig
end end
# TODO Need to decide how we are going to ensure settings like these #-----------------------------------------------------------------------#
# are always excluded from the user's project.
#
# See https://github.com/CocoaPods/CocoaPods/issues/1216
@xcconfig.attributes.delete('USE_HEADERMAP')
@xcconfig # @return [String] The xcconfig path of the root from the `$(SRCROOT)`
end # variable of the user's project.
#
# @return [String] The xcconfig path of the root from the `$(SRCROOT)` # TODO: return the root of the sandbox
# variable of the user's project. # The pods root is used by the copy resources script
# #
# TODO: return the root of the sandbox def relative_pods_root
# The pods root is used by the copy resources script if target.user_project_path
# "${SRCROOT}/#{sandbox_root.relative_path_from(target.user_project_path.dirname)}"
def relative_pods_root else
if target.user_project_path sandbox_root
"${SRCROOT}/#{target.support_files_root.relative_path_from(target.user_project_path.dirname)}" end
else
target.support_files_root.to_s
end end
end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
end
end end
end end
end end
end
...@@ -2,116 +2,116 @@ module Pod ...@@ -2,116 +2,116 @@ module Pod
module Generator module Generator
module XCConfig module XCConfig
# Generates the private xcconfigs for the pod targets. # Generates the private xcconfigs for the pod targets.
#
# The private xcconfig file for a Pod target merges the configuration
# values of the public namespaced xcconfig with the default private
# configuration values required by CocoaPods.
#
class PrivatePodXCConfig
# @return [Target] the target represented by this xcconfig.
# #
attr_reader :target # The private xcconfig file for a Pod target merges the configuration
# values of the public namespaced xcconfig with the default private
# @return [Xcodeproj::Config] The public xcconfig which this one will # configuration values required by CocoaPods.
# use.
# #
attr_reader :public_xcconfig class PrivatePodXCConfig
# @param [Target] target @see target # @return [Target] the target represented by this xcconfig.
# @param [Xcodeproj::Config] public_xcconfig @see public_xcconfig #
# attr_reader :target
def initialize(target, public_xcconfig)
@target = target
@public_xcconfig = public_xcconfig
end
# @return [Xcodeproj::Config] The generated xcconfig. # @return [Xcodeproj::Config] The public xcconfig which this one will
# # use.
attr_reader :xcconfig #
attr_reader :public_xcconfig
# Generates and saves the xcconfig to the given path. # @param [Target] target @see target
# # @param [Xcodeproj::Config] public_xcconfig @see public_xcconfig
# @param [Pathname] path #
# the path where the prefix header should be stored. def initialize(target, public_xcconfig)
# @target = target
# @return [void] @public_xcconfig = public_xcconfig
# end
def save_as(path)
generate.save_as(path)
end
# Generates the xcconfig. # @return [Xcodeproj::Config] The generated xcconfig.
# #
# @return [Xcodeproj::Config] attr_reader :xcconfig
#
def generate
search_pahts = target.build_headers.search_paths.concat(target.sandbox.public_headers.search_paths)
config = {
'OTHER_LDFLAGS' => XCConfigHelper.default_ld_flags(target),
'PODS_ROOT' => '${SRCROOT}',
'HEADER_SEARCH_PATHS' => XCConfigHelper.quote(search_pahts),
'GCC_PREPROCESSOR_DEFINITIONS' => 'COCOAPODS=1',
# 'USE_HEADERMAP' => 'NO'
}
xcconfig_hash = add_xcconfig_namespaced_keys(public_xcconfig.to_hash, config, target.xcconfig_prefix) # Generates and saves the xcconfig to the given path.
@xcconfig = Xcodeproj::Config.new(xcconfig_hash) #
@xcconfig.includes = [target.name] # @param [Pathname] path
@xcconfig # the path where the prefix header should be stored.
end #
# @return [void]
#
def save_as(path)
generate.save_as(path)
end
private # Generates the xcconfig.
#
# @return [Xcodeproj::Config]
#
def generate
search_pahts = target.build_headers_store.search_paths.concat(target.public_headers_store.search_paths)
config = {
'OTHER_LDFLAGS' => XCConfigHelper.default_ld_flags(target),
'PODS_ROOT' => '${SRCROOT}',
'HEADER_SEARCH_PATHS' => XCConfigHelper.quote(search_pahts),
'GCC_PREPROCESSOR_DEFINITIONS' => 'COCOAPODS=1',
# 'USE_HEADERMAP' => 'NO'
}
#-----------------------------------------------------------------------# xcconfig_hash = add_xcconfig_namespaced_keys(public_xcconfig.to_hash, config, XCConfigHelper.prefix(target.name))
@xcconfig = Xcodeproj::Config.new(xcconfig_hash)
@xcconfig.includes = [target.name]
@xcconfig
end
# !@group Private Helpers private
# Returns the hash representation of an xcconfig which inherit from the #-----------------------------------------------------------------------#
# namespaced keys of a given one.
# # !@group Private Helpers
# @param [Hash] source_config
# The xcconfig whose keys need to be inherited. # Returns the hash representation of an xcconfig which inherit from the
# # namespaced keys of a given one.
# @param [Hash] destination_config #
# The config which should inherit the source config keys. # @param [Hash] source_config
# # The xcconfig whose keys need to be inherited.
# @return [Hash] The inheriting xcconfig. #
# # @param [Hash] destination_config
def add_xcconfig_namespaced_keys(source_config, destination_config, prefix) # The config which should inherit the source config keys.
result = destination_config.dup #
source_config.each do |key, value| # @return [Hash] The inheriting xcconfig.
prefixed_key = prefix + conditional_less_key(key) #
current_value = destination_config[key] def add_xcconfig_namespaced_keys(source_config, destination_config, prefix)
if current_value result = destination_config.dup
result[key] = "#{current_value} ${#{prefixed_key}}" source_config.each do |key, value|
else prefixed_key = prefix + conditional_less_key(key)
result[key] = "${#{prefixed_key}}" current_value = destination_config[key]
if current_value
result[key] = "#{current_value} ${#{prefixed_key}}"
else
result[key] = "${#{prefixed_key}}"
end
end end
result
end end
result
end
# Strips the [*]-syntax from the given xcconfig key. # Strips the [*]-syntax from the given xcconfig key.
# #
# @param [String] key # @param [String] key
# The key to strip. # The key to strip.
# #
# @return [String] The stripped key. # @return [String] The stripped key.
# #
def conditional_less_key(key) def conditional_less_key(key)
brackets_index = key.index('[') brackets_index = key.index('[')
if brackets_index if brackets_index
key[0...brackets_index] key[0...brackets_index]
else else
key key
end
end end
end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
end
end end
end end
end end
end
...@@ -14,11 +14,13 @@ module Pod ...@@ -14,11 +14,13 @@ module Pod
# @return [Target] the target represented by this xcconfig. # @return [Target] the target represented by this xcconfig.
# #
attr_reader :target attr_reader :target
attr_reader :sandbox_root
# @param [Target] target @see target # @param [Target] target @see target
# #
def initialize(target) def initialize(target, sanbox_root)
@target = target @target = target
@sandbox_root = sanbox_root
end end
# @return [Xcodeproj::Config] The generated xcconfig. # @return [Xcodeproj::Config] The generated xcconfig.
...@@ -33,7 +35,7 @@ module Pod ...@@ -33,7 +35,7 @@ module Pod
# @return [void] # @return [void]
# #
def save_as(path) def save_as(path)
generate.save_as(path, target.xcconfig_prefix) generate.save_as(path, XCConfigHelper.prefix(target.name))
end end
# Generates the xcconfig for the target. # Generates the xcconfig for the target.
...@@ -45,10 +47,10 @@ module Pod ...@@ -45,10 +47,10 @@ module Pod
target.file_accessors.each do |file_accessor| target.file_accessors.each do |file_accessor|
XCConfigHelper.add_spec_build_settings_to_xcconfig(file_accessor.spec_consumer, @xcconfig) XCConfigHelper.add_spec_build_settings_to_xcconfig(file_accessor.spec_consumer, @xcconfig)
file_accessor.vendored_frameworks.each do |vendored_framework| file_accessor.vendored_frameworks.each do |vendored_framework|
XCConfigHelper.add_framework_build_settings(vendored_framework, @xcconfig, target.sandbox.root) XCConfigHelper.add_framework_build_settings(vendored_framework, @xcconfig, sandbox_root)
end end
file_accessor.vendored_libraries.each do |vendored_library| file_accessor.vendored_libraries.each do |vendored_library|
XCConfigHelper.add_library_build_settings(vendored_library, @xcconfig, target.sandbox.root) XCConfigHelper.add_library_build_settings(vendored_library, @xcconfig, sandbox_root)
end end
end end
@xcconfig @xcconfig
......
...@@ -6,6 +6,18 @@ module Pod ...@@ -6,6 +6,18 @@ module Pod
# #
module XCConfigHelper module XCConfigHelper
# Returns the XCConfig namespaced prefix to use for the target with the
# given name.
#
# @param [Array<String>] target_name
# the name of the target.
#
# @return [String] the prefix for the target.
#
def self.prefix(target_name)
target_name.upcase.gsub(/[^A-Z]/, '_') + '_'
end
# 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.
...@@ -19,13 +31,16 @@ module Pod ...@@ -19,13 +31,16 @@ module Pod
strings.sort.map { |s| %W|"#{s}"| }.join(" ") strings.sort.map { |s| %W|"#{s}"| }.join(" ")
end end
# Configures the project to load all members that implement Objective-c
# classes or categories from the static library#
#
# @return [String] the default linker flags. `-ObjC` is always included # @return [String] the default linker flags. `-ObjC` is always included
# while `-fobjc-arc` is included only if requested in the # while `-fobjc-arc` is included only if requested in the
# Podfile. # Podfile.
# #
def self.default_ld_flags(target) def self.default_ld_flags(target)
ld_flags = '-ObjC' ld_flags = '-ObjC'
if target.target_definition.podfile.set_arc_compatibility_flag? and if target.set_arc_compatibility_flag? and
target.spec_consumers.any? { |consumer| consumer.requires_arc? } target.spec_consumers.any? { |consumer| consumer.requires_arc? }
ld_flags << ' -fobjc-arc' ld_flags << ' -fobjc-arc'
end end
......
...@@ -70,7 +70,7 @@ module Pod ...@@ -70,7 +70,7 @@ module Pod
# #
def pods_by_lib def pods_by_lib
result = {} result = {}
installer.aggregate_targets.map(&:pod_targets).flatten.each do |lib| installer.aggregate_targets.map(&:children).flatten.each do |lib|
pod_names = [lib.root_spec.name] pod_names = [lib.root_spec.name]
pod_reps = pods.select { |rep| pod_names.include?(rep.name) } pod_reps = pods.select { |rep| pod_names.include?(rep.name) }
result[lib.target_definition] = pod_reps result[lib.target_definition] = pod_reps
......
...@@ -83,7 +83,6 @@ module Pod ...@@ -83,7 +83,6 @@ module Pod
def initialize(sandbox, library) def initialize(sandbox, library)
@sandbox = sandbox @sandbox = sandbox
@library = library @library = library
raise "[BUG]" unless library.is_a?(AggregateTarget)
end end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
......
...@@ -191,7 +191,7 @@ module Pod ...@@ -191,7 +191,7 @@ module Pod
def clean_sandbox def clean_sandbox
sandbox.public_headers.implode! sandbox.public_headers.implode!
pod_targets.each do |pod_target| pod_targets.each do |pod_target|
pod_target.build_headers.implode! pod_target.build_headers_store.implode!
end end
unless sandbox.state.deleted.empty? unless sandbox.state.deleted.empty?
...@@ -209,7 +209,7 @@ module Pod ...@@ -209,7 +209,7 @@ module Pod
# #
def create_file_accessors def create_file_accessors
aggregate_targets.each do |target| aggregate_targets.each do |target|
target.pod_targets.each do |pod_target| target.children.each do |pod_target|
pod_root = sandbox.pod_dir(pod_target.root_spec.name) pod_root = sandbox.pod_dir(pod_target.root_spec.name)
path_list = Sandbox::PathList.new(pod_root) path_list = Sandbox::PathList.new(pod_root)
file_accessors = pod_target.specs.map do |spec| file_accessors = pod_target.specs.map do |spec|
...@@ -299,11 +299,11 @@ module Pod ...@@ -299,11 +299,11 @@ module Pod
pod_targets.each do |pod_target| pod_targets.each do |pod_target|
pod_target.file_accessors.each do |file_accessor| pod_target.file_accessors.each do |file_accessor|
headers_sandbox = Pathname.new(file_accessor.spec.root.name) headers_sandbox = Pathname.new(file_accessor.spec.root.name)
pod_target.build_headers.add_search_path(headers_sandbox) pod_target.build_headers_store.add_search_path(headers_sandbox)
sandbox.public_headers.add_search_path(headers_sandbox) sandbox.public_headers.add_search_path(headers_sandbox)
header_mappings(headers_sandbox, file_accessor, file_accessor.headers).each do |namespaced_path, files| header_mappings(headers_sandbox, file_accessor, file_accessor.headers).each do |namespaced_path, files|
pod_target.build_headers.add_files(namespaced_path, files) pod_target.build_headers_store.add_files(namespaced_path, files)
end end
header_mappings(headers_sandbox, file_accessor, file_accessor.public_headers).each do |namespaced_path, files| header_mappings(headers_sandbox, file_accessor, file_accessor.public_headers).each do |namespaced_path, files|
...@@ -563,7 +563,7 @@ module Pod ...@@ -563,7 +563,7 @@ module Pod
# #
def libraries_using_spec(spec) def libraries_using_spec(spec)
aggregate_targets.select do |aggregate_target| aggregate_targets.select do |aggregate_target|
aggregate_target.pod_targets.any? { |pod_target| pod_target.specs.include?(spec) } aggregate_target.children.any? { |pod_target| pod_target.specs.include?(spec) }
end end
end end
...@@ -571,7 +571,7 @@ module Pod ...@@ -571,7 +571,7 @@ module Pod
# process. # process.
# #
def pod_targets def pod_targets
aggregate_targets.map(&:pod_targets).flatten aggregate_targets.map(&:children).flatten
end end
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
......
...@@ -164,30 +164,47 @@ module Pod ...@@ -164,30 +164,47 @@ module Pod
def generate_targets def generate_targets
targets = [] targets = []
result.specs_by_target.each do |target_definition, specs| result.specs_by_target.each do |target_definition, specs|
target = AggregateTarget.new(target_definition, sandbox) # TODO: install named targets even if empty
targets << target # TODO: add spec for aggregate targets to install
unless target_definition.empty?
if config.integrate_targets? target = Target.new(target_definition.label)
project_path = compute_user_project_path(target_definition) targets << target
user_project = Xcodeproj::Project.open(project_path)
native_targets = compute_user_project_targets(target_definition, user_project) target.target_definition = target_definition
target.platform = target_definition.platform
target.user_project_path = project_path target.support_files_root = sandbox.library_support_files_dir(target.name)
target.user_target_uuids = native_targets.map(&:uuid) target.set_arc_compatibility_flag = podfile.set_arc_compatibility_flag?
target.user_build_configurations = compute_user_build_configurations(target_definition, native_targets) target.generate_bridge_support = podfile.generate_bridge_support?
else target.public_headers_store = sandbox.public_headers
target.user_target_uuids = [] target.build_headers_store = Sandbox::HeadersStore.new(sandbox, "BuildHeaders")
target.user_build_configurations = {}
end if config.integrate_targets?
project_path = compute_user_project_path(target_definition)
grouped_specs = specs.map do |spec| user_project = Xcodeproj::Project.open(project_path)
specs.select { |s| s.root == spec.root } native_targets = compute_user_project_targets(target_definition, user_project)
end.uniq
target.user_project_path = project_path
target.user_target_uuids = native_targets.map(&:uuid)
target.user_build_configurations = compute_user_build_configurations(target_definition, native_targets)
else
target.user_target_uuids = []
target.user_build_configurations = {}
end
grouped_specs.each do |pod_specs| grouped_specs = specs.map do |spec|
pod_target = PodTarget.new(pod_specs, target_definition, sandbox) specs.select { |s| s.root == spec.root }
pod_target.user_build_configurations = target.user_build_configurations end.uniq
target.pod_targets << pod_target
grouped_specs.each do |pod_specs|
pod_target = Target.new(pod_specs.first.root.name, target)
pod_target.specs = [pod_specs]
pod_target.support_files_root = sandbox.library_support_files_dir(target.name)
pod_target.user_build_configurations = target.user_build_configurations
pod_target.set_arc_compatibility_flag = podfile.set_arc_compatibility_flag?
pod_target.generate_bridge_support = podfile.generate_bridge_support?
pod_target.build_headers_store = Sandbox::HeadersStore.new(sandbox, "BuildHeaders")
pod_target.public_headers_store = sandbox.public_headers
end
end end
end end
targets targets
......
...@@ -199,10 +199,9 @@ module Pod ...@@ -199,10 +199,9 @@ module Pod
# #
def sync_support_files def sync_support_files
targets = all_pod_targets + aggregate_targets targets = all_pod_targets + aggregate_targets
targets.reject!(&:skip_installation?)
targets.each do |target| targets.each do |target|
UI.message"- Generating support files for target `#{target}`" do UI.message"- Generating support files for target `#{target}`" do
gen = SupportFilesGenerator.new(target, sandbox.project) gen = SupportFilesGenerator.new(target, sandbox)
gen.generate! gen.generate!
end end
end end
...@@ -217,7 +216,7 @@ module Pod ...@@ -217,7 +216,7 @@ module Pod
UI.message"- Populating aggregate targets" do UI.message"- Populating aggregate targets" do
aggregate_targets.each do |aggregate_target| aggregate_targets.each do |aggregate_target|
native_target = aggregate_target.native_target native_target = aggregate_target.native_target
aggregate_target.pod_targets.each do |pod_target| aggregate_target.children.each do |pod_target|
product = pod_target.native_target.product_reference product = pod_target.native_target.product_reference
unless native_target.frameworks_build_phase.files_references.include?(product) unless native_target.frameworks_build_phase.files_references.include?(product)
native_target.frameworks_build_phase.add_file_reference(product) native_target.frameworks_build_phase.add_file_reference(product)
...@@ -234,13 +233,13 @@ module Pod ...@@ -234,13 +233,13 @@ module Pod
def add_missing_target_dependencies def add_missing_target_dependencies
UI.message"- Setting-up target dependencies" do UI.message"- Setting-up target dependencies" do
aggregate_targets.each do |aggregate_target| aggregate_targets.each do |aggregate_target|
aggregate_target.pod_targets.each do |dep| aggregate_target.children.each do |dep|
aggregate_target.native_target.add_dependency(dep.target) aggregate_target.native_target.add_dependency(dep.target)
end end
aggregate_targets.each do |aggregate_target| aggregate_targets.each do |aggregate_target|
aggregate_target.pod_targets.each do |pod_target| aggregate_target.children.each do |pod_target|
dependencies = pod_target.dependencies.map { |dep_name| aggregate_target.pod_targets.find { |target| target.pod_name == dep_name } } dependencies = pod_target.dependencies.map { |dep_name| aggregate_target.children.find { |target| target.pod_name == dep_name } }
dependencies.each do |dep| dependencies.each do |dep|
pod_target.native_target.add_dependency(dep.target) pod_target.native_target.add_dependency(dep.target)
end end
...@@ -279,10 +278,10 @@ module Pod ...@@ -279,10 +278,10 @@ module Pod
@unrecognized_targets = native_targets_by_name.keys.dup @unrecognized_targets = native_targets_by_name.keys.dup
cp_targets = aggregate_targets + all_pod_targets cp_targets = aggregate_targets + all_pod_targets
cp_targets.each do |pod_target| cp_targets.each do |pod_target|
native_targets = native_targets_by_name[pod_target.label] native_targets = native_targets_by_name[pod_target.name]
if native_targets if native_targets
pod_target.native_target = native_targets.first pod_target.native_target = native_targets.first
@unrecognized_targets.delete(pod_target.label) @unrecognized_targets.delete(pod_target.name)
end end
end end
end end
...@@ -303,7 +302,7 @@ module Pod ...@@ -303,7 +302,7 @@ module Pod
pod_names.include?(group.display_name) pod_names.include?(group.display_name)
end end
aggregate_names = aggregate_targets.map(&:label).uniq.sort aggregate_names = aggregate_targets.map(&:name).uniq.sort
groups_to_remove << project.support_files_group.children.reject do |group| groups_to_remove << project.support_files_group.children.reject do |group|
aggregate_names.include?(group.display_name) aggregate_names.include?(group.display_name)
end end
...@@ -347,7 +346,7 @@ module Pod ...@@ -347,7 +346,7 @@ module Pod
# process. # process.
# #
def all_pod_targets def all_pod_targets
aggregate_targets.map(&:pod_targets).flatten aggregate_targets.map(&:children).flatten
end end
# #
...@@ -366,7 +365,7 @@ module Pod ...@@ -366,7 +365,7 @@ module Pod
# #
def aggregate_targets_to_install def aggregate_targets_to_install
aggregate_targets.sort_by(&:name).select do |target| aggregate_targets.sort_by(&:name).select do |target|
target.native_target.nil? && !target.skip_installation? target.native_target.nil?
end end
end end
......
...@@ -86,7 +86,6 @@ module Pod ...@@ -86,7 +86,6 @@ module Pod
# @!group Private Helpers # @!group Private Helpers
#---------------------------------------------------------------------# #---------------------------------------------------------------------#
# @return [Array<Sandbox::FileAccessor>] The file accessors for all the # @return [Array<Sandbox::FileAccessor>] The file accessors for all the
# specs platform combinations. # specs platform combinations.
# #
......
...@@ -13,17 +13,21 @@ module Pod ...@@ -13,17 +13,21 @@ module Pod
# #
attr_reader :target attr_reader :target
attr_reader :project attr_reader :sandbox
def initialize(target, project) def initialize(target, sandbox)
@target = target @target = target
@project = project @sandbox = sandbox
end
def project
sandbox.project
end end
def generate! def generate!
validate validate
# TODO clean up # TODO clean up
if target.is_a?(AggregateTarget) if target.aggregate?
create_xcconfig_file_aggregate create_xcconfig_file_aggregate
create_target_environment_header create_target_environment_header
create_bridge_support_file create_bridge_support_file
...@@ -54,7 +58,7 @@ module Pod ...@@ -54,7 +58,7 @@ module Pod
# #
def create_xcconfig_file_aggregate def create_xcconfig_file_aggregate
path = file_path(:public_xcconfig) path = file_path(:public_xcconfig)
gen = Generator::XCConfig::AggregateXCConfig.new(target) gen = Generator::XCConfig::AggregateXCConfig.new(target, sandbox.root)
gen.save_as(path) gen.save_as(path)
target.xcconfig = gen.xcconfig target.xcconfig = gen.xcconfig
xcconfig_file_ref = add_file_to_support_group(path) xcconfig_file_ref = add_file_to_support_group(path)
...@@ -65,13 +69,12 @@ module Pod ...@@ -65,13 +69,12 @@ module Pod
end end
end end
# Generates the contents of the xcconfig file and saves it to disk. # Generates the contents of the xcconfig file and saves it to disk.
# #
# @return [void] # @return [void]
# #
def create_xcconfig_file_pods def create_xcconfig_file_pods
public_gen = Generator::XCConfig::PublicPodXCConfig.new(target) public_gen = Generator::XCConfig::PublicPodXCConfig.new(target, sandbox.root)
path = file_path(:public_xcconfig) path = file_path(:public_xcconfig)
public_gen.save_as(path) public_gen.save_as(path)
add_file_to_support_group(path) add_file_to_support_group(path)
...@@ -87,13 +90,12 @@ module Pod ...@@ -87,13 +90,12 @@ module Pod
end end
end end
# Generates a header which allows to inspect at compile time the
# Generates a header which allows to inspect at compile time the installed # installed pods and the installed specifications of a pod.
# pods and the installed specifications of a pod.
# #
def create_target_environment_header def create_target_environment_header
path = file_path(:environment_header) path = file_path(:environment_header, target.root)
generator = Generator::TargetEnvironmentHeader.new(target.pod_targets.map { |l| l.specs }.flatten) generator = Generator::TargetEnvironmentHeader.new(target.children.map { |l| l.specs }.flatten)
generator.save_as(path) generator.save_as(path)
add_file_to_support_group(path) add_file_to_support_group(path)
end end
...@@ -107,7 +109,7 @@ module Pod ...@@ -107,7 +109,7 @@ module Pod
# @return [void] # @return [void]
# #
def create_bridge_support_file def create_bridge_support_file
if target.target_definition.podfile.generate_bridge_support? if target.generate_bridge_support?
path = file_path(:bridge_support) path = file_path(:bridge_support)
headers = target.target.headers_build_phase.files.map { |bf| bf.file_ref.real_path } headers = target.target.headers_build_phase.files.map { |bf| bf.file_ref.real_path }
generator = Generator::BridgeSupport.new(headers) generator = Generator::BridgeSupport.new(headers)
...@@ -125,24 +127,25 @@ module Pod ...@@ -125,24 +127,25 @@ module Pod
Generator::Acknowledgements.generators.each do |generator_class| Generator::Acknowledgements.generators.each do |generator_class|
basepath = file_path(:acknowledgements) basepath = file_path(:acknowledgements)
path = generator_class.path_from_basepath(basepath) path = generator_class.path_from_basepath(basepath)
file_accessors = target.pod_targets.map(&:file_accessors).flatten file_accessors = target.children.map(&:file_accessors).flatten
generator = generator_class.new(file_accessors) generator = generator_class.new(file_accessors)
generator.save_as(path) generator.save_as(path)
add_file_to_support_group(path) add_file_to_support_group(path)
end end
end end
# Creates a script that copies the resources to the bundle of the client # Creates a script that copies the resources to the bundle of the
# target. # client target.
# #
# @note The bridge support file needs to be created before the prefix # @note The bridge support file needs to be created before the prefix
# header, otherwise it will not be added to the resources script. # header, otherwise it will not be added to the resources
# script.
# #
# @return [void] # @return [void]
# #
def create_copy_resources_script def create_copy_resources_script
path = file_path(:copy_resources_script) path = file_path(:copy_resources_script)
file_accessors = target.pod_targets.map(&:file_accessors).flatten file_accessors = target.children.map(&:file_accessors).flatten
resource_paths = file_accessors.map { |accessor| accessor.resources.flatten.map { |res| res.relative_path_from(path.dirname) }}.flatten resource_paths = file_accessors.map { |accessor| accessor.resources.flatten.map { |res| res.relative_path_from(path.dirname) }}.flatten
resource_bundles = file_accessors.map { |accessor| accessor.resource_bundles.keys.map {|name| "${BUILT_PRODUCTS_DIR}/#{name}.bundle" } }.flatten resource_bundles = file_accessors.map { |accessor| accessor.resource_bundles.keys.map {|name| "${BUILT_PRODUCTS_DIR}/#{name}.bundle" } }.flatten
resources = [] resources = []
...@@ -164,7 +167,7 @@ module Pod ...@@ -164,7 +167,7 @@ module Pod
def create_prefix_header def create_prefix_header
path = file_path(:prefix_header) path = file_path(:prefix_header)
generator = Generator::PrefixHeader.new(target.file_accessors, target.platform) generator = Generator::PrefixHeader.new(target.file_accessors, target.platform)
generator.imports << file_path(:environment_header).basename generator.imports << file_path(:environment_header, target.root).basename
generator.save_as(path) generator.save_as(path)
add_file_to_support_group(path) add_file_to_support_group(path)
target.prefix_header_path = path target.prefix_header_path = path
...@@ -183,7 +186,7 @@ module Pod ...@@ -183,7 +186,7 @@ module Pod
# #
def create_dummy_source def create_dummy_source
path = file_path(:dummy_source) path = file_path(:dummy_source)
generator = Generator::DummySource.new(target.label) generator = Generator::DummySource.new(target.name)
generator.save_as(path) generator.save_as(path)
file_reference = add_file_to_support_group(path) file_reference = add_file_to_support_group(path)
existing = target.target.source_build_phase.files_references.include?(file_reference) existing = target.target.source_build_phase.files_references.include?(file_reference)
...@@ -214,10 +217,11 @@ module Pod ...@@ -214,10 +217,11 @@ module Pod
# @return [Pathname] The absolute path of the support file with the # @return [Pathname] The absolute path of the support file with the
# given extension. # given extension.
# #
def file_path(key) def file_path(key, target_for_path = nil)
target_for_path ||= target
file_name = SUPPORT_FILES_NAMES[key] file_name = SUPPORT_FILES_NAMES[key]
raise "Unrecognized key `#{key}`" unless file_name raise "Unrecognized key `#{key}`" unless file_name
target.support_files_root + "#{target.label}-#{file_name}" target_for_path.support_files_root + "#{target_for_path.name}-#{file_name}"
end end
...@@ -231,11 +235,11 @@ module Pod ...@@ -231,11 +235,11 @@ module Pod
# #
def support_files_group def support_files_group
unless @support_files_group unless @support_files_group
if target.is_a?(AggregateTarget) if target.aggregate?
aggregate_name = target.label aggregate_name = target.name
@support_files_group = project.add_aggregate_group(aggregate_name, project.path.dirname) @support_files_group = project.add_aggregate_group(aggregate_name, project.path.dirname)
else else
aggregate_name = target.target_definition.label.to_s aggregate_name = target.root.name
pod_name = target.pod_name pod_name = target.pod_name
unless project.aggregate_group(aggregate_name) unless project.aggregate_group(aggregate_name)
# TODO # TODO
......
...@@ -36,7 +36,7 @@ module Pod ...@@ -36,7 +36,7 @@ module Pod
# #
def install! def install!
add_target add_target
unless target.is_a?(AggregateTarget) unless target.aggregate?
add_files_to_build_phases add_files_to_build_phases
add_resources_bundle_targets add_resources_bundle_targets
link_to_system_frameworks link_to_system_frameworks
...@@ -57,7 +57,7 @@ module Pod ...@@ -57,7 +57,7 @@ module Pod
# @return [void] # @return [void]
# #
def add_target def add_target
name = target.label name = target.name
platform = target.platform.name platform = target.platform.name
deployment_target = target.platform.deployment_target.to_s deployment_target = target.platform.deployment_target.to_s
@native_target = project.new_target(:static_library, name, platform, deployment_target) @native_target = project.new_target(:static_library, name, platform, deployment_target)
......
...@@ -110,8 +110,10 @@ module Pod ...@@ -110,8 +110,10 @@ module Pod
# @return [void] # @return [void]
# #
def integrate_user_targets def integrate_user_targets
targets_to_integrate.sort_by(&:name).each do |target| targets.sort_by(&:name).each do |target|
TargetIntegrator.new(target).integrate! unless target.user_target_uuids.empty?
TargetIntegrator.new(target).integrate!
end
end end
end end
...@@ -168,11 +170,6 @@ module Pod ...@@ -168,11 +170,6 @@ module Pod
end.compact.uniq end.compact.uniq
end end
def targets_to_integrate
targets.reject { |target| target.target_definition.empty? }
end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
end end
......
...@@ -40,7 +40,7 @@ module Pod ...@@ -40,7 +40,7 @@ module Pod
# @return [String] a string representation suitable for debugging. # @return [String] a string representation suitable for debugging.
# #
def inspect def inspect
"#<#{self.class} for target `#{target.label}'>" "#<#{self.class} for target `#{target.name}'>"
end end
...@@ -63,7 +63,7 @@ module Pod ...@@ -63,7 +63,7 @@ module Pod
# @return [Specification::Consumer] the consumer for the specifications. # @return [Specification::Consumer] the consumer for the specifications.
# #
def spec_consumers def spec_consumers
@spec_consumers ||= target.pod_targets.map(&:file_accessors).flatten.map(&:spec_consumer) @spec_consumers ||= target.children.map(&:file_accessors).flatten.map(&:spec_consumer)
end end
# Adds the `xcconfig` configurations files generated for the current # Adds the `xcconfig` configurations files generated for the current
...@@ -241,8 +241,8 @@ module Pod ...@@ -241,8 +241,8 @@ module Pod
# integration. # integration.
# #
def integration_message def integration_message
"Integrating Pod #{'target'.pluralize(target.pod_targets.size)} " \ "Integrating Pod #{'target'.pluralize(target.children.size)} " \
"`#{target.pod_targets.map(&:name).to_sentence}` " \ "`#{target.children.map(&:name).to_sentence}` " \
"into aggregate target #{target.name} " \ "into aggregate target #{target.name} " \
"of project #{UI.path target.user_project_path}." "of project #{UI.path target.user_project_path}."
end end
......
...@@ -8,35 +8,59 @@ module Pod ...@@ -8,35 +8,59 @@ module Pod
# #
class Target class Target
# @return [PBXNativeTarget] the target definition of the Podfile that attr_accessor :short_name
# generated this target.
# attr_accessor :parent
attr_reader :target_definition
def initialize(short_name, parent = nil)
@short_name = short_name
@parent = parent
@children = []
@pod_targets = []
@specs = []
@file_accessors = []
@user_target_uuids = []
@user_build_configurations = {}
if parent
parent.children << self
end
end
# @return [Sandbox] The sandbox where the Pods should be installed. # @return [Array]
# #
attr_reader :sandbox attr_accessor :children
# @return [String] the name of the library. # @return [Target]
# #
def name def root
label if parent
parent
else
self
end
end end
# @return [String] the name of the library. # @return [Bool]
# #
def product_name def root?
"lib#{label}.a" parent.nil?
end end
# @return [String] the XCConfig namespaced prefix. # @return [String] the name of the library.
# #
def xcconfig_prefix def name
label.upcase.gsub(/[^A-Z]/, '_') + '_' if root?
short_name
else
"#{parent.name}-#{short_name}"
end
end end
def skip_installation? # @return [String] the name of the library.
false #
def product_name
"lib#{name}.a"
end end
# @return [String] A string suitable for debugging. # @return [String] A string suitable for debugging.
...@@ -45,69 +69,182 @@ module Pod ...@@ -45,69 +69,182 @@ module Pod
"<#{self.class} name=#{name}>" "<#{self.class} name=#{name}>"
end end
# @return [String]
#
def to_s def to_s
"#{name} #{platform}" s = "#{name}"
s << " #{platform}" if platform
s
end end
#-------------------------------------------------------------------------#
# @!group Information storage public
# @return [Hash{String=>Symbol}] A hash representing the user build # @!group Support files
# configurations where each key corresponds to the name of a #-------------------------------------------------------------------------#
# configuration and its value to its type (`:debug` or `:release`).
#
attr_accessor :user_build_configurations
# @return [PBXNativeTarget] the target generated in the Pods project for # @return [PBXNativeTarget] The Xcode native target generated in the Pods
# this library. # project.
# #
attr_accessor :target attr_accessor :target
alias :native_target :target alias :native_target :target
alias :native_target= :target= alias :native_target= :target=
# @return [Platform] the platform for this library. # @return [Pathname] The directory where the support files are stored.
# #
def platform attr_accessor :support_files_root
@platform ||= target_definition.platform
end
# @return [HeadersStore] the build header store.
#
attr_accessor :build_headers_store
# @return [Xcodeproj::Config] The configuration file of the target. # @return [HeadersStore] the public header store.
# #
# @note The configuration is generated by the {TargetInstaller} and attr_accessor :public_headers_store
# used by {UserProjectIntegrator} to check for any overridden
# values. # @return [Xcodeproj::Config] The public configuration.
# #
attr_accessor :xcconfig attr_accessor :xcconfig
# @return [Pathname] The path of the xcconfig file relative to the root of # @return [Pathname] The path of the public configuration.
# the user project.
# #
attr_accessor :xcconfig_path attr_accessor :xcconfig_path
# @return [Pathname] The path of the copy resources script relative to the # @return [Pathname] The path of the copy resources script
# root of the user project.
# #
attr_accessor :copy_resources_script_path attr_accessor :copy_resources_script_path
# @return [Pathname] The path of the prefix header file.
# @return [Pathname]
# #
attr_accessor :prefix_header_path attr_accessor :prefix_header_path
public
# @!group Specs
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
# @!group Support files attr_accessor :specs
# @return [Specification] the spec for the target.
#
def specs
(@specs + children.map(&:specs)).flatten
end
# @return [Array<Specification::Consumer>] The consumers of the Pod.
#
def spec_consumers
specs.map { |spec| spec.consumer(platform) }
end
# @return [Specification] The root specification for the target.
#
def root_spec
specs.first.root
end
# @return [String] The name of the Pod that this target refers to.
#
def pod_name
root_spec.name
end
# @return [Array<Sandbox::FileAccessor>] the file accessors for the
# specifications of this target.
#
attr_accessor :file_accessors
# @return [Array<String>] The names of the Pods on which this target
# depends.
#
def dependencies
specs.map do |spec|
spec.consumer(platform).dependencies.map { |dep| Specification.root_name(dep.name) }
end.flatten.reject { |dep| dep == pod_name }
end
attr_accessor :inhibits_warnings
alias :inhibits_warnings? :inhibits_warnings
# @inhibits_warnings ||= target_definition.inhibits_warnings_for_pod?(pod_name)
def frameworks
spec_consumers.map(&:frameworks).flatten.uniq
end
def libraries
spec_consumers.map(&:libraries).flatten.uniq
end
public
# @!group Aggregate
#-------------------------------------------------------------------------#
#
#
def aggregate?
root?
end
#----------------------------------------#
# @return [Platform] the platform for this library.
#
def platform
if root?
@paltform
else
root.platform
end
end
# @return [Pathname] the folder where to store the support files of this
# library.
# #
def support_files_root #
@sandbox.library_support_files_dir(name) def platform=(platform)
if root?
@paltform = platform
else
raise "The platform must be set in the root target"
end
end end
#----------------------------------------#
# @return [Pathname] the path of the user project that this target will
# integrate as identified by the analyzer.
#
# @note The project instance is not stored to prevent editing different
# instances.
#
attr_accessor :user_project_path
# @return [String] the list of the UUIDs of the user targets that will be
# integrated by this target as identified by the analyzer.
#
# @note The target instances are not stored to prevent editing different
# instances.
#
attr_accessor :user_target_uuids
# @return [Hash{String=>Symbol}] A hash representing the user build
# configurations where each key corresponds to the name of a
# configuration and its value to its type (`:debug` or `:release`).
#
attr_accessor :user_build_configurations
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
attr_accessor :target_definition
attr_accessor :set_arc_compatibility_flag
alias :set_arc_compatibility_flag? :set_arc_compatibility_flag
attr_accessor :generate_bridge_support
alias :generate_bridge_support? :generate_bridge_support
end end
end end
module Pod
# Stores the information relative to the target used to cluster the targets
# of the single Pods. The client targets will then depend on this one.
#
class AggregateTarget < Target
# @param [TargetDefinition] target_definition @see target_definition
# @param [Sandbox] sandbox @see sandbox
#
def initialize(target_definition, sandbox)
@target_definition = target_definition
@sandbox = sandbox
@pod_targets = []
@file_accessors = []
@user_build_configurations = {}
end
def skip_installation?
target_definition.empty?
end
# @return [String] the label for the target.
#
def label
target_definition.label.to_s
end
#-------------------------------------------------------------------------#
# @return [Pathname] the path of the user project that this target will
# integrate as identified by the analyzer.
#
# @note The project instance is not stored to prevent editing different
# instances.
#
attr_accessor :user_project_path
# @return [String] the list of the UUIDs of the user targets that will be
# integrated by this target as identified by the analyzer.
#
# @note The target instances are not stored to prevent editing different
# instances.
#
attr_accessor :user_target_uuids
public
# @!group Pod targets
#-------------------------------------------------------------------------#
# @return [Array<PodTarget>] The dependencies for this target.
#
attr_accessor :pod_targets
# @return [Array<Specification>] The specifications used by this aggregate target.
#
def specs
pod_targets.map(&:specs).flatten
end
# @return [Array<Specification::Consumer>] The consumers of the Pod.
#
def spec_consumers
specs.map { |spec| spec.consumer(platform) }
end
#-------------------------------------------------------------------------#
end
end
module Pod
# Stores the information relative to the target used to compile a single Pod.
# A pod can have one or more activated spec/subspecs.
#
class PodTarget < Target
# @return [Specification] the spec for the target.
#
attr_reader :specs
# @return [HeadersStore] the header directory for the target.
#
attr_reader :build_headers
# @param [Specification] spec @see spec
# @param [TargetDefinition] target_definition @see target_definition
# @param [Sandbox] sandbox @see sandbox
#
def initialize(specs, target_definition, sandbox)
@specs = specs
@target_definition = target_definition
@sandbox = sandbox
@build_headers = Sandbox::HeadersStore.new(sandbox, "BuildHeaders")
@file_accessors = []
@user_build_configurations = {}
end
# @return [String] the label for the target.
#
def label
"#{target_definition.label.to_s}-#{root_spec.name}"
end
# @return [Array<Sandbox::FileAccessor>] the file accessors for the
# specifications of this target.
#
attr_accessor :file_accessors
# @return [Array<Specification::Consumer>] the specification consumers for
# the target.
#
def spec_consumers
specs.map { |spec| spec.consumer(platform) }
end
# @return [Specification] The root specification for the target.
#
def root_spec
specs.first.root
end
# @return [String] The name of the Pod that this target refers to.
#
def pod_name
root_spec.name
end
# @return [Array<String>] The names of the Pods on which this target
# depends.
#
def dependencies
specs.map do |spec|
spec.consumer(platform).dependencies.map { |dep| Specification.root_name(dep.name) }
end.flatten.reject { |dep| dep == pod_name }
end
#-------------------------------------------------------------------------#
def inhibits_warnings?
@inhibits_warnings ||= target_definition.inhibits_warnings_for_pod?(pod_name)
end
def frameworks
spec_consumers.map(&:frameworks).flatten.uniq
end
def libraries
spec_consumers.map(&:libraries).flatten.uniq
end
end
end
...@@ -209,7 +209,7 @@ module Pod ...@@ -209,7 +209,7 @@ module Pod
installer.install! installer.install!
file_accessors = installer.aggregate_targets.map do |target| file_accessors = installer.aggregate_targets.map do |target|
target.pod_targets.map(&:file_accessors) target.children.map(&:file_accessors)
end.flatten end.flatten
@file_accessor = file_accessors.find { |accessor| accessor.spec.root.name == spec.root.name } @file_accessor = file_accessors.find { |accessor| accessor.spec.root.name == spec.root.name }
......
Subproject commit 47c921f09fe5c1f0079922c6e10be0de21513a4a Subproject commit a7ff74e4d9bf72e594a11451e23112752ad8ea57
...@@ -6,83 +6,88 @@ module Pod ...@@ -6,83 +6,88 @@ module Pod
describe AggregateXCConfig do describe AggregateXCConfig do
before do before do
@spec = fixture_spec('banana-lib/BananaLib.podspec') target = Target.new('Pod')
@consumer = @spec.consumer(:ios) target.user_project_path = config.sandbox.root.dirname + 'Project.xcodeproj'
target_definition = Podfile::TargetDefinition.new('Pods', nil) target.stubs(:platform).returns(:ios)
@target = AggregateTarget.new(target_definition, config.sandbox) target.public_headers_store = config.sandbox.public_headers
@target.user_project_path = config.sandbox.root.dirname + 'Project.xcodeproj' target.user_project_path = config.sandbox.root + '../Project.xcodeproj'
@target.stubs(:platform).returns(:ios) target.support_files_root = config.sandbox.root
@pod_target = PodTarget.new([@spec], target_definition, config.sandbox) @sut = AggregateXCConfig.new(target, config.sandbox.root)
@pod_target.stubs(:platform).returns(:ios)
@pod_target.stubs(:spec_consumers).returns([@consumer])
@target.pod_targets = [@pod_target]
@generator = AggregateXCConfig.new(@target)
end end
#---------------------------------------------------------------------#
describe "#generate" do
it "generates the xcconfig" do
xcconfig = @sut.generate
xcconfig.class.should == Xcodeproj::Config
end
it "configures the project to load all members that implement Objective-c classes or categories from the static library" do
xcconfig = @sut.generate
xcconfig.to_hash['OTHER_LDFLAGS'].should.include '-ObjC'
end
it 'does not add the -fobjc-arc to OTHER_LDFLAGS by default as Xcode 4.3.2 does not support it' do
xcconfig = @sut.generate
xcconfig.to_hash['OTHER_LDFLAGS'].should.not.include("-fobjc-arc")
end
it 'adds the -fobjc-arc to OTHER_LDFLAGS if any pods require arc and the podfile explicitly requires it' do
@sut.target.set_arc_compatibility_flag = true
@sut.target.stubs(:spec_consumers).returns([stub( :requires_arc? => true )])
xcconfig = @sut.generate
xcconfig.to_hash['OTHER_LDFLAGS'].split(" ").should.include("-fobjc-arc")
end
it "sets the PODS_ROOT build variable" do
xcconfig = @sut.generate
xcconfig.to_hash['PODS_ROOT'].should == '${SRCROOT}/Pods'
end
it 'adds the sandbox public headers search paths to the xcconfig, with quotes' do
xcconfig = @sut.generate
expected = "\"#{config.sandbox.public_headers.search_paths.join('" "')}\""
xcconfig.to_hash['HEADER_SEARCH_PATHS'].should == expected
end
it 'adds the COCOAPODS macro definition' do
xcconfig = @sut.generate
xcconfig.to_hash['GCC_PREPROCESSOR_DEFINITIONS'].should.include 'COCOAPODS=1'
end
it 'inherits the parent GCC_PREPROCESSOR_DEFINITIONS value' do
xcconfig = @sut.generate
xcconfig.to_hash['GCC_PREPROCESSOR_DEFINITIONS'].should.include '$(inherited)'
end
#-----------------------------------------------------------------------#
before do
@podfile = Podfile.new
@target.target_definition.stubs(:podfile).returns(@podfile)
@xcconfig = @generator.generate
end end
it "generates the xcconfig" do #---------------------------------------------------------------------#
@xcconfig.class.should == Xcodeproj::Config
end
it "configures the project to load all members that implement Objective-c classes or categories from the static library" do describe "#save_as" do
@xcconfig.to_hash['OTHER_LDFLAGS'].should.include '-ObjC'
end
it 'does not add the -fobjc-arc to OTHER_LDFLAGS by default as Xcode 4.3.2 does not support it' do it "saves the xcconfig" do
@consumer.stubs(:requires_arc?).returns(true) path = temporary_directory + 'sample.xcconfig'
@xcconfig.to_hash['OTHER_LDFLAGS'].should.not.include("-fobjc-arc") @sut.generate
end @sut.save_as(path)
Xcodeproj::Config.new(path).to_hash['OTHER_LDFLAGS'].should == "-ObjC"
end
it 'adds the -fobjc-arc to OTHER_LDFLAGS if any pods require arc and the podfile explicitly requires it' do
@podfile.stubs(:set_arc_compatibility_flag?).returns(true)
@consumer.stubs(:requires_arc?).returns(true)
@xcconfig = @generator.generate
@xcconfig.to_hash['OTHER_LDFLAGS'].split(" ").should.include("-fobjc-arc")
end end
it "sets the PODS_ROOT build variable" do #---------------------------------------------------------------------#
@xcconfig.to_hash['PODS_ROOT'].should == '${SRCROOT}/Pods'
end
it 'adds the sandbox public headers search paths to the xcconfig, with quotes' do describe "Private Helpers" do
expected = "\"#{config.sandbox.public_headers.search_paths.join('" "')}\""
@xcconfig.to_hash['HEADER_SEARCH_PATHS'].should == expected
end
it 'adds the COCOAPODS macro definition' do it "returns the path of the pods root relative to the user project" do
@xcconfig.to_hash['GCC_PREPROCESSOR_DEFINITIONS'].should.include 'COCOAPODS=1' @sut.send(:relative_pods_root).should == '${SRCROOT}/Pods'
end end
it 'inherits the parent GCC_PREPROCESSOR_DEFINITIONS value' do
@xcconfig.to_hash['GCC_PREPROCESSOR_DEFINITIONS'].should.include '$(inherited)'
end end
#-----------------------------------------------------------------------# #---------------------------------------------------------------------#
before do
@path = temporary_directory + 'sample.xcconfig'
@generator.save_as(@path)
end
it "saves the xcconfig" do
generated = Xcodeproj::Config.new(@path)
generated.class.should == Xcodeproj::Config
end
#-----------------------------------------------------------------------#
it "returns the path of the pods root relative to the user project" do
@generator.send(:relative_pods_root).should == '${SRCROOT}/Pods'
end
end end
end end
......
...@@ -5,17 +5,16 @@ module Pod ...@@ -5,17 +5,16 @@ module Pod
module XCConfig module XCConfig
describe PrivatePodXCConfig do describe PrivatePodXCConfig do
describe "in general" do describe "In general" do
before do before do
@spec = fixture_spec('banana-lib/BananaLib.podspec') @spec = fixture_spec('banana-lib/BananaLib.podspec')
@consumer = @spec.consumer(:ios) @consumer = @spec.consumer(:ios)
target_definition = Podfile::TargetDefinition.new('Pods', nil) @pod_target = Target.new('Pods-BananaLib')
@pod_target = PodTarget.new([@spec], target_definition, config.sandbox) @pod_target.platform = Platform.ios
@pod_target.stubs(:platform).returns(:ios) @pod_target.build_headers_store = Sandbox::HeadersStore.new(config.sandbox, "BuildHeaders")
@pod_target.public_headers_store = config.sandbox.public_headers
public_xcconfig = Xcodeproj::Config.new({"OTHER_LDFLAGS"=>"-framework SystemConfiguration"}) public_xcconfig = Xcodeproj::Config.new({"OTHER_LDFLAGS"=>"-framework SystemConfiguration"})
@generator = PrivatePodXCConfig.new(@pod_target, public_xcconfig) @generator = PrivatePodXCConfig.new(@pod_target, public_xcconfig)
@podfile = Podfile.new
@pod_target.target_definition.stubs(:podfile).returns(@podfile)
@xcconfig = @generator.generate @xcconfig = @generator.generate
end end
...@@ -23,28 +22,16 @@ module Pod ...@@ -23,28 +22,16 @@ module Pod
@xcconfig.class.should == Xcodeproj::Config @xcconfig.class.should == Xcodeproj::Config
end end
it "configures the project to load all members that implement Objective-c classes or categories from the static library" do it "sets the default linker flags" do
@xcconfig.to_hash['OTHER_LDFLAGS'].should.include '-ObjC' @xcconfig.to_hash['OTHER_LDFLAGS'].should.include '-ObjC'
end end
it 'does not add the -fobjc-arc to OTHER_LDFLAGS by default as Xcode 4.3.2 does not support it' do
@consumer.stubs(:requires_arc?).returns(true)
@xcconfig.to_hash['OTHER_LDFLAGS'].should.not.include("-fobjc-arc")
end
it 'adds the -fobjc-arc to OTHER_LDFLAGS if any pods require arc and the podfile explicitly requires it' do
@podfile.stubs(:set_arc_compatibility_flag?).returns(true)
@consumer.stubs(:requires_arc?).returns(true)
@xcconfig = @generator.generate
@xcconfig.to_hash['OTHER_LDFLAGS'].split(" ").should.include("-fobjc-arc")
end
it "sets the PODS_ROOT build variable" do it "sets the PODS_ROOT build variable" do
@xcconfig.to_hash['PODS_ROOT'].should.not == nil @xcconfig.to_hash['PODS_ROOT'].should.not == nil
end end
it 'adds the library build headers and public headers search paths to the xcconfig, with quotes' do it 'adds the library build headers and public headers search paths to the xcconfig, with quotes' do
private_headers = "\"#{@pod_target.build_headers.search_paths.join('" "')}\"" private_headers = "\"#{@pod_target.build_headers_store.search_paths.join('" "')}\""
public_headers = "\"#{config.sandbox.public_headers.search_paths.join('" "')}\"" public_headers = "\"#{config.sandbox.public_headers.search_paths.join('" "')}\""
@xcconfig.to_hash['HEADER_SEARCH_PATHS'].should.include private_headers @xcconfig.to_hash['HEADER_SEARCH_PATHS'].should.include private_headers
@xcconfig.to_hash['HEADER_SEARCH_PATHS'].should.include public_headers @xcconfig.to_hash['HEADER_SEARCH_PATHS'].should.include public_headers
...@@ -55,7 +42,7 @@ module Pod ...@@ -55,7 +42,7 @@ module Pod
end end
it 'adds the pod namespaced configuration items' do it 'adds the pod namespaced configuration items' do
@xcconfig.to_hash['OTHER_LDFLAGS'].should.include("${#{@pod_target.xcconfig_prefix}OTHER_LDFLAGS}") @xcconfig.to_hash['OTHER_LDFLAGS'].should.include("${PODS_BANANALIB_OTHER_LDFLAGS}")
end end
it 'sets the relative path of the pods root for spec libraries to ${SRCROOT}' do it 'sets the relative path of the pods root for spec libraries to ${SRCROOT}' do
...@@ -71,7 +58,7 @@ module Pod ...@@ -71,7 +58,7 @@ module Pod
end end
#-------------------------------------------------------------------------# #---------------------------------------------------------------------#
describe "Private Helpers" do describe "Private Helpers" do
...@@ -124,7 +111,7 @@ module Pod ...@@ -124,7 +111,7 @@ module Pod
end end
#-------------------------------------------------------------------------# #---------------------------------------------------------------------#
end end
end end
......
...@@ -7,50 +7,45 @@ module Pod ...@@ -7,50 +7,45 @@ module Pod
before do before do
@spec = fixture_spec('banana-lib/BananaLib.podspec') @spec = fixture_spec('banana-lib/BananaLib.podspec')
@target_definition = Podfile::TargetDefinition.new('Pods', nil) @pod_target = Target.new('Pods-BananaLib')
@pod_target = PodTarget.new([@spec], @target_definition, config.sandbox) @sut = PublicPodXCConfig.new(@pod_target, config.sandbox.root)
@pod_target.stubs(:platform).returns(:ios)
@generator = PublicPodXCConfig.new(@pod_target)
@podfile = Podfile.new
@spec.xcconfig = { 'OTHER_LDFLAGS' => '-no_compact_unwind' }
@spec.frameworks = ['QuartzCore']
@spec.weak_frameworks = ['iAd']
@spec.libraries = ['xml2']
file_accessors = [Sandbox::FileAccessor.new(fixture('banana-lib'), @spec.consumer(:ios))] file_accessors = [Sandbox::FileAccessor.new(fixture('banana-lib'), @spec.consumer(:ios))]
# vendored_framework_paths = [config.sandbox.root + 'BananaLib/BananaLib.framework']
# Sandbox::FileAccessor.any_instance.stubs(:vendored_frameworks).returns(vendored_framework_paths)
@pod_target.target_definition.stubs(:podfile).returns(@podfile)
@pod_target.stubs(:file_accessors).returns(file_accessors) @pod_target.stubs(:file_accessors).returns(file_accessors)
@xcconfig = @generator.generate
end end
it "generates the xcconfig" do it "generates the xcconfig" do
@xcconfig.class.should == Xcodeproj::Config xcconfig = @sut.generate
xcconfig.class.should == Xcodeproj::Config
end end
it "includes the xcconfig of the specifications" do it "includes the xcconfig of the specifications" do
@xcconfig.to_hash["OTHER_LDFLAGS"].should.include('-no_compact_unwind') @spec.xcconfig = { 'OTHER_LDFLAGS' => '-no_compact_unwind' }
xcconfig = @sut.generate
xcconfig.to_hash["OTHER_LDFLAGS"].should.include('-no_compact_unwind')
end end
it "includes the libraries for the specifications" do it "includes the libraries for the specifications" do
@xcconfig.to_hash["OTHER_LDFLAGS"].should.include('-lxml2') @spec.libraries = ['xml2']
xcconfig = @sut.generate
xcconfig.to_hash["OTHER_LDFLAGS"].should.include('-lxml2')
end end
it "includes the frameworks of the specifications" do it "includes the frameworks of the specifications" do
@xcconfig.to_hash["OTHER_LDFLAGS"].should.include('-framework QuartzCore') @spec.frameworks = ['QuartzCore']
xcconfig = @sut.generate
xcconfig.to_hash["OTHER_LDFLAGS"].should.include('-framework QuartzCore')
end end
it "includes the weak-frameworks of the specifications" do it "includes the weak-frameworks of the specifications" do
@xcconfig.to_hash["OTHER_LDFLAGS"].should.include('-weak_framework iAd') @spec.weak_frameworks = ['iAd']
xcconfig = @sut.generate
xcconfig.to_hash["OTHER_LDFLAGS"].should.include('-weak_framework iAd')
end end
it "includes the developer frameworks search paths when SenTestingKit is detected" do it "includes the developer frameworks search paths when SenTestingKit is detected" do
@spec.xcconfig = { 'OTHER_LDFLAGS' => '-no_compact_unwind' } @spec.xcconfig = { 'OTHER_LDFLAGS' => '-no_compact_unwind' }
@spec.frameworks = ['SenTestingKit'] @spec.frameworks = ['SenTestingKit']
xcconfig = @generator.generate xcconfig = @sut.generate
framework_search_paths = xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS'] framework_search_paths = xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS']
framework_search_paths.should.include('$(SDKROOT)/Developer') framework_search_paths.should.include('$(SDKROOT)/Developer')
end end
...@@ -58,29 +53,30 @@ module Pod ...@@ -58,29 +53,30 @@ module Pod
it "doesn't include the developer frameworks if already present" do it "doesn't include the developer frameworks if already present" do
@spec.xcconfig = { 'FRAMEWORK_SEARCH_PATHS' => '"$(SDKROOT)/Developer/Library/Frameworks" "$(DEVELOPER_LIBRARY_DIR)/Frameworks"' } @spec.xcconfig = { 'FRAMEWORK_SEARCH_PATHS' => '"$(SDKROOT)/Developer/Library/Frameworks" "$(DEVELOPER_LIBRARY_DIR)/Frameworks"' }
@spec.frameworks = ['SenTestingKit'] @spec.frameworks = ['SenTestingKit']
xcconfig = @generator.generate xcconfig = @sut.generate
framework_search_paths = xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS'].split(' ') framework_search_paths = xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS'].split(' ')
framework_search_paths.select { |path| path == '"$(SDKROOT)/Developer/Library/Frameworks"'}.count.should == 1 framework_search_paths.select { |path| path == '"$(SDKROOT)/Developer/Library/Frameworks"'}.count.should == 1
framework_search_paths.select { |path| path == '"$(DEVELOPER_LIBRARY_DIR)/Frameworks"'}.count.should == 1 framework_search_paths.select { |path| path == '"$(DEVELOPER_LIBRARY_DIR)/Frameworks"'}.count.should == 1
end end
it "includes the build settings of the frameworks bundles of the spec" do it "includes the build settings of the frameworks bundles of the spec" do
config.sandbox.stubs(:root).returns(fixture('')) @sut.stubs(:sandbox_root).returns(fixture(''))
xcconfig = @generator.generate xcconfig = @sut.generate
xcconfig.to_hash["FRAMEWORK_SEARCH_PATHS"].should.include?('"$(PODS_ROOT)/banana-lib"') xcconfig.to_hash["FRAMEWORK_SEARCH_PATHS"].should.include?('"$(PODS_ROOT)/banana-lib"')
end end
it "includes the build settings of the libraries shipped with the spec" do it "includes the build settings of the libraries shipped with the spec" do
config.sandbox.stubs(:root).returns(fixture('')) @sut.stubs(:sandbox_root).returns(fixture(''))
xcconfig = @generator.generate xcconfig = @sut.generate
xcconfig.to_hash["LIBRARY_SEARCH_PATHS"].should.include?('"$(PODS_ROOT)/banana-lib"') xcconfig.to_hash["LIBRARY_SEARCH_PATHS"].should.include?('"$(PODS_ROOT)/banana-lib"')
end end
#-----------------------------------------------------------------------# #---------------------------------------------------------------------#
before do before do
xcconfig = @sut.generate
@path = temporary_directory + 'sample.xcconfig' @path = temporary_directory + 'sample.xcconfig'
@generator.save_as(@path) @sut.save_as(@path)
end end
it "saves the xcconfig" do it "saves the xcconfig" do
...@@ -90,9 +86,11 @@ module Pod ...@@ -90,9 +86,11 @@ module Pod
it "writes the xcconfig with a prefix computed from the target definition and root spec" do it "writes the xcconfig with a prefix computed from the target definition and root spec" do
generated = Xcodeproj::Config.new(@path) generated = Xcodeproj::Config.new(@path)
generated.to_hash.each { |k, v| k.should.start_with(@pod_target.xcconfig_prefix) } generated.to_hash.each { |k, v| k.should.start_with('PODS_BANANALIB_') }
end end
#---------------------------------------------------------------------#
end end
end end
end end
......
...@@ -11,22 +11,14 @@ module Pod ...@@ -11,22 +11,14 @@ module Pod
#---------------------------------------------------------------------# #---------------------------------------------------------------------#
describe "::default_ld_flags" do describe "::prefix" do
it "returns the default linker flags" do it "returns the prefix to use for the target with the given name" do
podfile = stub( :set_arc_compatibility_flag? => false ) @sut.prefix('Pods').should == 'PODS_'
target_definition = stub( :podfile => podfile ) @sut.prefix('Pods-BananaLib').should == 'PODS_BANANALIB_'
target = stub( :target_definition => target_definition )
result = @sut.default_ld_flags(target)
result.should == '-ObjC'
end end
it "includes the ARC compatibility flag if required by the Podfile" do it "replaces any non character which is not in the alphabet with an underscore" do
podfile = stub( :set_arc_compatibility_flag? => true ) @sut.prefix('Pods-BananaLib+Categories').should == 'PODS_BANANALIB_CATEGORIES_'
target_definition = stub( :podfile => podfile )
spec_consumer = stub( :requires_arc? => true )
target = stub( :target_definition => target_definition, :spec_consumers => [spec_consumer] )
result = @sut.default_ld_flags(target)
result.should == '-ObjC -fobjc-arc'
end end
end end
...@@ -41,6 +33,25 @@ module Pod ...@@ -41,6 +33,25 @@ module Pod
#---------------------------------------------------------------------# #---------------------------------------------------------------------#
describe "::default_ld_flags" do
it "returns the default linker flags" do
target = Target.new('BananaLib')
target.set_arc_compatibility_flag = false
result = @sut.default_ld_flags(target)
result.should == '-ObjC'
end
it "includes the ARC compatibility flag if required by the Podfile" do
target = Target.new('BananaLib')
target.set_arc_compatibility_flag = true
target.stubs(:spec_consumers).returns([stub( :requires_arc? => true )])
result = @sut.default_ld_flags(target)
result.should == '-ObjC -fobjc-arc'
end
end
#---------------------------------------------------------------------#
describe "::add_spec_build_settings_to_xcconfig" do describe "::add_spec_build_settings_to_xcconfig" do
it "adds the build settings of the consumer" do it "adds the build settings of the consumer" do
xcconfig = Xcodeproj::Config.new xcconfig = Xcodeproj::Config.new
......
...@@ -16,7 +16,7 @@ module Pod ...@@ -16,7 +16,7 @@ module Pod
config.integrate_targets = false config.integrate_targets = false
@installer = Installer.new(config.sandbox, podfile) @installer = Installer.new(config.sandbox, podfile)
@installer.send(:analyze) @installer.send(:analyze)
@specs = @installer.aggregate_targets.first.pod_targets.first.specs @specs = @installer.aggregate_targets.first.children.first.specs
@installer.stubs(:installed_specs).returns(@specs) @installer.stubs(:installed_specs).returns(@specs)
@rep = Hooks::InstallerRepresentation.new(@installer) @rep = Hooks::InstallerRepresentation.new(@installer)
end end
...@@ -52,7 +52,7 @@ module Pod ...@@ -52,7 +52,7 @@ module Pod
it "returns the pods representation by library representation" do it "returns the pods representation by library representation" do
pods_by_lib = @rep.pods_by_lib pods_by_lib = @rep.pods_by_lib
target_definition = @installer.aggregate_targets.first.pod_targets.first.target_definition target_definition = @installer.aggregate_targets.first.children.first.target_definition
pods_by_lib[target_definition].map(&:name).should == ['JSONKit'] pods_by_lib[target_definition].map(&:name).should == ['JSONKit']
end end
......
...@@ -7,7 +7,8 @@ module Pod ...@@ -7,7 +7,8 @@ module Pod
@target_definition = Podfile::TargetDefinition.new('MyApp', nil) @target_definition = Podfile::TargetDefinition.new('MyApp', nil)
@spec = Spec.new @spec = Spec.new
@spec.name = 'RestKit' @spec.name = 'RestKit'
@lib = AggregateTarget.new(@target_definition, config.sandbox) @lib = Target.new('Pods-MyApp', nil)
@lib.target_definition = @target_definition
@rep = Hooks::LibraryRepresentation.new(config.sandbox, @lib) @rep = Hooks::LibraryRepresentation.new(config.sandbox, @lib)
end end
......
...@@ -76,7 +76,7 @@ module Pod ...@@ -76,7 +76,7 @@ module Pod
it "generates the libraries which represent the target definitions" do it "generates the libraries which represent the target definitions" do
target = @analyzer.analyze.targets.first target = @analyzer.analyze.targets.first
target.pod_targets.map(&:name).sort.should == [ target.children.map(&:name).sort.should == [
'Pods-JSONKit', 'Pods-JSONKit',
'Pods-AFNetworking', 'Pods-AFNetworking',
'Pods-SVPullToRefresh', 'Pods-SVPullToRefresh',
...@@ -171,7 +171,7 @@ module Pod ...@@ -171,7 +171,7 @@ module Pod
end end
it "adds the specifications to the correspondent libraries" do it "adds the specifications to the correspondent libraries" do
@analyzer.analyze.targets.first.pod_targets.map(&:specs).flatten.map(&:to_s).should == [ @analyzer.analyze.targets.first.children.map(&:specs).flatten.map(&:to_s).should == [
"AFNetworking (1.0.1)", "AFNetworking (1.0.1)",
"JSONKit (1.5pre)", "JSONKit (1.5pre)",
"SVPullToRefresh (0.4)", "SVPullToRefresh (0.4)",
......
...@@ -5,7 +5,7 @@ module Pod ...@@ -5,7 +5,7 @@ module Pod
before do before do
@file_accessor = fixture_file_accessor('banana-lib/BananaLib.podspec') @file_accessor = fixture_file_accessor('banana-lib/BananaLib.podspec')
@pod_target = PodTarget.new([], nil, config.sandbox) @pod_target = Target.new('BananaLib')
@pod_target.file_accessors = [@file_accessor] @pod_target.file_accessors = [@file_accessor]
config.sandbox.project = Project.new(config.sandbox.project_path) config.sandbox.project = Project.new(config.sandbox.project_path)
config.sandbox.project.add_pod_group('BananaLib', fixture('banana-lib')) config.sandbox.project.add_pod_group('BananaLib', fixture('banana-lib'))
...@@ -54,9 +54,9 @@ module Pod ...@@ -54,9 +54,9 @@ module Pod
describe "#file_accessors" do describe "#file_accessors" do
it "returns the file accessors" do it "returns the file accessors" do
pod_target_1 = PodTarget.new([], nil, config.sandbox) pod_target_1 = Target.new('BananaLib_1')
pod_target_1.file_accessors = [fixture_file_accessor('banana-lib/BananaLib.podspec')] pod_target_1.file_accessors = [fixture_file_accessor('banana-lib/BananaLib.podspec')]
pod_target_2 = PodTarget.new([], nil, config.sandbox) pod_target_2 = Target.new('BananaLib_1')
pod_target_2.file_accessors = [fixture_file_accessor('banana-lib/BananaLib.podspec')] pod_target_2.file_accessors = [fixture_file_accessor('banana-lib/BananaLib.podspec')]
@sut = Installer::PodsProjectGenerator::FileReferencesInstaller.new(config.sandbox, [pod_target_1, pod_target_2]) @sut = Installer::PodsProjectGenerator::FileReferencesInstaller.new(config.sandbox, [pod_target_1, pod_target_2])
roots = @sut.send(:file_accessors).map { |fa| fa.path_list.root } roots = @sut.send(:file_accessors).map { |fa| fa.path_list.root }
...@@ -64,9 +64,9 @@ module Pod ...@@ -64,9 +64,9 @@ module Pod
end end
it "handles libraries empty libraries without file accessors" do it "handles libraries empty libraries without file accessors" do
pod_target_1 = PodTarget.new([], nil, config.sandbox) pod_target = Target.new('BananaLib_1')
pod_target_1.file_accessors = [] pod_target.file_accessors = []
@sut = Installer::PodsProjectGenerator::FileReferencesInstaller.new(config.sandbox, [pod_target_1]) @sut = Installer::PodsProjectGenerator::FileReferencesInstaller.new(config.sandbox, [pod_target])
roots = @sut.send(:file_accessors).should == [] roots = @sut.send(:file_accessors).should == []
end end
end end
......
...@@ -7,29 +7,28 @@ module Pod ...@@ -7,29 +7,28 @@ module Pod
before do before do
@project = Project.new(config.sandbox.project_path) @project = Project.new(config.sandbox.project_path)
native_target = @project.new_target(:static_target, 'Pods', :ios, '6.0') native_target = @project.new_target(:static_target, 'Pods', :ios, '6.0')
config.sandbox.project = @project
@podfile = Podfile.new do @target = Target.new('Pods')
platform :ios @target.platform = Platform.new(:ios, '6.0')
xcodeproj 'dummy'
end
@target_definition = @podfile.target_definitions['Pods']
@target = AggregateTarget.new(@target_definition, config.sandbox)
@target.stubs(:label).returns('Pods')
@target.stubs(:platform).returns(Platform.new(:ios, '6.0'))
@target.user_project_path = config.sandbox.root + '../user_project.xcodeproj' @target.user_project_path = config.sandbox.root + '../user_project.xcodeproj'
@target.user_build_configurations = { 'Debug' => :debug, 'Release' => :release, 'AppStore' => :release, 'Test' => :debug } @target.user_build_configurations = { 'Debug' => :debug, 'Release' => :release, 'AppStore' => :release, 'Test' => :debug }
@target.support_files_root = config.sandbox.root
@target.target = native_target @target.target = native_target
@target.public_headers_store = config.sandbox.public_headers
@target.build_headers_store = config.sandbox.public_headers
file_accessor = fixture_file_accessor('banana-lib/BananaLib.podspec') file_accessor = fixture_file_accessor('banana-lib/BananaLib.podspec')
@spec = fixture_spec('banana-lib/BananaLib.podspec') @spec = fixture_spec('banana-lib/BananaLib.podspec')
@pod_target = PodTarget.new([@spec], @target_definition, config.sandbox) @pod_target = Target.new('BananaLib', @target)
@pod_target.stubs(:platform).returns(Platform.new(:ios, '6.0')) @pod_target.specs = [@spec]
@pod_target.user_build_configurations = @target.user_build_configurations @pod_target.user_build_configurations = @target.user_build_configurations
@pod_target.file_accessors = [file_accessor] @pod_target.file_accessors = [file_accessor]
@pod_target.support_files_root = config.sandbox.root
@pod_target.public_headers_store = config.sandbox.public_headers
@pod_target.build_headers_store = config.sandbox.public_headers
@target.pod_targets = [@pod_target] @sut = Installer::PodsProjectGenerator::SupportFilesGenerator.new(@target, config.sandbox)
@sut = Installer::PodsProjectGenerator::SupportFilesGenerator.new(@target, @project)
end end
it "adds file references for the support files of the target" do it "adds file references for the support files of the target" do
...@@ -64,7 +63,7 @@ module Pod ...@@ -64,7 +63,7 @@ module Pod
end end
it "creates a bridge support file" do it "creates a bridge support file" do
Podfile.any_instance.stubs(:generate_bridge_support? => true) @target.generate_bridge_support = true
Generator::BridgeSupport.any_instance.expects(:save_as).once Generator::BridgeSupport.any_instance.expects(:save_as).once
@sut.generate! @sut.generate!
end end
...@@ -108,24 +107,29 @@ module Pod ...@@ -108,24 +107,29 @@ module Pod
describe "PodTarget" do describe "PodTarget" do
before do before do
@project = Project.new(config.sandbox.project_path) @project = Project.new(config.sandbox.project_path)
@project.add_pod_group('BananaLib', fixture('banana-lib'))
native_target = @project.new_target(:static_target, 'Pods-BananaLib', :ios, '6.0') native_target = @project.new_target(:static_target, 'Pods-BananaLib', :ios, '6.0')
config.sandbox.project = @project
@podfile = Podfile.new do @target = Target.new('Pods')
platform :ios @target.platform = Platform.new(:ios, '6.0')
xcodeproj 'dummy' @target.user_project_path = config.sandbox.root + '../user_project.xcodeproj'
end @target.user_build_configurations = { 'Debug' => :debug, 'Release' => :release, 'AppStore' => :release, 'Test' => :debug }
@target_definition = @podfile.target_definitions['Pods'] @target.support_files_root = config.sandbox.root
@target.public_headers_store = config.sandbox.public_headers
@target.build_headers_store = config.sandbox.public_headers
file_accessor = fixture_file_accessor('banana-lib/BananaLib.podspec') file_accessor = fixture_file_accessor('banana-lib/BananaLib.podspec')
@spec = fixture_spec('banana-lib/BananaLib.podspec') @spec = fixture_spec('banana-lib/BananaLib.podspec')
@target = PodTarget.new([@spec], @target_definition, config.sandbox) @pod_target = Target.new('BananaLib', @target)
@target.stubs(:platform).returns(Platform.new(:ios, '6.0')) @pod_target.specs = [@spec]
@target.user_build_configurations = @target.user_build_configurations @pod_target.user_build_configurations = @target.user_build_configurations
@target.file_accessors = [file_accessor] @pod_target.file_accessors = [file_accessor]
@target.target = native_target @pod_target.support_files_root = config.sandbox.root
@pod_target.public_headers_store = config.sandbox.public_headers
@pod_target.build_headers_store = config.sandbox.public_headers
@pod_target.target = native_target
@sut = Installer::PodsProjectGenerator::SupportFilesGenerator.new(@target, @project) @sut = Installer::PodsProjectGenerator::SupportFilesGenerator.new(@pod_target, config.sandbox)
end end
it "creates the xcconfig file" do it "creates the xcconfig file" do
......
...@@ -17,9 +17,8 @@ module Pod ...@@ -17,9 +17,8 @@ module Pod
before do before do
@project = Project.new(config.sandbox.project_path) @project = Project.new(config.sandbox.project_path)
target = AggregateTarget.new(nil, config.sandbox) target = Target.new('Pods')
target.stubs(:label).returns('Pods') target.platform = Platform.new(:ios, '6.0')
target.stubs(:platform).returns(Platform.new(:ios, '6.0'))
@sut = Installer::PodsProjectGenerator::TargetInstaller.new(@project, target) @sut = Installer::PodsProjectGenerator::TargetInstaller.new(@project, target)
end end
...@@ -101,11 +100,10 @@ module Pod ...@@ -101,11 +100,10 @@ module Pod
project.add_file_reference(file, group) project.add_file_reference(file, group)
end end
target = PodTarget.new([spec], nil, config.sandbox) target = Target.new('Pods-BananaLib')
target.stubs(:platform).returns(Platform.new(:ios, '6.0')) target.platform = Platform.new(:ios, '6.0')
target.file_accessors = [file_accessor] target.file_accessors = [file_accessor]
target.stubs(:inhibits_warnings?).returns(false) target.inhibits_warnings = false
target.stubs(:label).returns('Pods-BananaLib')
@sut = Installer::PodsProjectGenerator::TargetInstaller.new(project, target) @sut = Installer::PodsProjectGenerator::TargetInstaller.new(project, target)
@sut.send(:add_target) @sut.send(:add_target)
end end
...@@ -144,9 +142,9 @@ module Pod ...@@ -144,9 +142,9 @@ module Pod
describe "#link_to_system_frameworks" do describe "#link_to_system_frameworks" do
before do before do
project = Project.new(config.sandbox.project_path) project = Project.new(config.sandbox.project_path)
target = PodTarget.new([], nil, config.sandbox) target = Target.new('Pods-BananaLib')
target.stubs(:platform).returns(Platform.new(:ios, '6.0')) target.platform = Platform.new(:ios, '6.0')
target.stubs(:label).returns('Pods-BananaLib') target.inhibits_warnings = false
@sut = Installer::PodsProjectGenerator::TargetInstaller.new(project, target) @sut = Installer::PodsProjectGenerator::TargetInstaller.new(project, target)
@sut.send(:add_target) @sut.send(:add_target)
end end
......
...@@ -81,10 +81,11 @@ module Pod ...@@ -81,10 +81,11 @@ module Pod
end end
it "sets the deployment target for the project" do it "sets the deployment target for the project" do
target_ios = AggregateTarget.new(nil, config.sandbox) target_ios = Target.new('Pods-ios')
target_osx = AggregateTarget.new(nil, config.sandbox) target_ios.platform = Platform.ios
target_ios.stubs(:platform).returns(Platform.new(:ios, '6.0')) target_ios.platform = Platform.new(:ios, '6.0')
target_osx.stubs(:platform).returns(Platform.new(:osx, '10.8')) target_osx = Target.new('Pods-osx')
target_osx.platform = Platform.new(:osx, '10.8')
@sut.stubs(:aggregate_targets).returns([target_ios, target_osx]) @sut.stubs(:aggregate_targets).returns([target_ios, target_osx])
@sut.send(:prepare_project) @sut.send(:prepare_project)
build_settings = @sut.project.build_configurations.map(&:build_settings) build_settings = @sut.project.build_configurations.map(&:build_settings)
...@@ -119,8 +120,8 @@ module Pod ...@@ -119,8 +120,8 @@ module Pod
@target_definition = Podfile::TargetDefinition.new(:default, nil) @target_definition = Podfile::TargetDefinition.new(:default, nil)
pod_target = PodTarget.new([], @target_definition, config.sandbox) pod_target = PodTarget.new([], @target_definition, config.sandbox)
pod_target.stubs(:name).returns('BananaLib') pod_target.stubs(:name).returns('BananaLib')
aggregate_target = AggregateTarget.new(@target_definition, config.sandbox) aggregate_target = Target.new('Pods')
aggregate_target.pod_targets = [pod_target] aggregate_target.children = [pod_target]
@sut = PodsProjectGenerator.new(config.sandbox, [aggregate_target]) @sut = PodsProjectGenerator.new(config.sandbox, [aggregate_target])
end end
...@@ -177,11 +178,10 @@ module Pod ...@@ -177,11 +178,10 @@ module Pod
project = Pod::Project.new(config.sandbox.project_path) project = Pod::Project.new(config.sandbox.project_path)
@aggregate_native_target = project.new_target(:static_library, 'Pods', :ios) @aggregate_native_target = project.new_target(:static_library, 'Pods', :ios)
@pod_native_target = project.new_target(:static_library, 'Pods-BananaLib', :ios) @pod_native_target = project.new_target(:static_library, 'Pods-BananaLib', :ios)
pod_target = PodTarget.new([], nil, config.sandbox) aggregate_target = Target.new('Pods')
pod_target.target = @pod_native_target
aggregate_target = AggregateTarget.new(nil, config.sandbox)
aggregate_target.pod_targets = [pod_target]
aggregate_target.target = @aggregate_native_target aggregate_target.target = @aggregate_native_target
pod_target = Target.new('Pods-BananaLib', aggregate_target)
pod_target.target = @pod_native_target
@sut = PodsProjectGenerator.new(config.sandbox, [aggregate_target]) @sut = PodsProjectGenerator.new(config.sandbox, [aggregate_target])
end end
...@@ -200,16 +200,15 @@ module Pod ...@@ -200,16 +200,15 @@ module Pod
project = Pod::Project.new(config.sandbox.project_path) project = Pod::Project.new(config.sandbox.project_path)
aggregate_native_target = project.new_target(:static_library, 'Pods', :ios) aggregate_native_target = project.new_target(:static_library, 'Pods', :ios)
pod_native_target_1 = project.new_target(:static_library, 'Pods-BananaLib', :ios) pod_native_target_1 = project.new_target(:static_library, 'Pods-BananaLib', :ios)
@pod_target_1 = PodTarget.new([], nil, config.sandbox)
@pod_target_1.stubs(:pod_name).returns('BananaLib')
@pod_target_1.target = pod_native_target_1
pod_native_target_2 = project.new_target(:static_library, 'Pods-monkey', :ios) pod_native_target_2 = project.new_target(:static_library, 'Pods-monkey', :ios)
pod_target_2 = PodTarget.new([], nil, config.sandbox)
pod_target_2.stubs(:pod_name).returns('monkey') @aggregate_target = Target.new('Pods')
pod_target_2.target = pod_native_target_2
@aggregate_target = AggregateTarget.new(nil, config.sandbox)
@aggregate_target.pod_targets = [@pod_target_1, pod_target_2]
@aggregate_target.target = aggregate_native_target @aggregate_target.target = aggregate_native_target
@pod_target_1 = Target.new('BananaLib', @aggregate_target)
@pod_target_1.target = pod_native_target_1
@pod_target_2 = Target.new('monkey', @aggregate_target)
@pod_target_2.target = pod_native_target_2
@sut = PodsProjectGenerator.new(config.sandbox, [@aggregate_target]) @sut = PodsProjectGenerator.new(config.sandbox, [@aggregate_target])
end end
...@@ -222,6 +221,8 @@ module Pod ...@@ -222,6 +221,8 @@ module Pod
it "sets the dependencies of the pod targets" do it "sets the dependencies of the pod targets" do
@pod_target_1.stubs(:dependencies).returns(['monkey']) @pod_target_1.stubs(:dependencies).returns(['monkey'])
@pod_target_1.stubs(:pod_name).returns('BananaLib')
@pod_target_2.stubs(:pod_name).returns('monkey')
@sut.send(:add_missing_target_dependencies) @sut.send(:add_missing_target_dependencies)
dependencies = @pod_target_1.target.dependencies dependencies = @pod_target_1.target.dependencies
dependencies.map { |d| d.target.name}.should == ["Pods-monkey"] dependencies.map { |d| d.target.name}.should == ["Pods-monkey"]
......
...@@ -9,11 +9,8 @@ module Pod ...@@ -9,11 +9,8 @@ module Pod
before do before do
project_path = SpecHelper.create_sample_app_copy_from_fixture('SampleProject') project_path = SpecHelper.create_sample_app_copy_from_fixture('SampleProject')
@project = Xcodeproj::Project.open(project_path) @project = Xcodeproj::Project.open(project_path)
Xcodeproj::Project.new(config.sandbox.project_path).save
@native_target = @project.targets.first @native_target = @project.targets.first
target_definition = Podfile::TargetDefinition.new('Pods', nil) @target = Target.new('Pods')
target_definition.link_with_first_target = true
@target = AggregateTarget.new(target_definition, config.sandbox)
@target.user_project_path = project_path @target.user_project_path = project_path
@target.user_target_uuids = [@native_target.uuid] @target.user_target_uuids = [@native_target.uuid]
@target.xcconfig_path = config.sandbox.root + 'Pods.xcconfig' @target.xcconfig_path = config.sandbox.root + 'Pods.xcconfig'
......
...@@ -18,12 +18,12 @@ module Pod ...@@ -18,12 +18,12 @@ module Pod
end end
config.sandbox.project = Project.new(config.sandbox.project_path) config.sandbox.project = Project.new(config.sandbox.project_path)
Xcodeproj::Project.new(config.sandbox.project_path).save Xcodeproj::Project.new(config.sandbox.project_path).save
@library = AggregateTarget.new(@podfile.target_definitions['Pods'], config.sandbox) @library = Target.new('Pods')
@library.user_project_path = sample_project_path @library.user_project_path = sample_project_path
@library.user_target_uuids = ['A346496C14F9BE9A0080D870'] @library.user_target_uuids = ['A346496C14F9BE9A0080D870']
@library.xcconfig_path = config.sandbox.root + 'Pods.xcconfig' @library.xcconfig_path = config.sandbox.root + 'Pods.xcconfig'
@library.copy_resources_script_path = config.sandbox.root + 'Pods-resources.sh' @library.copy_resources_script_path = config.sandbox.root + 'Pods-resources.sh'
empty_library = AggregateTarget.new(@podfile.target_definitions[:empty], config.sandbox) empty_library = Target.new('Empty')
@integrator = Installer::UserProjectIntegrator.new(@podfile, config.sandbox, temporary_directory, [@library, empty_library]) @integrator = Installer::UserProjectIntegrator.new(@podfile, config.sandbox, temporary_directory, [@library, empty_library])
end end
...@@ -148,11 +148,6 @@ module Pod ...@@ -148,11 +148,6 @@ module Pod
@integrator.send(:user_project_paths).should == [ @sample_project_path ] @integrator.send(:user_project_paths).should == [ @sample_project_path ]
end end
it "skips libraries with empty target definitions" do
@integrator.targets.map(&:name).should == ["Pods", "Pods-empty"]
@integrator.send(:targets_to_integrate).map(&:name).should == ['Pods']
end
end end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
......
...@@ -115,7 +115,10 @@ module Pod ...@@ -115,7 +115,10 @@ module Pod
@analysis_result = Installer::Analyzer::AnalysisResult.new @analysis_result = Installer::Analyzer::AnalysisResult.new
@analysis_result.specifications = [] @analysis_result.specifications = []
config.sandbox.state = Installer::Analyzer::SpecsState.new() config.sandbox.state = Installer::Analyzer::SpecsState.new()
@pod_targets = [PodTarget.new([], nil, config.sandbox)] pod_target = Target.new('BananaLib', nil)
pod_target.build_headers_store = Sandbox::HeadersStore.new(config.sandbox, "BuildHeaders")
@pod_targets = [pod_target]
@installer.stubs(:analysis_result).returns(@analysis_result) @installer.stubs(:analysis_result).returns(@analysis_result)
@installer.stubs(:pod_targets).returns(@pod_targets) @installer.stubs(:pod_targets).returns(@pod_targets)
end end
...@@ -123,7 +126,7 @@ module Pod ...@@ -123,7 +126,7 @@ module Pod
it "cleans the header stores" do it "cleans the header stores" do
config.sandbox.public_headers.expects(:implode!) config.sandbox.public_headers.expects(:implode!)
@installer.pod_targets.each do |pods_target| @installer.pod_targets.each do |pods_target|
pods_target.build_headers.expects(:implode!) pods_target.build_headers_store.expects(:implode!)
end end
@installer.send(:clean_sandbox) @installer.send(:clean_sandbox)
end end
...@@ -159,7 +162,8 @@ module Pod ...@@ -159,7 +162,8 @@ module Pod
it "correctly configures the Pod source installer" do it "correctly configures the Pod source installer" do
spec = fixture_spec('banana-lib/BananaLib.podspec') spec = fixture_spec('banana-lib/BananaLib.podspec')
pod_target = PodTarget.new([spec], nil, config.sandbox) pod_target = Target.new('BananaLib')
pod_target.specs = [spec]
pod_target.stubs(:platform).returns(:ios) pod_target.stubs(:platform).returns(:ios)
@installer.stubs(:pod_targets).returns([pod_target]) @installer.stubs(:pod_targets).returns([pod_target])
@installer.instance_variable_set(:@installed_specs, []) @installer.instance_variable_set(:@installed_specs, [])
...@@ -169,7 +173,8 @@ module Pod ...@@ -169,7 +173,8 @@ module Pod
it "maintains the list of the installed specs" do it "maintains the list of the installed specs" do
spec = fixture_spec('banana-lib/BananaLib.podspec') spec = fixture_spec('banana-lib/BananaLib.podspec')
pod_target = PodTarget.new([spec], nil, config.sandbox) pod_target = Target.new('BananaLib')
pod_target.specs = [spec]
pod_target.stubs(:platform).returns(:ios) pod_target.stubs(:platform).returns(:ios)
@installer.stubs(:pod_targets).returns([pod_target, pod_target]) @installer.stubs(:pod_targets).returns([pod_target, pod_target])
@installer.instance_variable_set(:@installed_specs, []) @installer.instance_variable_set(:@installed_specs, [])
...@@ -195,7 +200,7 @@ module Pod ...@@ -195,7 +200,7 @@ module Pod
describe "#refresh_file_accessors" do describe "#refresh_file_accessors" do
it "refreshes the file accessors after cleaning and executing the specification hooks" do it "refreshes the file accessors after cleaning and executing the specification hooks" do
pod_target = PodTarget.new([], nil, config.sandbox) pod_target = Target.new('BananaLib')
file_accessor = stub() file_accessor = stub()
pod_target.file_accessors = [file_accessor] pod_target.file_accessors = [file_accessor]
@installer.stubs(:pod_targets).returns([pod_target]) @installer.stubs(:pod_targets).returns([pod_target])
...@@ -209,13 +214,17 @@ module Pod ...@@ -209,13 +214,17 @@ module Pod
describe "#link_headers" do describe "#link_headers" do
before do
@pod_target = Target.new('BananaLib')
@pod_target.file_accessors = [fixture_file_accessor('banana-lib/BananaLib.podspec')]
@pod_target.build_headers_store = Sandbox::HeadersStore.new(config.sandbox, "BuildHeaders")
@installer.stubs(:pod_targets).returns([@pod_target])
end
it "links the build headers" do it "links the build headers" do
pod_target = PodTarget.new(nil, nil, config.sandbox)
pod_target.file_accessors = [fixture_file_accessor('banana-lib/BananaLib.podspec')]
@installer.stubs(:pod_targets).returns([pod_target])
@installer.send(:link_headers) @installer.send(:link_headers)
headers_root = pod_target.build_headers.root headers_root = @pod_target.build_headers_store.root
public_header = headers_root + 'BananaLib/Banana.h' public_header = headers_root + 'BananaLib/Banana.h'
private_header = headers_root + 'BananaLib/BananaPrivate.h' private_header = headers_root + 'BananaLib/BananaPrivate.h'
public_header.should.exist public_header.should.exist
...@@ -223,9 +232,6 @@ module Pod ...@@ -223,9 +232,6 @@ module Pod
end end
it "links the public headers" do it "links the public headers" do
pod_target = PodTarget.new(nil, nil, config.sandbox)
pod_target.file_accessors = [fixture_file_accessor('banana-lib/BananaLib.podspec')]
@installer.stubs(:pod_targets).returns([pod_target])
@installer.send(:link_headers) @installer.send(:link_headers)
headers_root = config.sandbox.public_headers.root headers_root = config.sandbox.public_headers.root
...@@ -340,7 +346,7 @@ module Pod ...@@ -340,7 +346,7 @@ module Pod
describe "#integrate_user_project" do describe "#integrate_user_project" do
it "integrates the client projects" do it "integrates the client projects" do
@installer.stubs(:aggregate_targets).returns([AggregateTarget.new(nil, config.sandbox)]) @installer.stubs(:aggregate_targets).returns([Target.new('Pods')])
Installer::UserProjectIntegrator.any_instance.expects(:integrate!) Installer::UserProjectIntegrator.any_instance.expects(:integrate!)
@installer.send(:integrate_user_project) @installer.send(:integrate_user_project)
end end
...@@ -384,10 +390,9 @@ module Pod ...@@ -384,10 +390,9 @@ module Pod
end end
it "calls the hooks in the specs for each target" do it "calls the hooks in the specs for each target" do
pod_target_ios = PodTarget.new([@spec], nil, config.sandbox) pod_target_ios = Target.new('ios-BananaLib')
pod_target_osx = PodTarget.new([@spec], nil, config.sandbox) pod_target_osx = Target.new('osx-BananaLib')
pod_target_ios.stubs(:name).returns('label')
pod_target_osx.stubs(:name).returns('label')
library_ios_rep = stub() library_ios_rep = stub()
library_osx_rep = stub() library_osx_rep = stub()
target_installer_data = stub() target_installer_data = stub()
...@@ -410,7 +415,7 @@ module Pod ...@@ -410,7 +415,7 @@ module Pod
it "returns the hook representation of a pod" do it "returns the hook representation of a pod" do
file_accessor = stub(:spec => @spec) file_accessor = stub(:spec => @spec)
@aggregate_target.pod_targets.first.stubs(:file_accessors).returns([file_accessor]) @aggregate_target.children.first.stubs(:file_accessors).returns([file_accessor])
rep = @installer.send(:pod_rep, 'JSONKit') rep = @installer.send(:pod_rep, 'JSONKit')
rep.name.should == 'JSONKit' rep.name.should == 'JSONKit'
rep.root_spec.should == @spec rep.root_spec.should == @spec
......
require File.expand_path('../../../spec_helper', __FILE__)
module Pod
describe AggregateTarget do
describe "In general" do
before do
@target_definition = Podfile::TargetDefinition.new('Pods', nil)
@target_definition.link_with_first_target = true
@target = AggregateTarget.new(@target_definition, config.sandbox)
end
it "returns the target_definition that generated it" do
@target.target_definition.should == @target_definition
end
it "returns the label of the target definition" do
@target.label.should == 'Pods'
end
it "returns its name" do
@target.name.should == 'Pods'
end
it "returns the name of its product" do
@target.product_name.should == 'libPods.a'
end
end
describe "Pod targets" do
before do
spec = fixture_spec('banana-lib/BananaLib.podspec')
target_definition = Podfile::TargetDefinition.new('Pods', nil)
pod_target = PodTarget.new([spec], target_definition, config.sandbox)
@target = AggregateTarget.new(target_definition, config.sandbox)
@target.stubs(:platform).returns(:ios)
@target.pod_targets = [pod_target]
end
it "returns the specs of the Pods used by this aggregate target" do
@target.specs.map(&:name).should == ["BananaLib"]
end
it "returns the spec consumers for the pod targets" do
consumer_reps = @target.spec_consumers.map { |consumer| [consumer.spec.name, consumer.platform_name ] }
consumer_reps.should == [["BananaLib", :ios]]
end
end
end
end
require File.expand_path('../../../spec_helper', __FILE__)
module Pod
describe PodTarget do
before do
spec = fixture_spec('banana-lib/BananaLib.podspec')
@target_definition = Podfile::TargetDefinition.new('Pods', nil)
@pod_target = PodTarget.new([spec], @target_definition, config.sandbox)
@pod_target.stubs(:platform).returns(:ios)
end
describe "In general" do
it "returns the target_definition that generated it" do
@pod_target.target_definition.should == @target_definition
end
it "returns its name" do
@pod_target.name.should == 'Pods-BananaLib'
end
it "returns the name of its product" do
@pod_target.product_name.should == 'libPods-BananaLib.a'
end
it "returns the spec consumers for the pod targets" do
@pod_target.spec_consumers.should.not == nil
end
it "returns the root spec" do
@pod_target.root_spec.name.should == 'BananaLib'
end
it "returns the name of the Pod" do
@pod_target.pod_name.should == 'BananaLib'
end
it "returns the name of the Pods on which this target depends" do
@pod_target.dependencies.should == ["monkey"]
end
it "returns the dependencies as root names" do
dependencies = [stub(:name => 'monkey/subspec')]
Specification::Consumer.any_instance.stubs(:dependencies).returns(dependencies)
@pod_target.dependencies.should == ["monkey"]
end
it "never includes itself in the dependencies" do
dependencies = [stub(:name => 'BananaLib/subspec')]
Specification::Consumer.any_instance.stubs(:dependencies).returns(dependencies)
@pod_target.dependencies.should == []
end
end
end
end
...@@ -3,25 +3,99 @@ require File.expand_path('../../spec_helper', __FILE__) ...@@ -3,25 +3,99 @@ require File.expand_path('../../spec_helper', __FILE__)
module Pod module Pod
describe Target do describe Target do
before do before do
@target_definition = Podfile::TargetDefinition.new('Pods', nil) @sut = Target.new('Pods', nil)
@target_definition.link_with_first_target = true @child = Target.new('BananaLib', @sut)
@lib = AggregateTarget.new(@target_definition, config.sandbox)
end end
it "returns the target_definition that generated it" do #-------------------------------------------------------------------------#
@lib.target_definition.should == @target_definition
describe "In general" do
it "adds itself to the children of the parent" do
@sut.children.should == [@child]
end
it "returns the root" do
@sut.root.should == @sut
@child.root.should == @sut
end
it "returns whether it is root" do
@sut.should.be.root
@child.should.not.be.root
end
it "returns its name" do
@sut.name.should == 'Pods'
@child.name.should == 'Pods-BananaLib'
end
it "returns the name of its product" do
@sut.product_name.should == 'libPods.a'
end
end end
it "returns the label of the target definition" do #-------------------------------------------------------------------------#
@lib.label.should == 'Pods'
describe "Specs" do
before do
spec = fixture_spec('banana-lib/BananaLib.podspec')
@sut.specs = [spec]
@sut.platform = Platform.ios
end
it "returns the specs of the Pods used by this aggregate target" do
@sut.specs.map(&:name).should == ["BananaLib"]
end
it "returns the spec consumers for the pod targets" do
consumers = @sut.spec_consumers.map { |consumer| [consumer.spec.name, consumer.platform_name ] }
consumers.should == [["BananaLib", :ios]]
end
it "returns the root spec" do
@sut.root_spec.name.should == 'BananaLib'
end
it "returns the name of the Pod" do
@sut.pod_name.should == 'BananaLib'
end
#----------------------------------------#
describe "#dependencies" do
it "returns the name of the Pods on which this target depends" do
@sut.dependencies.should == ["monkey"]
end
it "returns the dependencies as root names" do
dependencies = [stub(:name => 'monkey/subspec')]
Specification::Consumer.any_instance.stubs(:dependencies).returns(dependencies)
@sut.dependencies.should == ["monkey"]
end
it "never includes itself in the dependencies" do
dependencies = [stub(:name => 'BananaLib/subspec')]
Specification::Consumer.any_instance.stubs(:dependencies).returns(dependencies)
@sut.dependencies.should == []
end
end
#----------------------------------------#
end end
it "returns its name" do #-------------------------------------------------------------------------#
@lib.name.should == 'Pods'
describe "Aggregate" do
end end
it "returns the name of its product" do #-------------------------------------------------------------------------#
@lib.product_name.should == 'libPods.a'
describe "Pod" do
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