Commit 08b71052 authored by Eloy Duran's avatar Eloy Duran

Refactor and start on creation of static library.

parent e65536b2
......@@ -5,6 +5,7 @@ module Pod
if spec = Specification.from_podfile(podfile)
#config.clean = false
spec.install_dependent_specifications!
spec.create_static_library!
else
$stderr.puts "No Podfile found in current working directory."
end
......
......@@ -7,7 +7,6 @@ module Pod
def resolve
@sets = []
find_dependency_sets(@specification)
#@sets.reject(&:only_part_of_other_pod?).map(&:podspec)
@sets
end
......@@ -18,12 +17,8 @@ module Pod
raise "Unable to find a pod named `#{dependency.name}'"
end
sets.each do |set|
# TODO ultimately this compatibility check should be used to try and
# resolve the conflicts, but for now we'll keep it simple.
if existing_set = @sets.find { |s| s == set }
existing_set.required_by(specification, dependency)
else
set.required_by(specification, dependency)
set.required_by(specification, dependency)
unless @sets.include?(set)
@sets << set
find_dependency_sets(set.podspec)
end
......
......@@ -16,7 +16,7 @@ module Pod
def search(dependency)
if dir = @repo.children.find { |c| c.basename.to_s == dependency.name }
Specification::Set.new(dir)
Specification::Set.by_pod_dir(dir)
end
end
end
......
......@@ -82,8 +82,19 @@ module Pod
dep
end
def xcconfig(path)
@xcconfig = path
end
# Not attributes
# Returns the specification for the pod that this pod's source is a part of.
def part_of_specification
if @part_of
Set.by_specification_name(@part_of.name).podspec
end
end
# This also includes those that are only part of other specs, but are not
# actually being used themselves.
def resolved_dependent_specification_sets
......@@ -96,25 +107,38 @@ module Pod
# In case the set is only part of other pods we don't need to install
# the pod itself.
next if set.only_part_of_other_pod?
set.podspec.install!
end
end
def create_static_library!
puts "==> Creating static library"
source_files = []
resolved_dependent_specification_sets.each do |set|
# In case the set is only part of other pods we don't need to build
# the pod itself.
next if set.only_part_of_other_pod?
spec = set.podspec
spec.install!
# In case spec is part of another pod we need to dowload the other
# pod's source.
if spec.part_of_other_pod?
# Find the specification of the pod that spec's source is a part of.
part_of_name = spec.read(:part_of).name
spec = sets.find { |set| set.name == part_of_name }.podspec
spec.read(:source_files).each do |pattern|
pattern = spec.pod_destroot + pattern
pattern = pattern + '*.{m,mm,c,cpp}' if pattern.directory?
source_files.concat(Dir.glob(pattern.to_s))
end
spec.download_if_necessary!
end
#p source_files
load_paths = source_files.map { |file| File.dirname(file) }.uniq
#p load_paths
end
include Config::Mixin
def pod_destroot
config.project_pods_root + "#{@name}-#{@version}"
if part_of_other_pod?
part_of_specification.pod_destroot
else
config.project_pods_root + "#{@name}-#{@version}"
end
end
# Places the activated podspec in the project's pods directory.
......@@ -123,6 +147,10 @@ module Pod
config.project_pods_root.mkpath
require 'fileutils'
FileUtils.cp(@defined_in_file, config.project_pods_root)
# In case this spec is part of another pod's source, we need to dowload
# the other pod's source.
(spart_of_specification || self).download_if_necessary!
end
def download_if_necessary!
......
module Pod
class Specification
class Set
def self.sets
@sets ||= {}
end
def self.by_specification_name(name)
sets[name]
end
# This keeps an identity map of sets so that you always get the same Set
# instance for the same pod directory.
def self.by_pod_dir(pod_dir)
set = new(pod_dir)
sets[set.name] ||= set
sets[set.name]
end
def initialize(pod_dir)
@pod_dir = pod_dir
@required_by = []
......
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