Commit 59564007 authored by Fabio Pelosin's avatar Fabio Pelosin

[Target] Clean-up

parent 23b8cd37
......@@ -47,7 +47,7 @@ module Pod
# @return [Xcodeproj::Config]
#
def generate
search_pahts = target.build_headers_store.search_paths.concat(target.public_headers_store.search_paths)
search_pahts = target.private_headers_store.search_paths.concat(target.public_headers_store.search_paths)
config = {
'OTHER_LDFLAGS' => XCConfigHelper.default_ld_flags(target),
'PODS_ROOT' => '${SRCROOT}',
......
......@@ -70,7 +70,7 @@ module Pod
# process.
#
def target
library.target
library.native_target
end
#-----------------------------------------------------------------------#
......
......@@ -191,7 +191,7 @@ module Pod
def clean_sandbox
sandbox.public_headers.implode!
pod_targets.each do |pod_target|
pod_target.build_headers_store.implode!
pod_target.private_headers_store.implode!
end
unless sandbox.state.deleted.empty?
......@@ -299,11 +299,11 @@ module Pod
pod_targets.each do |pod_target|
pod_target.file_accessors.each do |file_accessor|
headers_sandbox = Pathname.new(file_accessor.spec.root.name)
pod_target.build_headers_store.add_search_path(headers_sandbox)
pod_target.private_headers_store.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|
pod_target.build_headers_store.add_files(namespaced_path, files)
pod_target.private_headers_store.add_files(namespaced_path, files)
end
header_mappings(headers_sandbox, file_accessor, file_accessor.public_headers).each do |namespaced_path, files|
......
......@@ -176,7 +176,7 @@ module Pod
target.set_arc_compatibility_flag = podfile.set_arc_compatibility_flag?
target.generate_bridge_support = podfile.generate_bridge_support?
target.public_headers_store = sandbox.public_headers
target.build_headers_store = Sandbox::HeadersStore.new(sandbox, "BuildHeaders")
target.private_headers_store = Sandbox::HeadersStore.new(sandbox, "BuildHeaders")
if config.integrate_targets?
project_path = compute_user_project_path(target_definition)
......@@ -196,14 +196,16 @@ module Pod
end.uniq
grouped_specs.each do |pod_specs|
pod_target = Target.new(pod_specs.first.root.name, target)
pod_name = pod_specs.first.root.name
pod_target = Target.new(pod_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.private_headers_store = Sandbox::HeadersStore.new(sandbox, "BuildHeaders")
pod_target.public_headers_store = sandbox.public_headers
pod_target.inhibits_warnings = target_definition.inhibits_warnings_for_pod?(pod_name)
end
end
end
......
......@@ -234,14 +234,14 @@ module Pod
UI.message"- Setting-up target dependencies" do
aggregate_targets.each do |aggregate_target|
aggregate_target.children.each do |dep|
aggregate_target.native_target.add_dependency(dep.target)
aggregate_target.native_target.add_dependency(dep.native_target)
end
aggregate_targets.each do |aggregate_target|
aggregate_target.children.each do |pod_target|
dependencies = pod_target.dependencies.map { |dep_name| aggregate_target.children.find { |target| target.pod_name == dep_name } }
dependencies.each do |dep|
pod_target.native_target.add_dependency(dep.target)
pod_target.native_target.add_dependency(dep.native_target)
end
end
end
......
......@@ -47,7 +47,7 @@ module Pod
#---------------------------------------------------------------------#
def validate
unless target.target
unless target.native_target
raise "[SupportFilesGenerator] Missing native target for `#{target}`"
end
end
......@@ -64,7 +64,7 @@ module Pod
xcconfig_file_ref = add_file_to_support_group(path)
target.xcconfig_path = path
target.target.build_configurations.each do |c|
target.native_target.build_configurations.each do |c|
c.base_configuration_reference = xcconfig_file_ref
end
end
......@@ -85,7 +85,7 @@ module Pod
private_gen.save_as(path)
xcconfig_file_ref = add_file_to_support_group(path)
target.target.build_configurations.each do |c|
target.native_target.build_configurations.each do |c|
c.base_configuration_reference = xcconfig_file_ref
end
end
......@@ -111,7 +111,7 @@ module Pod
def create_bridge_support_file
if target.generate_bridge_support?
path = file_path(:bridge_support)
headers = target.target.headers_build_phase.files.map { |bf| bf.file_ref.real_path }
headers = target.native_target.headers_build_phase.files.map { |bf| bf.file_ref.real_path }
generator = Generator::BridgeSupport.new(headers)
generator.save_as(path)
add_file_to_support_group(path)
......@@ -172,7 +172,7 @@ module Pod
add_file_to_support_group(path)
target.prefix_header_path = path
target.target.build_configurations.each do |c|
target.native_target.build_configurations.each do |c|
relative_path = path.relative_path_from(project.path.dirname)
c.build_settings['GCC_PREFIX_HEADER'] = relative_path.to_s
end
......@@ -189,9 +189,9 @@ module Pod
generator = Generator::DummySource.new(target.name)
generator.save_as(path)
file_reference = add_file_to_support_group(path)
existing = target.target.source_build_phase.files_references.include?(file_reference)
existing = target.native_target.source_build_phase.files_references.include?(file_reference)
unless existing
target.target.source_build_phase.add_file_reference(file_reference)
target.native_target.source_build_phase.add_file_reference(file_reference)
end
end
......
......@@ -8,8 +8,12 @@ module Pod
#
class Target
# @return [String]
#
attr_accessor :short_name
# @return [Target]
#
attr_accessor :parent
def initialize(short_name, parent = nil)
......@@ -86,9 +90,7 @@ module Pod
# @return [PBXNativeTarget] The Xcode native target generated in the Pods
# project.
#
attr_accessor :target
alias :native_target :target
alias :native_target= :target=
attr_accessor :native_target
# @return [Pathname] The directory where the support files are stored.
#
......@@ -96,7 +98,7 @@ module Pod
# @return [HeadersStore] the build header store.
#
attr_accessor :build_headers_store
attr_accessor :private_headers_store
# @return [HeadersStore] the public header store.
#
......@@ -119,6 +121,74 @@ module Pod
attr_accessor :prefix_header_path
public
# @!group Aggregate
#-------------------------------------------------------------------------#
#
#
def aggregate?
root?
end
#----------------------------------------#
# @return [Platform] the platform for this library.
#
def platform
if root?
@platform
else
root.platform
end
end
# Sets the platform of the target
#
def platform=(platform)
if root?
@platform = platform
else
raise "The platform must be set in the root target"
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
# @return [Bool]
#
attr_accessor :set_arc_compatibility_flag
alias :set_arc_compatibility_flag? :set_arc_compatibility_flag
# @return [Bool]
#
attr_accessor :generate_bridge_support
alias :generate_bridge_support? :generate_bridge_support
public
# @!group Specs
......@@ -164,87 +234,34 @@ module Pod
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)
# @return [Array<String>]
#
def frameworks
spec_consumers.map(&:frameworks).flatten.uniq
end
# @return [Array<String>]
#
def libraries
spec_consumers.map(&:libraries).flatten.uniq
end
# @return [Bool]
#
attr_accessor :inhibits_warnings
alias :inhibits_warnings? :inhibits_warnings
public
# @!group Aggregate
# @!group Deprecated
#-------------------------------------------------------------------------#
# TODO: This has been preserved only for the LibraryRepresentation.
#
#
def aggregate?
root?
end
#----------------------------------------#
# @return [Platform] the platform for this library.
#
def platform
if root?
@paltform
else
root.platform
end
end
#
#
def platform=(platform)
if root?
@paltform = platform
else
raise "The platform must be set in the root target"
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
......@@ -11,7 +11,7 @@ module Pod
@consumer = @spec.consumer(:ios)
@pod_target = Target.new('Pods-BananaLib')
@pod_target.platform = Platform.ios
@pod_target.build_headers_store = Sandbox::HeadersStore.new(config.sandbox, "BuildHeaders")
@pod_target.private_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"})
@generator = PrivatePodXCConfig.new(@pod_target, public_xcconfig)
......@@ -31,7 +31,7 @@ module Pod
end
it 'adds the library build headers and public headers search paths to the xcconfig, with quotes' do
private_headers = "\"#{@pod_target.build_headers_store.search_paths.join('" "')}\""
private_headers = "\"#{@pod_target.private_headers_store.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 public_headers
......
......@@ -65,7 +65,7 @@ module Pod
it "returns the native target" do
target = stub()
@lib.target = target
@lib.native_target = target
@rep.target.should == target
end
......
......@@ -14,9 +14,9 @@ module Pod
@target.user_project_path = config.sandbox.root + '../user_project.xcodeproj'
@target.user_build_configurations = { 'Debug' => :debug, 'Release' => :release, 'AppStore' => :release, 'Test' => :debug }
@target.support_files_root = config.sandbox.root
@target.target = native_target
@target.native_target = native_target
@target.public_headers_store = config.sandbox.public_headers
@target.build_headers_store = config.sandbox.public_headers
@target.private_headers_store = config.sandbox.public_headers
file_accessor = fixture_file_accessor('banana-lib/BananaLib.podspec')
@spec = fixture_spec('banana-lib/BananaLib.podspec')
......@@ -26,7 +26,7 @@ module Pod
@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
@pod_target.private_headers_store = config.sandbox.public_headers
@sut = Installer::PodsProjectGenerator::SupportFilesGenerator.new(@target, config.sandbox)
end
......@@ -92,7 +92,7 @@ module Pod
it "creates a dummy source to ensure the creation of a single base target" do
@sut.generate!
build_files = @sut.target.target.source_build_phase.files
build_files = @sut.target.native_target.source_build_phase.files
build_file = build_files.find { |bf| bf.file_ref.path.include?('Pods-dummy.m') }
build_file.should.be.not.nil
build_file.file_ref.path.should == 'Pods-dummy.m'
......@@ -116,7 +116,7 @@ module Pod
@target.user_build_configurations = { 'Debug' => :debug, 'Release' => :release, 'AppStore' => :release, 'Test' => :debug }
@target.support_files_root = config.sandbox.root
@target.public_headers_store = config.sandbox.public_headers
@target.build_headers_store = config.sandbox.public_headers
@target.private_headers_store = config.sandbox.public_headers
file_accessor = fixture_file_accessor('banana-lib/BananaLib.podspec')
@spec = fixture_spec('banana-lib/BananaLib.podspec')
......@@ -126,8 +126,8 @@ module Pod
@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
@pod_target.target = native_target
@pod_target.private_headers_store = config.sandbox.public_headers
@pod_target.native_target = native_target
@sut = Installer::PodsProjectGenerator::SupportFilesGenerator.new(@pod_target, config.sandbox)
end
......@@ -156,7 +156,7 @@ module Pod
it "creates a dummy source to ensure the compilation of libraries with only categories" do
@sut.generate!
build_files = @sut.target.target.source_build_phase.files
build_files = @sut.target.native_target.source_build_phase.files
build_file = build_files.find { |bf| bf.file_ref.display_name == 'Pods-BananaLib-dummy.m' }
build_file.should.be.not.nil
build_file.file_ref.path.should == 'Pods-BananaLib-dummy.m'
......
......@@ -179,9 +179,9 @@ module Pod
@aggregate_native_target = project.new_target(:static_library, 'Pods', :ios)
@pod_native_target = project.new_target(:static_library, 'Pods-BananaLib', :ios)
aggregate_target = Target.new('Pods')
aggregate_target.target = @aggregate_native_target
aggregate_target.native_target = @aggregate_native_target
pod_target = Target.new('Pods-BananaLib', aggregate_target)
pod_target.target = @pod_native_target
pod_target.native_target = @pod_native_target
@sut = PodsProjectGenerator.new(config.sandbox, [aggregate_target])
end
......@@ -203,11 +203,11 @@ module Pod
pod_native_target_2 = project.new_target(:static_library, 'Pods-monkey', :ios)
@aggregate_target = Target.new('Pods')
@aggregate_target.target = aggregate_native_target
@aggregate_target.native_target = aggregate_native_target
@pod_target_1 = Target.new('BananaLib', @aggregate_target)
@pod_target_1.target = pod_native_target_1
@pod_target_1.native_target = pod_native_target_1
@pod_target_2 = Target.new('monkey', @aggregate_target)
@pod_target_2.target = pod_native_target_2
@pod_target_2.native_target = pod_native_target_2
@sut = PodsProjectGenerator.new(config.sandbox, [@aggregate_target])
end
......@@ -215,7 +215,7 @@ module Pod
it "sets the pod targets as dependencies of the aggregate target" do
@sut.send(:add_missing_target_dependencies)
dependencies = @aggregate_target.target.dependencies
dependencies = @aggregate_target.native_target.dependencies
dependencies.map { |d| d.target.name}.should == ["Pods-BananaLib", "Pods-monkey"]
end
......@@ -224,7 +224,7 @@ module Pod
@pod_target_1.stubs(:pod_name).returns('BananaLib')
@pod_target_2.stubs(:pod_name).returns('monkey')
@sut.send(:add_missing_target_dependencies)
dependencies = @pod_target_1.target.dependencies
dependencies = @pod_target_1.native_target.dependencies
dependencies.map { |d| d.target.name}.should == ["Pods-monkey"]
end
......
......@@ -116,7 +116,7 @@ module Pod
@analysis_result.specifications = []
config.sandbox.state = Installer::Analyzer::SpecsState.new()
pod_target = Target.new('BananaLib', nil)
pod_target.build_headers_store = Sandbox::HeadersStore.new(config.sandbox, "BuildHeaders")
pod_target.private_headers_store = Sandbox::HeadersStore.new(config.sandbox, "BuildHeaders")
@pod_targets = [pod_target]
@installer.stubs(:analysis_result).returns(@analysis_result)
......@@ -126,7 +126,7 @@ module Pod
it "cleans the header stores" do
config.sandbox.public_headers.expects(:implode!)
@installer.pod_targets.each do |pods_target|
pods_target.build_headers_store.expects(:implode!)
pods_target.private_headers_store.expects(:implode!)
end
@installer.send(:clean_sandbox)
end
......@@ -217,14 +217,14 @@ module Pod
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")
@pod_target.private_headers_store = Sandbox::HeadersStore.new(config.sandbox, "BuildHeaders")
@installer.stubs(:pod_targets).returns([@pod_target])
end
it "links the build headers" do
@installer.send(:link_headers)
headers_root = @pod_target.build_headers_store.root
headers_root = @pod_target.private_headers_store.root
public_header = headers_root + 'BananaLib/Banana.h'
private_header = headers_root + 'BananaLib/BananaPrivate.h'
public_header.should.exist
......
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