Commit 6555d4e0 authored by Marius Rackwitz's avatar Marius Rackwitz

[Refactor] Renamed TargetInstaller#library to target

parent 6717e7be
...@@ -10,16 +10,16 @@ module Pod ...@@ -10,16 +10,16 @@ module Pod
# #
attr_reader :sandbox attr_reader :sandbox
# @return [Library] The library whose target needs to be generated. # @return [Target] The library whose target needs to be generated.
# #
attr_reader :library attr_reader :target
# @param [Project] project @see project # @param [Project] project @see project
# @param [Library] library @see library # @param [Target] target @see target
# #
def initialize(sandbox, library) def initialize(sandbox, target)
@sandbox = sandbox @sandbox = sandbox
@library = library @target = target
end end
private private
...@@ -36,31 +36,31 @@ module Pod ...@@ -36,31 +36,31 @@ module Pod
# @return [void] # @return [void]
# #
def add_target def add_target
name = library.label name = target.label
platform = library.platform.name platform = target.platform.name
deployment_target = library.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)
library.user_build_configurations.each do |bc_name, type| target.user_build_configurations.each do |bc_name, type|
configuration = @native_target.add_build_configuration(bc_name, type) configuration = @native_target.add_build_configuration(bc_name, type)
end end
settings = { 'OTHER_LDFLAGS' => '', 'OTHER_LIBTOOLFLAGS' => '' } settings = { 'OTHER_LDFLAGS' => '', 'OTHER_LIBTOOLFLAGS' => '' }
if library.archs if target.archs
settings['ARCHS'] = library.archs settings['ARCHS'] = target.archs
end end
@native_target.build_configurations.each do |configuration| @native_target.build_configurations.each do |configuration|
configuration.build_settings.merge!(settings) configuration.build_settings.merge!(settings)
end end
library.native_target = @native_target target.native_target = @native_target
end end
# Creates the directory where to store the support files of the target. # Creates the directory where to store the support files of the target.
# #
def create_support_files_dir def create_support_files_dir
library.support_files_dir.mkdir target.support_files_dir.mkdir
end end
# Generates a dummy source file for each target so libraries that contain # Generates a dummy source file for each target so libraries that contain
...@@ -69,8 +69,8 @@ module Pod ...@@ -69,8 +69,8 @@ module Pod
# @return [void] # @return [void]
# #
def create_dummy_source def create_dummy_source
path = library.dummy_source_path path = target.dummy_source_path
generator = Generator::DummySource.new(library.label) generator = Generator::DummySource.new(target.label)
generator.save_as(path) generator.save_as(path)
file_reference = add_file_to_support_group(path) file_reference = add_file_to_support_group(path)
native_target.source_build_phase.add_file_reference(file_reference) native_target.source_build_phase.add_file_reference(file_reference)
...@@ -98,7 +98,7 @@ module Pod ...@@ -98,7 +98,7 @@ module Pod
# @return [TargetDefinition] the target definition of the library. # @return [TargetDefinition] the target definition of the library.
# #
def target_definition def target_definition
library.target_definition target.target_definition
end end
# @return [PBXGroup] the group where the file references to the support # @return [PBXGroup] the group where the file references to the support
......
...@@ -9,7 +9,7 @@ module Pod ...@@ -9,7 +9,7 @@ module Pod
# @return [void] # @return [void]
# #
def install! def install!
UI.message "- Installing target `#{library.name}` #{library.platform}" do UI.message "- Installing target `#{target.name}` #{target.platform}" do
add_target add_target
create_support_files_dir create_support_files_dir
create_suport_files_group create_suport_files_group
...@@ -33,8 +33,8 @@ module Pod ...@@ -33,8 +33,8 @@ module Pod
# #
def create_suport_files_group def create_suport_files_group
parent = project.support_files_group parent = project.support_files_group
name = library.name name = target.name
dir = library.support_files_dir dir = target.support_files_dir
@support_files_group = parent.new_group(name, dir) @support_files_group = parent.new_group(name, dir)
end end
...@@ -44,10 +44,10 @@ module Pod ...@@ -44,10 +44,10 @@ module Pod
# #
def create_xcconfig_file def create_xcconfig_file
native_target.build_configurations.each do |configuration| native_target.build_configurations.each do |configuration|
path = library.xcconfig_path(configuration.name) path = target.xcconfig_path(configuration.name)
gen = Generator::XCConfig::AggregateXCConfig.new(library, configuration.name) gen = Generator::XCConfig::AggregateXCConfig.new(target, configuration.name)
gen.save_as(path) gen.save_as(path)
library.xcconfigs[configuration.name] = gen.xcconfig target.xcconfigs[configuration.name] = gen.xcconfig
xcconfig_file_ref = add_file_to_support_group(path) xcconfig_file_ref = add_file_to_support_group(path)
configuration.base_configuration_reference = xcconfig_file_ref configuration.base_configuration_reference = xcconfig_file_ref
end end
...@@ -57,8 +57,8 @@ module Pod ...@@ -57,8 +57,8 @@ module Pod
# 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 = library.target_environment_header_path path = target.target_environment_header_path
generator = Generator::TargetEnvironmentHeader.new(library.specs_by_build_configuration) generator = Generator::TargetEnvironmentHeader.new(target.specs_by_build_configuration)
generator.save_as(path) generator.save_as(path)
add_file_to_support_group(path) add_file_to_support_group(path)
end end
...@@ -66,14 +66,14 @@ module Pod ...@@ -66,14 +66,14 @@ module Pod
# Generates the bridge support metadata if requested by the {Podfile}. # Generates the bridge support metadata if requested by the {Podfile}.
# #
# @note The bridge support metadata is added to the resources of the # @note The bridge support metadata is added to the resources of the
# library because it is needed for environments interpreted at # target because it is needed for environments interpreted at
# runtime. # runtime.
# #
# @return [void] # @return [void]
# #
def create_bridge_support_file def create_bridge_support_file
if target_definition.podfile.generate_bridge_support? if target_definition.podfile.generate_bridge_support?
path = library.bridge_support_path path = target.bridge_support_path
headers = native_target.headers_build_phase.files.map { |bf| sandbox.root + bf.file_ref.path } headers = native_target.headers_build_phase.files.map { |bf| sandbox.root + bf.file_ref.path }
generator = Generator::BridgeSupport.new(headers) generator = Generator::BridgeSupport.new(headers)
generator.save_as(path) generator.save_as(path)
...@@ -91,15 +91,15 @@ module Pod ...@@ -91,15 +91,15 @@ module Pod
# @return [void] # @return [void]
# #
def create_copy_resources_script def create_copy_resources_script
path = library.copy_resources_script_path path = target.copy_resources_script_path
file_accessors = library.pod_targets.map(&:file_accessors).flatten file_accessors = target.pod_targets.map(&:file_accessors).flatten
resource_paths = file_accessors.map { |accessor| accessor.resources.flatten.map { |res| res.relative_path_from(project.path.dirname) } }.flatten resource_paths = file_accessors.map { |accessor| accessor.resources.flatten.map { |res| res.relative_path_from(project.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 = []
resources.concat(resource_paths) resources.concat(resource_paths)
resources.concat(resource_bundles) resources.concat(resource_bundles)
resources << bridge_support_file if bridge_support_file resources << bridge_support_file if bridge_support_file
generator = Generator::CopyResourcesScript.new(resources, library.platform) generator = Generator::CopyResourcesScript.new(resources, target.platform)
generator.save_as(path) generator.save_as(path)
add_file_to_support_group(path) add_file_to_support_group(path)
end end
...@@ -109,10 +109,10 @@ module Pod ...@@ -109,10 +109,10 @@ module Pod
# @return [void] # @return [void]
# #
def create_acknowledgements def create_acknowledgements
basepath = library.acknowledgements_basepath basepath = target.acknowledgements_basepath
Generator::Acknowledgements.generators.each do |generator_class| Generator::Acknowledgements.generators.each do |generator_class|
path = generator_class.path_from_basepath(basepath) path = generator_class.path_from_basepath(basepath)
file_accessors = library.pod_targets.map(&:file_accessors).flatten file_accessors = target.pod_targets.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)
......
...@@ -9,7 +9,7 @@ module Pod ...@@ -9,7 +9,7 @@ module Pod
# @return [void] # @return [void]
# #
def install! def install!
UI.message "- Installing target `#{library.name}` #{library.platform}" do UI.message "- Installing target `#{target.name}` #{target.platform}" do
add_target add_target
create_support_files_dir create_support_files_dir
add_files_to_build_phases add_files_to_build_phases
...@@ -33,7 +33,7 @@ module Pod ...@@ -33,7 +33,7 @@ module Pod
# @return [void] # @return [void]
# #
def add_files_to_build_phases def add_files_to_build_phases
library.file_accessors.each do |file_accessor| target.file_accessors.each do |file_accessor|
consumer = file_accessor.spec_consumer consumer = file_accessor.spec_consumer
flags = compiler_flags_for_consumer(consumer) flags = compiler_flags_for_consumer(consumer)
all_source_files = file_accessor.source_files all_source_files = file_accessor.source_files
...@@ -53,7 +53,7 @@ module Pod ...@@ -53,7 +53,7 @@ module Pod
# @return [void] # @return [void]
# #
def add_resources_bundle_targets def add_resources_bundle_targets
library.file_accessors.each do |file_accessor| target.file_accessors.each do |file_accessor|
file_accessor.resource_bundles.each do |bundle_name, paths| file_accessor.resource_bundles.each do |bundle_name, paths|
# Add a dependency on an existing Resource Bundle target if possible # Add a dependency on an existing Resource Bundle target if possible
if bundle_target = project.targets.find { |target| target.name == bundle_name } if bundle_target = project.targets.find { |target| target.name == bundle_name }
...@@ -64,7 +64,7 @@ module Pod ...@@ -64,7 +64,7 @@ module Pod
bundle_target = project.new_resources_bundle(bundle_name, file_accessor.spec_consumer.platform_name) bundle_target = project.new_resources_bundle(bundle_name, file_accessor.spec_consumer.platform_name)
bundle_target.add_resources(file_references) bundle_target.add_resources(file_references)
library.user_build_configurations.each do |bc_name, type| target.user_build_configurations.each do |bc_name, type|
bundle_target.add_build_configuration(bc_name, type) bundle_target.add_build_configuration(bc_name, type)
end end
...@@ -78,13 +78,13 @@ module Pod ...@@ -78,13 +78,13 @@ module Pod
# @return [void] # @return [void]
# #
def create_xcconfig_file def create_xcconfig_file
path = library.xcconfig_path path = target.xcconfig_path
public_gen = Generator::XCConfig::PublicPodXCConfig.new(library) public_gen = Generator::XCConfig::PublicPodXCConfig.new(target)
public_gen.save_as(path) public_gen.save_as(path)
add_file_to_support_group(path) add_file_to_support_group(path)
path = library.xcconfig_private_path path = target.xcconfig_private_path
private_gen = Generator::XCConfig::PrivatePodXCConfig.new(library, public_gen.xcconfig) private_gen = Generator::XCConfig::PrivatePodXCConfig.new(target, public_gen.xcconfig)
private_gen.save_as(path) private_gen.save_as(path)
xcconfig_file_ref = add_file_to_support_group(path) xcconfig_file_ref = add_file_to_support_group(path)
...@@ -100,9 +100,9 @@ module Pod ...@@ -100,9 +100,9 @@ module Pod
# @return [void] # @return [void]
# #
def create_prefix_header def create_prefix_header
path = library.prefix_header_path path = target.prefix_header_path
generator = Generator::PrefixHeader.new(library.file_accessors, library.platform) generator = Generator::PrefixHeader.new(target.file_accessors, target.platform)
generator.imports << library.target_environment_header_path.basename generator.imports << target.target_environment_header_path.basename
generator.save_as(path) generator.save_as(path)
add_file_to_support_group(path) add_file_to_support_group(path)
...@@ -176,8 +176,8 @@ module Pod ...@@ -176,8 +176,8 @@ module Pod
# @return [PBXFileReference] the file reference of the added file. # @return [PBXFileReference] the file reference of the added file.
# #
def add_file_to_support_group(path) def add_file_to_support_group(path)
pod_name = library.pod_name pod_name = target.pod_name
dir = library.support_files_dir dir = target.support_files_dir
group = project.pod_support_files_group(pod_name, dir) group = project.pod_support_files_group(pod_name, dir)
group.new_file(path) group.new_file(path)
end end
......
...@@ -109,7 +109,7 @@ module Pod ...@@ -109,7 +109,7 @@ module Pod
it 'does not enable the GCC_WARN_INHIBIT_ALL_WARNINGS flag by default' do it 'does not enable the GCC_WARN_INHIBIT_ALL_WARNINGS flag by default' do
@installer.install! @installer.install!
@installer.library.native_target.build_configurations.each do |config| @installer.target.native_target.build_configurations.each do |config|
config.build_settings['GCC_WARN_INHIBIT_ALL_WARNINGS'].should.be.nil config.build_settings['GCC_WARN_INHIBIT_ALL_WARNINGS'].should.be.nil
end end
end end
...@@ -166,7 +166,7 @@ module Pod ...@@ -166,7 +166,7 @@ module Pod
it 'creates a dummy source to ensure the creation of a single base library' do it 'creates a dummy source to ensure the creation of a single base library' do
@installer.install! @installer.install!
build_files = @installer.library.native_target.source_build_phase.files build_files = @installer.target.native_target.source_build_phase.files
build_file = build_files.find { |bf| bf.file_ref.path.include?('Pods-dummy.m') } build_file = build_files.find { |bf| bf.file_ref.path.include?('Pods-dummy.m') }
build_file.should.be.not.nil build_file.should.be.not.nil
build_file.file_ref.path.should == 'Pods-dummy.m' build_file.file_ref.path.should == 'Pods-dummy.m'
......
...@@ -88,7 +88,7 @@ module Pod ...@@ -88,7 +88,7 @@ module Pod
it 'does not enable the GCC_WARN_INHIBIT_ALL_WARNINGS flag by default' do it 'does not enable the GCC_WARN_INHIBIT_ALL_WARNINGS flag by default' do
@installer.install! @installer.install!
@installer.library.native_target.build_configurations.each do |config| @installer.target.native_target.build_configurations.each do |config|
config.build_settings['GCC_WARN_INHIBIT_ALL_WARNINGS'].should.be.nil config.build_settings['GCC_WARN_INHIBIT_ALL_WARNINGS'].should.be.nil
end end
end end
...@@ -97,7 +97,7 @@ module Pod ...@@ -97,7 +97,7 @@ module Pod
it 'adds the source files of each pod to the target of the Pod library' do it 'adds the source files of each pod to the target of the Pod library' do
@installer.install! @installer.install!
names = @installer.library.native_target.source_build_phase.files.map { |bf| bf.file_ref.display_name } names = @installer.target.native_target.source_build_phase.files.map { |bf| bf.file_ref.display_name }
names.should.include('Banana.m') names.should.include('Banana.m')
end end
...@@ -142,7 +142,7 @@ module Pod ...@@ -142,7 +142,7 @@ module Pod
it 'creates a dummy source to ensure the compilation of libraries with only categories' do it 'creates a dummy source to ensure the compilation of libraries with only categories' do
@installer.install! @installer.install!
build_files = @installer.library.native_target.source_build_phase.files build_files = @installer.target.native_target.source_build_phase.files
build_file = build_files.find { |bf| bf.file_ref.display_name == 'Pods-BananaLib-dummy.m' } build_file = build_files.find { |bf| bf.file_ref.display_name == 'Pods-BananaLib-dummy.m' }
build_file.should.be.not.nil build_file.should.be.not.nil
build_file.file_ref.path.should == 'Pods-BananaLib-dummy.m' build_file.file_ref.path.should == 'Pods-BananaLib-dummy.m'
...@@ -158,10 +158,10 @@ module Pod ...@@ -158,10 +158,10 @@ module Pod
end end
it 'flags should not be added to dtrace files' do it 'flags should not be added to dtrace files' do
@installer.library.target_definition.stubs(:inhibits_warnings_for_pod?).returns(true) @installer.target.target_definition.stubs(:inhibits_warnings_for_pod?).returns(true)
@installer.install! @installer.install!
dtrace_files = @installer.library.native_target.source_build_phase.files.reject do |sf| dtrace_files = @installer.target.native_target.source_build_phase.files.reject do |sf|
!(File.extname(sf.file_ref.path) == '.d') !(File.extname(sf.file_ref.path) == '.d')
end end
dtrace_files.each do |dt| dtrace_files.each do |dt|
...@@ -170,7 +170,7 @@ module Pod ...@@ -170,7 +170,7 @@ module Pod
end end
it 'adds -w per pod if target definition inhibits warnings for that pod' do it 'adds -w per pod if target definition inhibits warnings for that pod' do
@installer.library.target_definition.stubs(:inhibits_warnings_for_pod?).returns(true) @installer.target.target_definition.stubs(:inhibits_warnings_for_pod?).returns(true)
flags = @installer.send(:compiler_flags_for_consumer, @spec.consumer(:ios)) flags = @installer.send(:compiler_flags_for_consumer, @spec.consumer(:ios))
flags.should.include?('-w') flags.should.include?('-w')
...@@ -182,7 +182,7 @@ module Pod ...@@ -182,7 +182,7 @@ module Pod
end end
it 'adds -Xanalyzer -analyzer-disable-checker per pod' do it 'adds -Xanalyzer -analyzer-disable-checker per pod' do
@installer.library.target_definition.stubs(:inhibits_warnings_for_pod?).returns(true) @installer.target.target_definition.stubs(:inhibits_warnings_for_pod?).returns(true)
flags = @installer.send(:compiler_flags_for_consumer, @spec.consumer(:ios)) flags = @installer.send(:compiler_flags_for_consumer, @spec.consumer(:ios))
flags.should.include?('-Xanalyzer -analyzer-disable-checker') flags.should.include?('-Xanalyzer -analyzer-disable-checker')
......
...@@ -42,8 +42,8 @@ module Pod ...@@ -42,8 +42,8 @@ module Pod
it 'always clears the OTHER_LDFLAGS and OTHER_LIBTOOLFLAGS, because these lib targets do not ever need any' do it 'always clears the OTHER_LDFLAGS and OTHER_LIBTOOLFLAGS, because these lib targets do not ever need any' do
@installer.send(:add_target) @installer.send(:add_target)
@installer.send(:target).resolved_build_setting('OTHER_LDFLAGS').values.uniq.should == [''] @installer.send(:native_target).resolved_build_setting('OTHER_LDFLAGS').values.uniq.should == ['']
@installer.send(:target).resolved_build_setting('OTHER_LIBTOOLFLAGS').values.uniq.should == [''] @installer.send(:native_target).resolved_build_setting('OTHER_LIBTOOLFLAGS').values.uniq.should == ['']
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