Unverified Commit 2b4de852 authored by Samuel Giddins's avatar Samuel Giddins Committed by GitHub

Merge pull request #7181 from keith/ks/empty-build-phases

Only add resources and frameworks build phase when needed
parents efeff72e 878d6939
......@@ -49,6 +49,11 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
[Dimitris Koutsogiorgas](https://github.com/dnkoutso)
[#7336](https://github.com/CocoaPods/CocoaPods/issues/7336)
* Avoid adding copy resources and frameworks script phases when those phases
would not copy anything.
[Keith Smiley](https://github.com/keith)
[Samuel Giddins](https://github.com/segiddins)
## 1.4.0 (2018-01-18)
......
......@@ -47,7 +47,7 @@ group :development do
# Integration tests
gem 'diffy'
gem 'clintegracon'
gem 'clintegracon', :git => 'https://github.com/segiddins/CLIntegracon.git', :branch => 'segiddins/replacement-pattern-overlapping-replacements'
# Code Quality
gem 'inch_by_inch'
......
......@@ -93,6 +93,15 @@ GIT
specs:
cocoapods-try (1.1.0)
GIT
remote: https://github.com/segiddins/CLIntegracon.git
revision: 8bb9aa1fecd1731df996bda5cabc53fd746d2577
branch: segiddins/replacement-pattern-overlapping-replacements
specs:
clintegracon (0.8.1)
colored2 (~> 3.1)
diffy
GIT
remote: https://github.com/segiddins/json.git
revision: a9588bc4334c2f5bf985f255b61c05eafdcd8907
......@@ -142,15 +151,11 @@ GEM
cork
nap
open4 (~> 1.3)
clintegracon (0.8.1)
colored (~> 1.2)
diffy
cocoapods-dependencies (1.0.0.beta.1)
ruby-graphviz (~> 1.2)
cocoapods_debug (0.1.0)
pry (= 0.10.3)
coderay (1.1.0)
colored (1.2)
colored2 (3.1.2)
concurrent-ruby (1.0.5)
cork (0.3.0)
......@@ -267,7 +272,7 @@ DEPENDENCIES
bacon
bundler (~> 1.3)
claide!
clintegracon
clintegracon!
cocoapods!
cocoapods-core!
cocoapods-deintegrate!
......
......@@ -119,6 +119,17 @@ module Pod
phase.output_paths = output_paths
end
# Delete a 'Copy Pods Resources' script phase if present
#
# @param [PBXNativeTarget] native_target
# The native target to remove the script phase from.
#
def remove_copy_resources_script_phase_from_target(native_target)
build_phase = native_target.shell_script_build_phases.find { |bp| bp.name && bp.name.end_with?(COPY_PODS_RESOURCES_PHASE_NAME) }
return unless build_phase.present?
native_target.build_phases.delete(build_phase)
end
# Creates or update a shell script build phase for the given target.
#
# @param [PBXNativeTarget] native_target
......@@ -292,9 +303,9 @@ module Pod
native_targets.each do |native_target|
script_path = target.copy_resources_script_relative_path
resource_paths_by_config = target.resource_paths_by_config
input_paths = []
output_paths = []
unless resource_paths_by_config.values.all?(&:empty?)
if resource_paths_by_config.values.all?(&:empty?)
TargetIntegrator.remove_copy_resources_script_phase_from_target(native_target)
else
resource_paths_flattened = resource_paths_by_config.values.flatten.uniq
input_paths = [target.copy_resources_script_relative_path, *resource_paths_flattened]
# convert input paths to output paths according to extensions
......@@ -303,9 +314,9 @@ module Pod
output_extension = TargetIntegrator.output_extension_for_resource(File.extname(input_path))
File.join(base_path, File.basename(input_path, File.extname(input_path)) + output_extension)
end.uniq
TargetIntegrator.validate_input_output_path_limit(input_paths, output_paths)
TargetIntegrator.create_or_update_copy_resources_script_phase_to_target(native_target, script_path, input_paths, output_paths)
end
TargetIntegrator.validate_input_output_path_limit(input_paths, output_paths)
TargetIntegrator.create_or_update_copy_resources_script_phase_to_target(native_target, script_path, input_paths, output_paths)
end
end
......@@ -332,14 +343,14 @@ module Pod
native_targets_to_embed_in.each do |native_target|
script_path = target.embed_frameworks_script_relative_path
framework_paths_by_config = target.framework_paths_by_config.values.flatten.uniq
input_paths = []
output_paths = []
unless framework_paths_by_config.all?(&:empty?)
if framework_paths_by_config.all?(&:empty?)
TargetIntegrator.remove_embed_frameworks_script_phase_from_target(native_target)
else
input_paths = [target.embed_frameworks_script_relative_path, *framework_paths_by_config.map { |fw| [fw[:input_path], fw[:dsym_input_path]] }.flatten.compact]
output_paths = framework_paths_by_config.map { |fw| [fw[:output_path], fw[:dsym_output_path]] }.flatten.compact.uniq
TargetIntegrator.validate_input_output_path_limit(input_paths, output_paths)
TargetIntegrator.create_or_update_embed_frameworks_script_phase_to_target(native_target, script_path, input_paths, output_paths)
end
TargetIntegrator.validate_input_output_path_limit(input_paths, output_paths)
TargetIntegrator.create_or_update_embed_frameworks_script_phase_to_target(native_target, script_path, input_paths, output_paths)
end
end
......
Subproject commit 42f00e7a2b76ce69b0f3c7a06f85baa7a874d71b
Subproject commit 382f474f5f42af0cbfeccac15371fe6dd9ee579c
......@@ -149,6 +149,7 @@ describe_cli 'pod' do
# This was changed in a very recent git version
s.replace_pattern /git checkout -b <new-branch-name>/, 'git checkout -b new_branch_name'
s.replace_pattern /[ \t]+(\r?$)/, '\1'
# git sometimes prints this, but not always ¯\_(ツ)_/¯
s.replace_pattern /^\s*Checking out files.*done\./, ''
......
......@@ -19,6 +19,8 @@ module Pod
@pod_bundle.user_build_configurations = { 'Release' => :release, 'Debug' => :debug }
@pod_bundle.client_root = project_path.dirname
@pod_bundle.user_target_uuids = [@target.uuid]
@pod_bundle.stubs(:resource_paths_by_config).returns('Release' => %w(${PODS_ROOT}/Lib/Resources/image.png))
@pod_bundle.stubs(:framework_paths_by_config).returns('Release' => [{ :input_path => '${PODS_BUILD_DIR}/Lib/Lib.framework' }])
configuration = Xcodeproj::Config.new(
'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) COCOAPODS=1',
)
......@@ -290,13 +292,28 @@ module Pod
phase.nil?.should == true
end
it 'does not add copy pods resources input and output paths with no resources' do
it 'does not add copy pods resources script phase 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
phase.should.be.nil
end
it 'removes copy resources phase if it becomes empty' do
@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_ROOT}/Lib/Resources/image.png
${SRCROOT}/../Pods/Target\ Support\ Files/Pods/Pods-resources.sh
)
# Now pretend the same target has no more framework paths, it should update the targets input/output paths
@pod_bundle.stubs(: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.should.be.nil
end
it 'clears input and output paths from script phase if it exceeds limit' do
......@@ -378,16 +395,15 @@ module Pod
)
end
it 'does not add embed frameworks build phase input output paths with no frameworks' do
it 'does not add embed frameworks build phase with no frameworks' do
@pod_bundle.stubs(:framework_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 == @embed_framework_phase_name }
phase.input_paths.should.be.empty
phase.output_paths.should.be.empty
phase.should.be.nil
end
it 'updates embed frameworks phase if it becomes empty' do
it 'removes embed frameworks phase if it becomes empty' do
debug_non_vendored_framework = { :name => 'DebugCompiledFramework.framework',
:input_path => '${BUILT_PRODUCTS_DIR}/DebugCompiledFramework/DebugCompiledFramework.framework',
:output_path => '${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/DebugCompiledFramework.framework' }
......@@ -407,7 +423,7 @@ module Pod
@target_integrator.integrate!
target = @target_integrator.send(:native_targets).first
phase = target.shell_script_build_phases.find { |bp| bp.name == @embed_framework_phase_name }
phase.input_paths.sort.should.be.empty
phase.should.be.nil
end
it 'adds embed frameworks build phase input and output paths for vendored and non vendored frameworks' do
......
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