Add inputs and outputs for resources script phase

parent 7246c408
...@@ -8,6 +8,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ...@@ -8,6 +8,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
##### Enhancements ##### Enhancements
* Add inputs and outputs for resources script phase
[Dimitris Koutsogiorgas](https://github.com/dnkoutso)
[#6806](https://github.com/CocoaPods/CocoaPods/pull/6806)
* Simplify logic around framework input and output paths * Simplify logic around framework input and output paths
[Dimitris Koutsogiorgas](https://github.com/dnkoutso) [Dimitris Koutsogiorgas](https://github.com/dnkoutso)
[#6803](https://github.com/CocoaPods/CocoaPods/pull/6803) [#6803](https://github.com/CocoaPods/CocoaPods/pull/6803)
......
...@@ -136,7 +136,7 @@ module Pod ...@@ -136,7 +136,7 @@ module Pod
script_path = target.embed_frameworks_script_relative_path script_path = target.embed_frameworks_script_relative_path
phase.shell_script = %("#{script_path}"\n) phase.shell_script = %("#{script_path}"\n)
framework_paths_by_config = target.framework_paths_by_config.values.flatten.uniq framework_paths_by_config = target.framework_paths_by_config.values.flatten.uniq
unless framework_paths_by_config.empty? unless framework_paths_by_config.all?(&:empty?)
phase.input_paths = [target.embed_frameworks_script_relative_path, *framework_paths_by_config.map { |fw| [fw[:input_path], fw[:dsym_input_path]] }.flatten.compact] phase.input_paths = [target.embed_frameworks_script_relative_path, *framework_paths_by_config.map { |fw| [fw[:input_path], fw[:dsym_input_path]] }.flatten.compact]
phase.output_paths = framework_paths_by_config.map { |fw| [fw[:output_path], fw[:dsym_output_path]] }.flatten.compact phase.output_paths = framework_paths_by_config.map { |fw| [fw[:output_path], fw[:dsym_output_path]] }.flatten.compact
end end
...@@ -164,7 +164,11 @@ module Pod ...@@ -164,7 +164,11 @@ module Pod
phase = create_or_update_build_phase(native_target, phase_name) phase = create_or_update_build_phase(native_target, phase_name)
script_path = target.copy_resources_script_relative_path script_path = target.copy_resources_script_relative_path
phase.shell_script = %("#{script_path}"\n) phase.shell_script = %("#{script_path}"\n)
# TODO: Add input and output paths for the copy resources script phase. resource_paths_by_config = target.resource_paths_by_config
unless resource_paths_by_config.values.all?(&:empty?)
phase.input_paths = [target.copy_resources_script_relative_path, *resource_paths_by_config.values.flatten.uniq]
phase.output_paths = ['${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}']
end
end end
end end
......
...@@ -119,7 +119,7 @@ module Pod ...@@ -119,7 +119,7 @@ module Pod
# #
def create_copy_resources_script def create_copy_resources_script
path = target.copy_resources_script_path path = target.copy_resources_script_path
generator = Generator::CopyResourcesScript.new(target.resources_by_config, target.platform) generator = Generator::CopyResourcesScript.new(target.resource_paths_by_config, target.platform)
generator.save_as(path) generator.save_as(path)
add_file_to_support_group(path) add_file_to_support_group(path)
end end
......
...@@ -222,9 +222,9 @@ module Pod ...@@ -222,9 +222,9 @@ module Pod
framework_paths_by_config framework_paths_by_config
end end
# @return [Hash{ Symbol => Array<Pathname> }] Uniqued Resources grouped by config # @return [Hash{ String => Array<String> }] Uniqued Resources grouped by config
# #
def resources_by_config def resource_paths_by_config
library_targets = pod_targets.reject do |pod_target| library_targets = pod_targets.reject do |pod_target|
pod_target.should_build? && pod_target.requires_frameworks? pod_target.should_build? && pod_target.requires_frameworks?
end end
...@@ -232,7 +232,7 @@ module Pod ...@@ -232,7 +232,7 @@ module Pod
resources_by_config[config] = library_targets.flat_map do |library_target| resources_by_config[config] = library_targets.flat_map do |library_target|
next [] unless library_target.include_in_build_config?(target_definition, config) next [] unless library_target.include_in_build_config?(target_definition, config)
resource_paths = library_target.file_accessors.flat_map do |accessor| resource_paths = library_target.file_accessors.flat_map do |accessor|
accessor.resources.flat_map { |res| res.relative_path_from(sandbox.project.path.dirname) } accessor.resources.flat_map { |res| "${PODS_ROOT}/#{res.relative_path_from(sandbox.project.path.dirname)}" }
end end
resource_bundles = library_target.file_accessors.flat_map do |accessor| resource_bundles = library_target.file_accessors.flat_map do |accessor|
accessor.resource_bundles.keys.map { |name| "#{library_target.configuration_build_dir}/#{name.shellescape}.bundle" } accessor.resource_bundles.keys.map { |name| "#{library_target.configuration_build_dir}/#{name.shellescape}.bundle" }
......
Subproject commit 20fe360fab027944870e3e7f6307942e994acc74 Subproject commit 72424f479a2e86682d511955ada020e87d631231
...@@ -31,6 +31,10 @@ module Pod ...@@ -31,6 +31,10 @@ module Pod
@phase_prefix = Installer::UserProjectIntegrator::TargetIntegrator::BUILD_PHASE_PREFIX @phase_prefix = Installer::UserProjectIntegrator::TargetIntegrator::BUILD_PHASE_PREFIX
@embed_framework_phase_name = @phase_prefix + @embed_framework_phase_name = @phase_prefix +
Installer::UserProjectIntegrator::TargetIntegrator::EMBED_FRAMEWORK_PHASE_NAME Installer::UserProjectIntegrator::TargetIntegrator::EMBED_FRAMEWORK_PHASE_NAME
@copy_pods_resources_phase_name = @phase_prefix +
Installer::UserProjectIntegrator::TargetIntegrator::COPY_PODS_RESOURCES_PHASE_NAME
@check_manifest_phase_name = @phase_prefix +
Installer::UserProjectIntegrator::TargetIntegrator::CHECK_MANIFEST_PHASE_NAME
end end
describe '#integrate!' do describe '#integrate!' do
...@@ -47,7 +51,7 @@ module Pod ...@@ -47,7 +51,7 @@ module Pod
it 'fixes the copy resource scripts of legacy installations' do it 'fixes the copy resource scripts of legacy installations' do
@target_integrator.integrate! @target_integrator.integrate!
target = @target_integrator.send(:native_targets).first target = @target_integrator.send(:native_targets).first
phase_name = @phase_prefix + Installer::UserProjectIntegrator::TargetIntegrator::COPY_PODS_RESOURCES_PHASE_NAME phase_name = @copy_pods_resources_phase_name
phase = target.shell_script_build_phases.find { |bp| bp.name == phase_name } phase = target.shell_script_build_phases.find { |bp| bp.name == phase_name }
phase.shell_script = %("${SRCROOT}/../Pods/Pods-resources.sh"\n) phase.shell_script = %("${SRCROOT}/../Pods/Pods-resources.sh"\n)
@target_integrator.integrate! @target_integrator.integrate!
...@@ -85,7 +89,7 @@ module Pod ...@@ -85,7 +89,7 @@ module Pod
it 'adds a Copy Pods Resources build phase to each target' do it 'adds a Copy Pods Resources build phase to each target' do
@target_integrator.integrate! @target_integrator.integrate!
target = @target_integrator.send(:native_targets).first target = @target_integrator.send(:native_targets).first
phase_name = @phase_prefix + Installer::UserProjectIntegrator::TargetIntegrator::COPY_PODS_RESOURCES_PHASE_NAME phase_name = @copy_pods_resources_phase_name
phase = target.shell_script_build_phases.find { |bp| bp.name == phase_name } phase = target.shell_script_build_phases.find { |bp| bp.name == phase_name }
phase.shell_script.strip.should == '"${SRCROOT}/../Pods/Target Support Files/Pods/Pods-resources.sh"' phase.shell_script.strip.should == '"${SRCROOT}/../Pods/Target Support Files/Pods/Pods-resources.sh"'
end end
...@@ -93,7 +97,7 @@ module Pod ...@@ -93,7 +97,7 @@ module Pod
it 'adds a Check Manifest.lock build phase to each target' do it 'adds a Check Manifest.lock build phase to each target' do
@target_integrator.integrate! @target_integrator.integrate!
target = @target_integrator.send(:native_targets).first target = @target_integrator.send(:native_targets).first
phase_name = @phase_prefix + Installer::UserProjectIntegrator::TargetIntegrator::CHECK_MANIFEST_PHASE_NAME phase_name = @check_manifest_phase_name
phase = target.shell_script_build_phases.find { |bp| bp.name == phase_name } phase = target.shell_script_build_phases.find { |bp| bp.name == phase_name }
phase.shell_script.should == <<-EOS.strip_heredoc phase.shell_script.should == <<-EOS.strip_heredoc
diff "${PODS_PODFILE_DIR_PATH}/Podfile.lock" "${PODS_ROOT}/Manifest.lock" > /dev/null diff "${PODS_PODFILE_DIR_PATH}/Podfile.lock" "${PODS_ROOT}/Manifest.lock" > /dev/null
...@@ -111,7 +115,7 @@ module Pod ...@@ -111,7 +115,7 @@ module Pod
@target_integrator.integrate! @target_integrator.integrate!
target = @target_integrator.send(:native_targets).first target = @target_integrator.send(:native_targets).first
target.build_phases.first target.build_phases.first
phase_name = @phase_prefix + Installer::UserProjectIntegrator::TargetIntegrator::CHECK_MANIFEST_PHASE_NAME phase_name = @check_manifest_phase_name
phase = target.build_phases.find { |bp| bp.name == phase_name } phase = target.build_phases.find { |bp| bp.name == phase_name }
target.build_phases.first.should.equal? phase target.build_phases.first.should.equal? phase
end end
...@@ -284,8 +288,34 @@ module Pod ...@@ -284,8 +288,34 @@ module Pod
phase.nil?.should == true phase.nil?.should == true
end end
it 'does not add copy pods resources input and output paths with no resources' do
@pod_bundle.stubs(:resource_paths_by_config => { 'Debug' => [], 'Release' => [] })
@target_integrator.integrate!
target = @target_integrator.send(:native_targets).first
phase = target.shell_script_build_phases.find { |bp| bp.name == @copy_pods_resources_phase_name }
phase.input_paths.should.be.empty
phase.output_paths.should.be.empty
end
it 'adds copy pods resources input and output paths' do
resource_paths_by_config = {
'Debug' => ['$PODS_CONFIGURATION_BUILD_DIR/DebugLib/DebugLib.bundle'],
'Release' => ['$PODS_CONFIGURATION_BUILD_DIR/ReleaseLib/ReleaseLib.bundle'],
}
@pod_bundle.stubs(:resource_paths_by_config => resource_paths_by_config)
@target_integrator.integrate!
target = @target_integrator.send(:native_targets).first
phase = target.shell_script_build_phases.find { |bp| bp.name == @copy_pods_resources_phase_name }
phase.input_paths.sort.should == %w(
$PODS_CONFIGURATION_BUILD_DIR/DebugLib/DebugLib.bundle
$PODS_CONFIGURATION_BUILD_DIR/ReleaseLib/ReleaseLib.bundle
${SRCROOT}/../Pods/Target\ Support\ Files/Pods/Pods-resources.sh
)
phase.output_paths.sort.should == %w(${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH})
end
it 'does not add embed frameworks build phase input output paths with no frameworks' do it 'does not add embed frameworks build phase input output paths with no frameworks' do
@pod_bundle.stubs(:framework_paths_by_config => {}) @pod_bundle.stubs(:framework_paths_by_config => { 'Debug' => {}, 'Release' => {} })
@target_integrator.integrate! @target_integrator.integrate!
target = @target_integrator.send(:native_targets).first target = @target_integrator.send(:native_targets).first
phase = target.shell_script_build_phases.find { |bp| bp.name == @embed_framework_phase_name } phase = target.shell_script_build_phases.find { |bp| bp.name == @embed_framework_phase_name }
......
...@@ -158,7 +158,7 @@ module Pod ...@@ -158,7 +158,7 @@ module Pod
'Trees' => [Pathname('palm.jpg')], 'Trees' => [Pathname('palm.jpg')],
'Leafs' => [Pathname('leaf.jpg')], 'Leafs' => [Pathname('leaf.jpg')],
) )
resources_by_config = @target.resources_by_config resources_by_config = @target.resource_paths_by_config
resources_by_config.each_value do |resources| resources_by_config.each_value do |resources|
resources.should.include '$PODS_CONFIGURATION_BUILD_DIR/BananaLib/Trees.bundle' resources.should.include '$PODS_CONFIGURATION_BUILD_DIR/BananaLib/Trees.bundle'
resources.should.include '$PODS_CONFIGURATION_BUILD_DIR/BananaLib/Leafs.bundle' resources.should.include '$PODS_CONFIGURATION_BUILD_DIR/BananaLib/Leafs.bundle'
...@@ -167,7 +167,7 @@ module Pod ...@@ -167,7 +167,7 @@ module Pod
it 'adds the bridge support file to the copy resources script, if one was created' do it 'adds the bridge support file to the copy resources script, if one was created' do
Podfile.any_instance.stubs(:generate_bridge_support? => true) Podfile.any_instance.stubs(:generate_bridge_support? => true)
resources_by_config = @target.resources_by_config resources_by_config = @target.resource_paths_by_config
resources_by_config.each_value do |resources| resources_by_config.each_value do |resources|
resources.should.include @installer.target.bridge_support_file resources.should.include @installer.target.bridge_support_file
end end
...@@ -190,10 +190,10 @@ module Pod ...@@ -190,10 +190,10 @@ module Pod
accessor.stubs(:resources => duplicated_paths) accessor.stubs(:resources => duplicated_paths)
end end
end end
resources_by_config = @target.resources_by_config resources_by_config = @target.resource_paths_by_config
resources_by_config.each_value do |resources| resources_by_config.each_value do |resources|
resources.length.should == 1 resources.length.should == 1
resources[0].basename.should == a_path.basename Pathname.new(resources[0]).basename.should == a_path.basename
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