Commit 2fcf6c17 authored by Marius Rackwitz's avatar Marius Rackwitz

Merge pull request #3145 from CocoaPods/seg-module-map

Allow the specification of custom module map files
parents 0bbd1060 1d0a7346
...@@ -6,6 +6,13 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ...@@ -6,6 +6,13 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
## Master ## Master
##### Enhancements
* Allow the specification of custom module map files.
[Samuel Giddins](https://github.com/segiddins)
[Marius Rackwitz](https://github.com/mrackwitz)
[#3145](https://github.com/CocoaPods/CocoaPods/issues/3145)
##### Bug Fixes ##### Bug Fixes
* Do not pass code-sign arguments to xcodebuild when linting OS X targets. * Do not pass code-sign arguments to xcodebuild when linting OS X targets.
......
...@@ -7,7 +7,7 @@ GIT ...@@ -7,7 +7,7 @@ GIT
GIT GIT
remote: https://github.com/CocoaPods/Core.git remote: https://github.com/CocoaPods/Core.git
revision: ff06595f0151dd5d2ba247251f87bab63ece1cfb revision: 971a8c4aa452726bec255c784714a7a7ebaa55fc
branch: master branch: master
specs: specs:
cocoapods-core (0.36.3) cocoapods-core (0.36.3)
......
...@@ -50,6 +50,7 @@ module Pod ...@@ -50,6 +50,7 @@ module Pod
headers = file_accessor.headers headers = file_accessor.headers
public_headers = file_accessor.public_headers public_headers = file_accessor.public_headers
private_headers = file_accessor.private_headers
other_source_files = file_accessor.source_files.select { |sf| sf.extname == '.d' } other_source_files = file_accessor.source_files.select { |sf| sf.extname == '.d' }
{ {
...@@ -66,9 +67,13 @@ module Pod ...@@ -66,9 +67,13 @@ module Pod
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 # Set added headers as public if needed
if target.requires_frameworks? if target.requires_frameworks?
if public_headers.include?(build_file.file_ref.real_path)
build_file.settings ||= {} build_file.settings ||= {}
if public_headers.include?(build_file.file_ref.real_path)
build_file.settings['ATTRIBUTES'] = ['Public'] 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 end
end end
...@@ -239,6 +244,20 @@ module Pod ...@@ -239,6 +244,20 @@ module Pod
group.new_file(path) group.new_file(path)
end end
def create_module_map
return super unless module_map = target.file_accessors.first.module_map
path = target.module_map_path
UI.message "- Copying module map file to #{UI.path(path)}" do
FileUtils.cp(module_map, path)
add_file_to_support_group(path)
native_target.build_configurations.each do |c|
relative_path = path.relative_path_from(sandbox.root)
c.build_settings['MODULEMAP_FILE'] = relative_path.to_s
end
end
end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
end end
end end
......
...@@ -124,6 +124,12 @@ module Pod ...@@ -124,6 +124,12 @@ module Pod
header_files - private_headers header_files - private_headers
end end
# @return [Array<Pathname>] The private headers of the specification.
#
def private_headers
private_header_files
end
# @return [Hash{ Symbol => Array<Pathname> }] the resources of the # @return [Hash{ Symbol => Array<Pathname> }] the resources of the
# specification grouped by destination. # specification grouped by destination.
# #
...@@ -206,6 +212,14 @@ module Pod ...@@ -206,6 +212,14 @@ module Pod
end end
end end
# @return [Pathname, Nil] The path of the custom module map file of the
# specification, if specified.
def module_map
if module_map = spec_consumer.spec.root.module_map
path_list.root + module_map
end
end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
private private
......
...@@ -399,9 +399,8 @@ module Pod ...@@ -399,9 +399,8 @@ module Pod
end end
if consumer.spec.root? if consumer.spec.root?
unless file_accessor.license || spec.license && (spec.license[:type] == 'Public Domain' || spec.license[:text]) _validate_license
warning('license', 'Unable to find a license file') _validate_module_map
end
end end
end end
...@@ -413,6 +412,24 @@ module Pod ...@@ -413,6 +412,24 @@ module Pod
_validate_header_files(:public_header_files) _validate_header_files(:public_header_files)
end end
def _validate_license
unless file_accessor.license || spec.license && (spec.license[:type] == 'Public Domain' || spec.license[:text])
warning('license', 'Unable to find a license file')
end
end
def _validate_module_map
if spec.module_map
unless file_accessor.module_map.exist?
error('module_map', 'Unable to find the specified module map file.')
end
unless file_accessor.module_map.extname == '.modulemap'
relative_path = file_accessor.module_map.relative_path_from file_accessor.root
error('module_map', "Unexpected file extension for modulemap file (#{relative_path}).")
end
end
end
# Ensures that a list of header files only contains header files. # Ensures that a list of header files only contains header files.
# #
def _validate_header_files(attr_name) def _validate_header_files(attr_name)
......
Subproject commit e35ee4d2dd475dd8407a3f3231a403a370b5d2a0 Subproject commit 053e086f92387ca51dff135c8477d1e1f7b2af6d
...@@ -173,6 +173,11 @@ describe_cli 'pod' do ...@@ -173,6 +173,11 @@ describe_cli 'pod' do
'install --no-repo-update' 'install --no-repo-update'
end end
describe 'Installs a Pod with a custom module map' do
behaves_like cli_spec 'install_custom_module_map',
'install --no-repo-update'
end
describe 'Installs a Pod with a custom module name' do describe 'Installs a Pod with a custom module name' do
behaves_like cli_spec 'install_custom_module_name', behaves_like cli_spec 'install_custom_module_name',
'install --no-repo-update' 'install --no-repo-update'
......
...@@ -31,6 +31,7 @@ module Pod ...@@ -31,6 +31,7 @@ module Pod
# #
def stub_podspec(pattern = nil, replacement = nil) def stub_podspec(pattern = nil, replacement = nil)
spec = (fixture('spec-repos') + 'master/Specs/JSONKit/1.4/JSONKit.podspec.json').read spec = (fixture('spec-repos') + 'master/Specs/JSONKit/1.4/JSONKit.podspec.json').read
spec.gsub!(/.*license.*$/, '"license": "Public Domain",')
spec.gsub!(%r{https://github\.com/johnezang/JSONKit\.git}, fixture('integration/JSONKit').to_s) spec.gsub!(%r{https://github\.com/johnezang/JSONKit\.git}, fixture('integration/JSONKit').to_s)
spec.gsub!(pattern, replacement) if pattern && replacement spec.gsub!(pattern, replacement) if pattern && replacement
spec spec
...@@ -434,12 +435,41 @@ module Pod ...@@ -434,12 +435,41 @@ module Pod
validator.results.map(&:to_s).first.should.match /matches non-header files \(JSONKit\.m\)/ validator.results.map(&:to_s).first.should.match /matches non-header files \(JSONKit\.m\)/
validator.result_type.should == :error validator.result_type.should == :error
end end
it 'checks presence of license file' do
file = write_podspec(stub_podspec(/.*license.*$/, '"license": "MIT",'))
validator = Validator.new(file, SourcesManager.master.map(&:url))
validator.stubs(:build_pod)
validator.stubs(:validate_url)
validator.validate
validator.results.map(&:to_s).first.should.match /Unable to find a license file/
validator.result_type.should == :warning
end
it 'checks module_map must exist if specified' do
file = write_podspec(stub_podspec(/.*source_files.*/, '"source_files": "JSONKit.*", "module_map": "JSONKit.modulemap",'))
validator = Validator.new(file, SourcesManager.master.map(&:url))
validator.stubs(:build_pod)
validator.stubs(:validate_url)
validator.validate
validator.results.map(&:to_s).first.should.match /Unable to find the specified module map file./
validator.result_type.should == :error
end
it 'checks module_map accepts only modulemaps' do
file = write_podspec(stub_podspec(/.*source_files.*/, '"source_files": "JSONKit.*", "module_map": "JSONKit.m",'))
validator = Validator.new(file, SourcesManager.master.map(&:url))
validator.stubs(:build_pod)
validator.stubs(:validate_url)
validator.validate
validator.results.map(&:to_s).first.should.match /Unexpected file extension for modulemap file \(JSONKit\.m\)/
validator.result_type.should == :error
end
end end
it 'validates a podspec with dependencies' do it 'validates a podspec with dependencies' do
podspec = stub_podspec(/.*name.*/, '"name": "ZKit",') podspec = stub_podspec(/.*name.*/, '"name": "ZKit",')
podspec.gsub!(/.*requires_arc.*/, '"dependencies": { "SBJson": [ "~> 3.2" ] }, "requires_arc": false') podspec.gsub!(/.*requires_arc.*/, '"dependencies": { "SBJson": [ "~> 3.2" ] }, "requires_arc": false')
podspec.gsub!(/.*license.*$/, '"license": "Public Domain",')
file = write_podspec(podspec, 'ZKit.podspec.json') file = write_podspec(podspec, 'ZKit.podspec.json')
spec = Specification.from_file(file) spec = Specification.from_file(file)
...@@ -504,7 +534,6 @@ module Pod ...@@ -504,7 +534,6 @@ module Pod
describe 'swift validation' do describe 'swift validation' do
def test_swiftpod def test_swiftpod
podspec = stub_podspec(/.*source_files.*/, '"source_files": "*.swift",') podspec = stub_podspec(/.*source_files.*/, '"source_files": "*.swift",')
podspec.gsub!(/.*license.*$/, '"license": "Public Domain",')
file = write_podspec(podspec) file = write_podspec(podspec)
Podfile::TargetDefinition.any_instance.stubs(:uses_frameworks?).returns(true) Podfile::TargetDefinition.any_instance.stubs(:uses_frameworks?).returns(true)
......
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