Commit 27f75ca4 authored by Samuel E. Giddins's avatar Samuel E. Giddins

Merge pull request #4267 from CocoaPods/seg-frameworks-nested-headers

[PodTargetInstaller] Preserve header_mappings_dir when copying header…
parents 4738e9c2 02ddb916
...@@ -16,12 +16,13 @@ DerivedData ...@@ -16,12 +16,13 @@ DerivedData
/doc /doc
# Specs # Specs
tmp
spec/fixtures/banana-lib spec/fixtures/banana-lib
spec/fixtures/cache
spec/fixtures/chameleon spec/fixtures/chameleon
spec/fixtures/integration/Headers/ spec/fixtures/integration/Headers/
spec/fixtures/snake
spec/fixtures/vcr spec/fixtures/vcr
spec/fixtures/cache tmp
# Examples # Examples
examples/**/Podfile.lock examples/**/Podfile.lock
......
...@@ -17,6 +17,14 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ...@@ -17,6 +17,14 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
[Daniel Ribeiro](https://github.com/danielribeiro) [Daniel Ribeiro](https://github.com/danielribeiro)
[#4399](https://github.com/CocoaPods/CocoaPods/pull/4399) [#4399](https://github.com/CocoaPods/CocoaPods/pull/4399)
* Framework pods that have a `header_mappings_dirs` set will now produce
frameworks with headers that respect the nesting.
[Samuel Giddins](https://github.com/segiddins)
* The validator will now ensure that pods with a `header_mappings_dirs` have all
of their headers inside that directory.
[Samuel Giddins](https://github.com/segiddins)
##### Bug Fixes ##### Bug Fixes
* Improve repo lint error message when no repo found with given name. * Improve repo lint error message when no repo found with given name.
......
...@@ -83,15 +83,7 @@ module Pod ...@@ -83,15 +83,7 @@ module Pod
header_file_refs = headers.map { |sf| project.reference_for_path(sf) } header_file_refs = headers.map { |sf| project.reference_for_path(sf) }
native_target.add_file_references(header_file_refs) do |build_file| native_target.add_file_references(header_file_refs) do |build_file|
# Set added headers as public if needed add_header(build_file, public_headers, private_headers)
build_file.settings ||= {}
if public_headers.include?(build_file.file_ref.real_path)
build_file.settings['ATTRIBUTES'] = ['Public']
elsif private_headers.include?(build_file.file_ref.real_path)
build_file.settings['ATTRIBUTES'] = ['Private']
else
build_file.settings['ATTRIBUTES'] = ['Project']
end
end end
other_file_refs = other_source_files.map { |sf| project.reference_for_path(sf) } other_file_refs = other_source_files.map { |sf| project.reference_for_path(sf) }
...@@ -285,6 +277,39 @@ module Pod ...@@ -285,6 +277,39 @@ module Pod
@custom_module_map ||= target.file_accessors.first.module_map @custom_module_map ||= target.file_accessors.first.module_map
end end
def header_mappings_dir
return @header_mappings_dir if defined?(@header_mappings_dir)
file_accessor = target.file_accessors.first
@header_mappings_dir = if dir = file_accessor.spec_consumer.header_mappings_dir
file_accessor.path_list.root + dir
end
end
def add_header(build_file, public_headers, private_headers)
file_ref = build_file.file_ref
acl = if public_headers.include?(file_ref.real_path)
'Public'
elsif private_headers.include?(file_ref.real_path)
'Private'
else
'Project'
end
if target.requires_frameworks? && header_mappings_dir
relative_path = file_ref.real_path.relative_path_from(header_mappings_dir)
sub_dir = relative_path.dirname
copy_phase_name = "Copy #{sub_dir} #{acl} Headers"
copy_phase = native_target.copy_files_build_phases.find { |bp| bp.name == copy_phase_name } ||
native_target.new_copy_files_build_phase(copy_phase_name)
copy_phase.symbol_dst_subfolder_spec = :products_directory
copy_phase.dst_path = "$(#{acl.upcase}_HEADERS_FOLDER_PATH)/#{sub_dir}"
copy_phase.add_file_reference(file_ref, true)
else
build_file.settings ||= {}
build_file.settings['ATTRIBUTES'] = [acl]
end
end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
end end
end end
......
...@@ -454,6 +454,7 @@ module Pod ...@@ -454,6 +454,7 @@ module Pod
end end
end end
_validate_header_mappings_dir
if consumer.spec.root? if consumer.spec.root?
_validate_license _validate_license
_validate_module_map _validate_module_map
...@@ -491,12 +492,26 @@ module Pod ...@@ -491,12 +492,26 @@ module Pod
def _validate_header_files(attr_name) def _validate_header_files(attr_name)
non_header_files = file_accessor.send(attr_name). non_header_files = file_accessor.send(attr_name).
select { |f| !Sandbox::FileAccessor::HEADER_EXTENSIONS.include?(f.extname) }. select { |f| !Sandbox::FileAccessor::HEADER_EXTENSIONS.include?(f.extname) }.
map { |f| f.relative_path_from file_accessor.root } map { |f| f.relative_path_from(file_accessor.root) }
unless non_header_files.empty? unless non_header_files.empty?
error(attr_name, "The pattern matches non-header files (#{non_header_files.join(', ')}).") error(attr_name, "The pattern matches non-header files (#{non_header_files.join(', ')}).")
end end
end end
def _validate_header_mappings_dir
return unless header_mappings_dir = file_accessor.spec_consumer.header_mappings_dir
absolute_mappings_dir = file_accessor.root + header_mappings_dir
unless absolute_mappings_dir.directory?
error('header_mappings_dir', "The header_mappings_dir (`#{header_mappings_dir}`) is not a directory.")
end
non_mapped_headers = file_accessor.headers.
reject { |h| h.to_path.start_with?(absolute_mappings_dir.to_path) }.
map { |f| f.relative_path_from(file_accessor.root) }
unless non_mapped_headers.empty?
error('header_mappings_dir', "There are header files outside of the header_mappings_dir (#{non_mapped_headers.join(', ')}).")
end
end
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
private private
......
...@@ -239,6 +239,51 @@ module Pod ...@@ -239,6 +239,51 @@ module Pod
#--------------------------------------------------------------------------------# #--------------------------------------------------------------------------------#
it 'creates custom copy files phases for framework pods with header_mappings_dirs' do
@project.add_pod_group('snake', fixture('snake'))
@pod_target = fixture_pod_target('snake/snake.podspec', @target_definition)
@pod_target.user_build_configurations = { 'Debug' => :debug, 'Release' => :release }
@pod_target.stubs(:requires_frameworks? => true)
group = @project.group_for_spec('snake')
@pod_target.file_accessors.first.source_files.each do |file|
@project.add_file_reference(file, group)
end
@installer.stubs(:target).returns(@pod_target)
@installer.install!
target = @project.native_targets.first
target.name.should == 'snake'
target.headers_build_phase.files.reject { |build_file| build_file.settings.nil? }.map(&:display_name).should == ['snake-umbrella.h']
copy_files_build_phases = target.copy_files_build_phases.sort_by(&:name)
copy_files_build_phases.map(&:name).should == [
'Copy . Public Headers',
'Copy A Public Headers',
'Copy B Public Headers',
'Copy C Public Headers',
]
copy_files_build_phases.map(&:symbol_dst_subfolder_spec).should == Array.new(4, :products_directory)
copy_files_build_phases.map(&:dst_path).should == [
'$(PUBLIC_HEADERS_FOLDER_PATH)/.',
'$(PUBLIC_HEADERS_FOLDER_PATH)/A',
'$(PUBLIC_HEADERS_FOLDER_PATH)/B',
'$(PUBLIC_HEADERS_FOLDER_PATH)/C',
]
copy_files_build_phases.map { |phase| phase.files_references.map(&:path) }.should == [
['Code/snake.h'],
['Code/A/Boa.h', 'Code/A/Garden.h', 'Code/A/Rattle.h'],
['Code/B/Boa.h', 'Code/B/Garden.h', 'Code/B/Rattle.h'],
['Code/C/Boa.h', 'Code/C/Garden.h', 'Code/C/Rattle.h'],
]
end
#--------------------------------------------------------------------------------#
describe 'concerning compiler flags' do describe 'concerning compiler flags' do
before do before do
@spec = Pod::Spec.new @spec = Pod::Spec.new
......
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