Commit bdab2f83 authored by Fabio Pelosin's avatar Fabio Pelosin

[#179] Support for :local pods outside the sanbox

parent c3bb9a1f
...@@ -2,19 +2,23 @@ module Pod ...@@ -2,19 +2,23 @@ module Pod
class LocalPod class LocalPod
attr_reader :specification attr_reader :specification
attr_reader :sandbox attr_reader :sandbox
def initialize(specification, sandbox) def initialize(specification, sandbox)
@specification, @sandbox = specification, sandbox @specification, @sandbox = specification, sandbox
end end
def self.from_podspec(podspec, sandbox) def self.from_podspec(podspec, sandbox)
new(Specification.from_file(podspec), sandbox) new(Specification.from_file(podspec), sandbox)
end end
def root def root
@sandbox.root + specification.name if !specification.local?
@sandbox.root + specification.name
else
specification.local_path
end
end end
def to_s def to_s
if specification.local? if specification.local?
"#{specification} [LOCAL]" "#{specification} [LOCAL]"
...@@ -22,44 +26,44 @@ module Pod ...@@ -22,44 +26,44 @@ module Pod
specification.to_s specification.to_s
end end
end end
def name def name
specification.name specification.name
end end
def create def create
root.mkpath unless exists? root.mkpath unless exists?
end end
def exists? def exists?
root.exist? root.exist?
end end
def chdir(&block) def chdir(&block)
create create
Dir.chdir(root, &block) Dir.chdir(root, &block)
end end
def implode def implode
root.rmtree if exists? root.rmtree if exists?
end end
def clean def clean
clean_paths.each { |path| FileUtils.rm_rf(path) } clean_paths.each { |path| FileUtils.rm_rf(path) }
end end
def source_files def source_files
expanded_paths(specification.source_files, :glob => '*.{h,m,mm,c,cpp}', :relative_to_sandbox => true) expanded_paths(specification.source_files, :glob => '*.{h,m,mm,c,cpp}', :relative_to_sandbox => true)
end end
def absolute_source_files def absolute_source_files
expanded_paths(specification.source_files, :glob => '*.{h,m,mm,c,cpp}') expanded_paths(specification.source_files, :glob => '*.{h,m,mm,c,cpp}')
end end
def clean_paths def clean_paths
expanded_paths(specification.clean_paths) expanded_paths(specification.clean_paths)
end end
def resources def resources
expanded_paths(specification.resources, :relative_to_sandbox => true) expanded_paths(specification.resources, :relative_to_sandbox => true)
end end
...@@ -67,33 +71,33 @@ module Pod ...@@ -67,33 +71,33 @@ module Pod
def header_files def header_files
source_files.select { |f| f.extname == '.h' } source_files.select { |f| f.extname == '.h' }
end end
def link_headers def link_headers
copy_header_mappings.each do |namespaced_path, files| copy_header_mappings.each do |namespaced_path, files|
@sandbox.add_header_files(namespaced_path, files) @sandbox.add_header_files(namespaced_path, files)
end end
end end
def add_to_target(target) def add_to_target(target)
implementation_files.each do |file| implementation_files.each do |file|
target.add_source_file(file, nil, specification.compiler_flags) target.add_source_file(file, nil, specification.compiler_flags)
end end
end end
def requires_arc? def requires_arc?
specification.requires_arc specification.requires_arc
end end
private private
def implementation_files def implementation_files
source_files.select { |f| f.extname != '.h' } source_files.select { |f| f.extname != '.h' }
end end
def relative_root def relative_root
root.relative_path_from(@sandbox.root) root.relative_path_from(@sandbox.root)
end end
def copy_header_mappings def copy_header_mappings
header_files.inject({}) do |mappings, from| header_files.inject({}) do |mappings, from|
from_without_prefix = from.relative_path_from(relative_root) from_without_prefix = from.relative_path_from(relative_root)
...@@ -102,15 +106,15 @@ module Pod ...@@ -102,15 +106,15 @@ module Pod
mappings mappings
end end
end end
def expanded_paths(patterns, options={}) def expanded_paths(patterns, options={})
patterns.map do |pattern| patterns.map do |pattern|
pattern = root + pattern pattern = root + pattern
if pattern.directory? && options[:glob] if pattern.directory? && options[:glob]
pattern += options[:glob] pattern += options[:glob]
end end
pattern.glob.map do |file| pattern.glob.map do |file|
if options[:relative_to_sandbox] if options[:relative_to_sandbox]
file.relative_path_from(@sandbox.root) file.relative_path_from(@sandbox.root)
......
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