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