Commit 404f991d authored by Marius Rackwitz's avatar Marius Rackwitz

Generate a custom module map file

… to avoid conflicts with the generated umbrella header, which can so have by now a different path, which must be specified in the module map file, but is named by convention equal to the target product. This is often already used for pseudo umbrella header and would led to conflicts.
parent 8528146b
...@@ -59,6 +59,7 @@ module Pod ...@@ -59,6 +59,7 @@ module Pod
autoload :EmbedFrameworksScript, 'cocoapods/generator/embed_frameworks_script' autoload :EmbedFrameworksScript, 'cocoapods/generator/embed_frameworks_script'
autoload :Header, 'cocoapods/generator/header' autoload :Header, 'cocoapods/generator/header'
autoload :InfoPlistFile, 'cocoapods/generator/info_plist_file' autoload :InfoPlistFile, 'cocoapods/generator/info_plist_file'
autoload :ModuleMap, 'cocoapods/generator/module_map'
autoload :PrefixHeader, 'cocoapods/generator/prefix_header' autoload :PrefixHeader, 'cocoapods/generator/prefix_header'
autoload :TargetEnvironmentHeader, 'cocoapods/generator/target_environment_header' autoload :TargetEnvironmentHeader, 'cocoapods/generator/target_environment_header'
autoload :UmbrellaHeader, 'cocoapods/generator/umbrella_header' autoload :UmbrellaHeader, 'cocoapods/generator/umbrella_header'
......
module Pod
module Generator
# Generates the LLVM module map files. A module map file is generated for
# each Pod and for each Pod target definition, that requires to be built as
# framework. It specifies a different umbrella header then usual to avoid
# name conflicts with existing headers of the podspec.
#
class ModuleMap
# @return [Target] the target represented by this Info.plist.
#
attr_reader :target
# @param [Target] target @see target
#
def initialize(target)
@target = target
end
# Generates and saves the Info.plist to the given path.
#
# @param [Pathname] path
# the path where the prefix header should be stored.
#
# @return [void]
#
def save_as(path)
FileUtils.mkdir_p(path + '..')
contents = generate
File.open(path, 'w') do |f|
f.write(contents)
end
end
# Generates the contents of the module.modulemap file.
#
# @return [String]
#
def generate
<<-eos.strip_heredoc
framework module #{target.product_module_name} {
umbrella header "#{target.umbrella_header_path.basename}"
export *
module * { export * }
}
eos
end
end
end
end
...@@ -86,6 +86,25 @@ module Pod ...@@ -86,6 +86,25 @@ module Pod
end end
end end
# Creates the module map file which ensures that the umbrella header is
# recognized with a customized path
#
# @return [void]
#
def create_module_map
path = target.module_map_path
UI.message "- Generating module map file at #{UI.path(path)}" do
generator = Generator::ModuleMap.new(target)
generator.save_as(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
# Generates a header which ensures that all header files are exported # Generates a header which ensures that all header files are exported
# in the module map # in the module map
# #
......
...@@ -16,6 +16,7 @@ module Pod ...@@ -16,6 +16,7 @@ module Pod
create_xcconfig_file create_xcconfig_file
if target.requires_framework? if target.requires_framework?
create_info_plist_file create_info_plist_file
create_module_map
create_umbrella_header create_umbrella_header
create_embed_frameworks_script create_embed_frameworks_script
end end
......
...@@ -22,6 +22,7 @@ module Pod ...@@ -22,6 +22,7 @@ module Pod
create_xcconfig_file create_xcconfig_file
if target.requires_framework? if target.requires_framework?
create_info_plist_file create_info_plist_file
create_module_map
create_umbrella_header do |generator| create_umbrella_header do |generator|
generator.imports += target.file_accessors.map(&:public_headers).flatten.map(&:basename) generator.imports += target.file_accessors.map(&:public_headers).flatten.map(&:basename)
end end
......
...@@ -162,7 +162,14 @@ module Pod ...@@ -162,7 +162,14 @@ module Pod
# module map. # module map.
# #
def umbrella_header_path def umbrella_header_path
support_files_dir + target_definition.label + "#{product_module_name}.h" support_files_dir + "#{label}-umbrella.h"
end
# @return [Pathname] the absolute path of the LLVM module map file that
# defines the module structure for the compiler.
#
def module_map_path
support_files_dir + "#{label}.modulemap"
end end
# @return [Pathname] the absolute path of the header file which contains # @return [Pathname] the absolute path of the header file which contains
......
require File.expand_path('../../../spec_helper', __FILE__)
module Pod
describe Generator::ModuleMap do
before do
spec = fixture_spec('banana-lib/BananaLib.podspec')
target_definition = Podfile::TargetDefinition.new(:default, nil)
@pod_target = PodTarget.new([spec], target_definition, config.sandbox)
@gen = Generator::ModuleMap.new(@pod_target)
end
it 'writes the module map to the disk' do
path = temporary_directory + 'BananaLib.modulemap'
@gen.save_as(path)
path.read.should == <<-EOS.strip_heredoc
framework module BananaLib {
umbrella header "Pods-default-BananaLib-umbrella.h"
export *
module * { export * }
}
EOS
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