Commit 270907f1 authored by Fabio Pelosin's avatar Fabio Pelosin

[Sandbox] Store support files per target

parent 9d99d3eb
......@@ -57,13 +57,10 @@ module Pod
library.target = @target
end
# Creates the group that holds the references to the support files
# generated by this installer.
# Creates the directory where to store the support files of the target.
#
# @return [void]
#
def create_suport_files_group
@support_files_group = project.support_files_group.new_group(library.name)
def create_support_files_dir
library.support_files_dir.mkdir
end
# Generates a dummy source file for each target so libraries that contain
......
......@@ -11,6 +11,7 @@ module Pod
def install!
UI.message "- Installing target `#{library.name}` #{library.platform}" do
add_target
create_support_files_dir
create_suport_files_group
create_xcconfig_file
create_target_environment_header
......@@ -25,6 +26,18 @@ module Pod
private
# Creates the group that holds the references to the support files
# generated by this installer.
#
# @return [void]
#
def create_suport_files_group
parent = project.support_files_group
name = library.name
dir = library.support_files_dir
@support_files_group = parent.new_group(name, dir)
end
# Generates the contents of the xcconfig file and saves it to disk.
#
# @return [void]
......
......@@ -11,6 +11,7 @@ module Pod
def install!
UI.message "- Installing target `#{library.name}` #{library.platform}" do
add_target
create_support_files_dir
add_files_to_build_phases
add_resources_bundle_targets
create_xcconfig_file
......@@ -186,7 +187,8 @@ module Pod
#
def add_file_to_support_group(path)
pod_name = library.pod_name
group = project.pod_support_files_group(pod_name)
dir = library.support_files_dir
group = project.pod_support_files_group(pod_name, dir)
group.new_file(path)
end
......
......@@ -122,12 +122,11 @@ module Pod
#
# @return [PBXGroup] The group.
#
def pod_support_files_group(pod_name)
def pod_support_files_group(pod_name, dir)
group = pod_group(pod_name)
support_files_group = group['Support Files']
unless support_files_group
support_files_group = group.new_group('Support Files')
support_files_group.source_tree = 'SOURCE_ROOT'
support_files_group = group.new_group('Support Files', dir)
end
support_files_group
end
......
......@@ -132,8 +132,8 @@ module Pod
#
# @return [Pathname] the path of the support files.
#
def target_support_files_dir(_name)
target_support_files_root
def target_support_files_dir(name)
target_support_files_root + name
end
# Returns the path where the Pod with the given name is stored, taking into
......
......@@ -71,8 +71,8 @@ module Pod
# @return [Pathname] the folder where to store the support files of this
# library.
#
def support_files_root
@sandbox.target_support_files_dir(name)
def support_files_dir
sandbox.target_support_files_dir(name)
end
# @param [String] variant
......@@ -83,41 +83,42 @@ module Pod
#
def xcconfig_path(variant = nil)
if variant
support_files_root + "#{label}.#{variant.downcase}.xcconfig"
support_files_dir + "#{label}.#{variant.downcase}.xcconfig"
else
support_files_root + "#{label}.xcconfig"
support_files_dir + "#{label}.xcconfig"
end
end
# @return [Pathname] the absolute path of the private xcconfig file.
#
def xcconfig_private_path
support_files_root + "#{label}-Private.xcconfig"
support_files_dir + "#{label}-Private.xcconfig"
end
# @return [Pathname] the absolute path of the header file which contains
# the information about the installed pods.
#
def target_environment_header_path
support_files_root + "#{target_definition.label}-environment.h"
name = target_definition.label
sandbox.target_support_files_dir(name) + "#{name}-environment.h"
end
# @return [Pathname] the absolute path of the prefix header file.
#
def prefix_header_path
support_files_root + "#{label}-prefix.pch"
support_files_dir + "#{label}-prefix.pch"
end
# @return [Pathname] the absolute path of the bridge support file.
#
def bridge_support_path
support_files_root + "#{label}.bridgesupport"
support_files_dir + "#{label}.bridgesupport"
end
# @return [Pathname] the path of the dummy source generated by CocoaPods
#
def dummy_source_path
support_files_root + "#{label}-dummy.m"
support_files_dir + "#{label}-dummy.m"
end
#-------------------------------------------------------------------------#
......
......@@ -102,13 +102,13 @@ module Pod
# the file type.
#
def acknowledgements_basepath
support_files_root + "#{label}-acknowledgements"
support_files_dir + "#{label}-acknowledgements"
end
# @return [Pathname] The absolute path of the copy resources script.
#
def copy_resources_script_path
support_files_root + "#{label}-resources.sh"
support_files_dir + "#{label}-resources.sh"
end
# @return [String] The xcconfig path of the root from the `$(SRCROOT)`
......
......@@ -29,11 +29,13 @@ module Pod
end
it 'returns the path of the prefix header' do
@rep.prefix_header_path.should == temporary_directory + 'Pods/Target Support Files/Pods-MyApp-prefix.pch'
@rep.prefix_header_path.should == temporary_directory +
'Pods/Target Support Files/Pods-MyApp/Pods-MyApp-prefix.pch'
end
it 'returns the path of the copy resources script' do
@rep.copy_resources_script_path.should == temporary_directory + 'Pods/Target Support Files/Pods-MyApp-resources.sh'
@rep.copy_resources_script_path.should == temporary_directory +
'Pods/Target Support Files/Pods-MyApp/Pods-MyApp-resources.sh'
end
it 'returns the pods project' do
......
......@@ -82,7 +82,7 @@ module Pod
'Pods-SVPullToRefresh',
'Pods-libextobjc',
].sort
target.support_files_root.should == config.sandbox.target_support_files_dir('Pods')
target.support_files_dir.should == config.sandbox.target_support_files_dir('Pods')
target.user_project_path.to_s.should.include 'SampleProject/SampleProject'
target.client_root.to_s.should.include 'SampleProject'
......
......@@ -169,7 +169,7 @@ module Pod
build_files = @installer.library.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 == 'Target Support Files/Pods-dummy.m'
build_file.file_ref.path.should == 'Pods-dummy.m'
support_files_dir = config.sandbox.target_support_files_dir('Pods')
dummy = support_files_dir + 'Pods-dummy.m'
dummy.read.should.include?('@interface PodsDummy_Pods')
......
......@@ -125,7 +125,7 @@ module Pod
it "creates a prefix header, including the contents of the specification's prefix header" do
@spec.prefix_header_contents = '#import "BlocksKit.h"'
@installer.install!
support_files_dir = config.sandbox.target_support_files_dir('Pods')
support_files_dir = config.sandbox.target_support_files_dir('Pods-BananaLib')
prefix_header = support_files_dir + 'Pods-BananaLib-prefix.pch'
generated = prefix_header.read
expected = <<-EOS.strip_heredoc
......@@ -145,8 +145,8 @@ module Pod
build_files = @installer.library.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 == 'Target Support Files/Pods-BananaLib-dummy.m'
support_files_dir = config.sandbox.target_support_files_dir('Pods')
build_file.file_ref.path.should == 'Pods-BananaLib-dummy.m'
support_files_dir = config.sandbox.target_support_files_dir('Pods-BananaLib')
dummy = support_files_dir + 'Pods-BananaLib-dummy.m'
dummy.read.should.include?('@interface PodsDummy_Pods')
end
......
......@@ -47,7 +47,7 @@ module Pod
phase = target.shell_script_build_phases.find { |bp| bp.name == 'Copy Pods Resources' }
phase.shell_script = %("${SRCROOT}/../Pods/Pods-resources.sh"\n)
@target_integrator.integrate!
phase.shell_script.strip.should == "\"${SRCROOT}/../Pods/Target Support Files/Pods-resources.sh\""
phase.shell_script.strip.should == "\"${SRCROOT}/../Pods/Target Support Files/Pods/Pods-resources.sh\""
end
it 'adds references to the Pods static libraries to the Frameworks group' do
......@@ -67,7 +67,7 @@ module Pod
@target_integrator.integrate!
target = @target_integrator.send(:native_targets).first
phase = target.shell_script_build_phases.find { |bp| bp.name == 'Copy Pods Resources' }
phase.shell_script.strip.should == "\"${SRCROOT}/../Pods/Target Support Files/Pods-resources.sh\""
phase.shell_script.strip.should == "\"${SRCROOT}/../Pods/Target Support Files/Pods/Pods-resources.sh\""
end
it 'adds a Check Manifest.lock build phase to each target' do
......
......@@ -36,37 +36,37 @@ module Pod
end
it 'returns the absolute path of the xcconfig file' do
@lib.xcconfig_path('Release').to_s.should.include?('Pods/Target Support Files/Pods.release.xcconfig')
@lib.xcconfig_path('Release').to_s.should.include?('Pods/Target Support Files/Pods/Pods.release.xcconfig')
end
it 'returns the absolute path of the resources script' do
@lib.copy_resources_script_path.to_s.should.include?('Pods/Target Support Files/Pods-resources.sh')
@lib.copy_resources_script_path.to_s.should.include?('Pods/Target Support Files/Pods/Pods-resources.sh')
end
it 'returns the absolute path of the target header file' do
@lib.target_environment_header_path.to_s.should.include?('Pods/Target Support Files/Pods-environment.h')
@lib.target_environment_header_path.to_s.should.include?('Pods/Target Support Files/Pods/Pods-environment.h')
end
it 'returns the absolute path of the prefix header file' do
@lib.prefix_header_path.to_s.should.include?('Pods/Target Support Files/Pods-prefix.pch')
@lib.prefix_header_path.to_s.should.include?('Pods/Target Support Files/Pods/Pods-prefix.pch')
end
it 'returns the absolute path of the bridge support file' do
@lib.bridge_support_path.to_s.should.include?('Pods/Target Support Files/Pods.bridgesupport')
@lib.bridge_support_path.to_s.should.include?('Pods/Target Support Files/Pods/Pods.bridgesupport')
end
it 'returns the absolute path of the acknowledgements files without extension' do
@lib.acknowledgements_basepath.to_s.should.include?('Pods/Target Support Files/Pods-acknowledgements')
@lib.acknowledgements_basepath.to_s.should.include?('Pods/Target Support Files/Pods/Pods-acknowledgements')
end
#--------------------------------------#
it 'returns the path of the resources script relative to the user project' do
@lib.copy_resources_script_relative_path.should == '${SRCROOT}/Pods/Target Support Files/Pods-resources.sh'
@lib.copy_resources_script_relative_path.should == '${SRCROOT}/Pods/Target Support Files/Pods/Pods-resources.sh'
end
it 'returns the path of the xcconfig file relative to the user project' do
@lib.xcconfig_relative_path('Release').should == 'Pods/Target Support Files/Pods.release.xcconfig'
@lib.xcconfig_relative_path('Release').should == 'Pods/Target Support Files/Pods/Pods.release.xcconfig'
end
end
......
......@@ -139,14 +139,13 @@ module Pod
end
it 'creates a support file group relative to the project' do
group = @project.pod_support_files_group('BananaLib')
group.source_tree.should == 'SOURCE_ROOT'
group.path.should.be.nil
group = @project.pod_support_files_group('BananaLib', 'path')
group.path.should == 'path'
end
it "doesn't duplicate the groups" do
group_1 = @project.pod_support_files_group('BananaLib')
group_2 = @project.pod_support_files_group('BananaLib')
group_1 = @project.pod_support_files_group('BananaLib', 'path')
group_2 = @project.pod_support_files_group('BananaLib', 'path')
group_1.uuid.should == group_2.uuid
end
......
......@@ -33,7 +33,8 @@ module Pod
end
it 'returns the public headers store' do
@sandbox.public_headers.root.should == temporary_directory + 'Sandbox/Headers/Public'
@sandbox.public_headers.root.should ==
temporary_directory + 'Sandbox/Headers/Public'
end
it 'cleans any trace of the Pod with the given name' do
......@@ -61,19 +62,23 @@ module Pod
describe 'Paths' do
it 'returns the path of the manifest' do
@sandbox.manifest_path.should == temporary_directory + 'Sandbox/Manifest.lock'
@sandbox.manifest_path.should ==
temporary_directory + 'Sandbox/Manifest.lock'
end
it 'returns the path of the Pods project' do
@sandbox.project_path.should == temporary_directory + 'Sandbox/Pods.xcodeproj'
@sandbox.project_path.should ==
temporary_directory + 'Sandbox/Pods.xcodeproj'
end
it 'returns the directory for the support files of a library' do
@sandbox.target_support_files_dir('Pods').should == temporary_directory + 'Sandbox/Target Support Files'
@sandbox.target_support_files_dir('Pods').should ==
temporary_directory + 'Sandbox/Target Support Files/Pods'
end
it 'returns the directory where a Pod is stored' do
@sandbox.pod_dir('JSONKit').should == temporary_directory + 'Sandbox/Sources/JSONKit'
@sandbox.pod_dir('JSONKit').should ==
temporary_directory + 'Sandbox/Sources/JSONKit'
end
it 'returns the directory where a local Pod is stored' do
......@@ -112,13 +117,15 @@ module Pod
end
it 'returns the directory where to store the specifications' do
@sandbox.specifications_root.should == temporary_directory + 'Sandbox/Local Podspecs'
@sandbox.specifications_root.should ==
temporary_directory + 'Sandbox/Local Podspecs'
end
it "returns the path to a spec file in the 'Local Podspecs' dir" do
(@sandbox.root + 'Local Podspecs').mkdir
FileUtils.cp(fixture('banana-lib/BananaLib.podspec'), @sandbox.root + 'Local Podspecs')
@sandbox.specification_path('BananaLib').should == @sandbox.root + 'Local Podspecs/BananaLib.podspec'
@sandbox.specification_path('BananaLib').should ==
@sandbox.root + 'Local Podspecs/BananaLib.podspec'
end
it 'stores a podspec with a given path into the sandbox' do
......
......@@ -44,35 +44,35 @@ module Pod
end
it 'returns the absolute path of the xcconfig file' do
@target.xcconfig_path('Release').to_s.should.include?('Pods/Target Support Files/Pods.release.xcconfig')
@target.xcconfig_path('Release').to_s.should.include?('Pods/Target Support Files/Pods/Pods.release.xcconfig')
end
it 'returns the absolute path of the resources script' do
@target.copy_resources_script_path.to_s.should.include?('Pods/Target Support Files/Pods-resources.sh')
@target.copy_resources_script_path.to_s.should.include?('Pods/Target Support Files/Pods/Pods-resources.sh')
end
it 'returns the absolute path of the target header file' do
@target.target_environment_header_path.to_s.should.include?('Pods/Target Support Files/Pods-environment.h')
@target.target_environment_header_path.to_s.should.include?('Pods/Target Support Files/Pods/Pods-environment.h')
end
it 'returns the absolute path of the prefix header file' do
@target.prefix_header_path.to_s.should.include?('Pods/Target Support Files/Pods-prefix.pch')
@target.prefix_header_path.to_s.should.include?('Pods/Target Support Files/Pods/Pods-prefix.pch')
end
it 'returns the absolute path of the bridge support file' do
@target.bridge_support_path.to_s.should.include?('Pods/Target Support Files/Pods.bridgesupport')
@target.bridge_support_path.to_s.should.include?('Pods/Target Support Files/Pods/Pods.bridgesupport')
end
it 'returns the absolute path of the acknowledgements files without extension' do
@target.acknowledgements_basepath.to_s.should.include?('Pods/Target Support Files/Pods-acknowledgements')
@target.acknowledgements_basepath.to_s.should.include?('Pods/Target Support Files/Pods/Pods-acknowledgements')
end
it 'returns the path of the resources script relative to the user project' do
@target.copy_resources_script_relative_path.should == '${SRCROOT}/Pods/Target Support Files/Pods-resources.sh'
@target.copy_resources_script_relative_path.should == '${SRCROOT}/Pods/Target Support Files/Pods/Pods-resources.sh'
end
it 'returns the path of the xcconfig file relative to the user project' do
@target.xcconfig_relative_path('Release').should == 'Pods/Target Support Files/Pods.release.xcconfig'
@target.xcconfig_relative_path('Release').should == 'Pods/Target Support Files/Pods/Pods.release.xcconfig'
end
end
......
......@@ -54,32 +54,45 @@ module Pod
@target_definition.store_pod('BananaLib')
@target_definition.store_pod('BananaLib/Subspec')
@target_definition.whitelist_pod_for_configuration('BananaLib', 'debug')
should.raise Informative do
message = should.raise Informative do
@pod_target.include_in_build_config?('release').should.be.true
end.message.should.match /subspecs across different build configurations/
end.message
message.should.match /subspecs across different build configurations/
end
end
describe 'Support files' do
it 'returns the absolute path of the xcconfig file' do
@pod_target.xcconfig_path('Release').to_s.should.include 'Pods/Target Support Files/Pods-BananaLib.release.xcconfig'
@pod_target.xcconfig_path('Release').to_s.should.include?(
'Pods/Target Support Files/Pods-BananaLib/Pods-BananaLib.release.xcconfig'
)
end
it 'returns the absolute path of the target header file' do
@pod_target.target_environment_header_path.to_s.should.include 'Pods/Target Support Files/Pods-environment.h'
@pod_target.target_environment_header_path.to_s.should.include?(
'Pods/Target Support Files/Pods/Pods-environment.h'
)
end
it 'returns the absolute path of the prefix header file' do
@pod_target.prefix_header_path.to_s.should.include 'Pods/Target Support Files/Pods-BananaLib-prefix.pch'
@pod_target.prefix_header_path.to_s.should.include?(
'Pods/Target Support Files/Pods-BananaLib/Pods-BananaLib-prefix.pch'
)
end
it 'returns the absolute path of the bridge support file' do
@pod_target.bridge_support_path.to_s.should.include 'Pods/Target Support Files/Pods-BananaLib.bridgesupport'
@pod_target.bridge_support_path.to_s.should.include?(
'Pods/Target Support Files/Pods-BananaLib/Pods-BananaLib.bridgesupport'
)
end
it 'returns the absolute path of the public and private xcconfig files' do
@pod_target.xcconfig_path.to_s.should.include 'Pods/Target Support Files/Pods-BananaLib.xcconfig'
@pod_target.xcconfig_private_path.to_s.should.include 'Pods/Target Support Files/Pods-BananaLib-Private.xcconfig'
@pod_target.xcconfig_path.to_s.should.include?(
'Pods/Target Support Files/Pods-BananaLib/Pods-BananaLib.xcconfig'
)
@pod_target.xcconfig_private_path.to_s.should.include(
'Pods/Target Support Files/Pods-BananaLib/Pods-BananaLib-Private.xcconfig'
)
end
end
......
......@@ -173,11 +173,17 @@ module Pod
describe 'Screenshot validation' do
before do
@sut.stubs(:validate_homepage)
WebMock::API.stub_request(:head, 'banana-corp.local/valid-image.png').to_return(:status => 200, :headers => { 'Content-Type' => 'image/png' })
WebMock::API.
stub_request(:head, 'banana-corp.local/valid-image.png').
to_return({
:status => 200,
:headers => { 'Content-Type' => 'image/png' }
})
end
it 'checks if the screenshots are valid' do
Specification.any_instance.stubs(:screenshots).returns(['http://banana-corp.local/valid-image.png'])
Specification.any_instance.stubs(:screenshots).
returns(['http://banana-corp.local/valid-image.png'])
@sut.validate
@sut.results.should.be.empty?
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