Commit 75b072d6 authored by Eloy Duran's avatar Eloy Duran

Move generator code from installer to cocoapods/generator/*

parent fc033185
...@@ -20,6 +20,11 @@ module Pod ...@@ -20,6 +20,11 @@ module Pod
autoload :Pathname, 'pathname' autoload :Pathname, 'pathname'
autoload :FileList, 'cocoapods/file_list' autoload :FileList, 'cocoapods/file_list'
module Generator
autoload :BridgeSupport, 'cocoapods/generator/bridge_support'
autoload :CopyResourcesScript, 'cocoapods/generator/copy_resources_script'
end
end end
module Xcodeproj module Xcodeproj
......
module Pod
class BridgeSupportGenerator
include Config::Mixin
extend Executable
executable :gen_bridge_metadata
attr_reader :headers
def initialize(headers)
@headers = headers
end
def search_paths
@headers.map { |header| "-I '#{header.dirname}'" }.uniq
end
def save_as(pathname)
puts "==> Generating BridgeSupport metadata file at `#{pathname}'" unless config.silent?
gen_bridge_metadata %{-c "#{search_paths.join(' ')}" -o '#{pathname}' '#{headers.join("' '")}'}
end
end
end
module Pod
module Generator
class BridgeSupport
include Config::Mixin
extend Executable
executable :gen_bridge_metadata
attr_reader :headers
def initialize(headers)
@headers = headers
end
def search_paths
@headers.map { |header| "-I '#{header.dirname}'" }.uniq
end
def save_as(pathname)
puts "==> Generating BridgeSupport metadata file at `#{pathname}'" unless config.silent?
gen_bridge_metadata %{-c "#{search_paths.join(' ')}" -o '#{pathname}' '#{headers.join("' '")}'}
end
end
end
end
module Pod
module Generator
class CopyResourcesScript
CONTENT = <<EOS
#!/bin/sh
install_resource()
{
echo "cp -R ${SRCROOT}/Pods/$1 ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
cp -R ${SRCROOT}/Pods/$1 ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}
}
EOS
attr_reader :resources
# A list of files relative to the project pods root.
def initialize(resources)
@resources = resources
end
def save_as(pathname)
pathname.open('w') do |script|
script.puts CONTENT
@resources.each do |resource|
script.puts "install_resource '#{resource}'"
end
end
# TODO use File api
system("chmod +x '#{pathname}'")
end
end
end
end
...@@ -14,36 +14,6 @@ module Pod ...@@ -14,36 +14,6 @@ module Pod
end end
end end
class CopyResourcesScript
CONTENT = <<EOS
#!/bin/sh
install_resource()
{
echo "cp -R ${SRCROOT}/Pods/$1 ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
cp -R ${SRCROOT}/Pods/$1 ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}
}
EOS
attr_reader :resources
# A list of files relative to the project pods root.
def initialize(resources)
@resources = resources
end
def save_as(pathname)
pathname.open('w') do |script|
script.puts CONTENT
@resources.each do |resource|
script.puts "install_resource '#{resource}'"
end
end
# TODO use File api
system("chmod +x '#{pathname}'")
end
end
class TargetInstaller class TargetInstaller
include Config::Mixin include Config::Mixin
include Shared include Shared
...@@ -70,7 +40,7 @@ EOS ...@@ -70,7 +40,7 @@ EOS
end end
def copy_resources_script def copy_resources_script
@copy_resources_script ||= CopyResourcesScript.new(build_specifications.map do |spec| @copy_resources_script ||= Generator::CopyResourcesScript.new(build_specifications.map do |spec|
spec.expanded_resources spec.expanded_resources
end.flatten) end.flatten)
end end
...@@ -80,7 +50,7 @@ EOS ...@@ -80,7 +50,7 @@ EOS
end end
def bridge_support_generator def bridge_support_generator
BridgeSupportGenerator.new(build_specifications.map do |spec| Generator::BridgeSupport.new(build_specifications.map do |spec|
spec.header_files.map do |header| spec.header_files.map do |header|
config.project_pods_root + header config.project_pods_root + header
end end
......
require File.expand_path('../../spec_helper', __FILE__) require File.expand_path('../../../spec_helper', __FILE__)
describe "Pod::BridgeSupportGenerator" do describe "Pod::Generator::BridgeSupport" do
it "generates a metadata file with the appropriate search paths" do it "generates a metadata file with the appropriate search paths" do
headers = %w{ /some/dir/foo.h /some/dir/bar.h /some/other/dir/baz.h }.map { |h| Pathname.new(h) } headers = %w{ /some/dir/foo.h /some/dir/bar.h /some/other/dir/baz.h }.map { |h| Pathname.new(h) }
generator = Pod::BridgeSupportGenerator.new(headers) generator = Pod::Generator::BridgeSupport.new(headers)
def generator.gen_bridge_metadata(command) def generator.gen_bridge_metadata(command)
@command = command @command = command
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