Commit 8a4f5ac0 authored by Fabio Pelosin's avatar Fabio Pelosin

[LocalSource] Initial draft.

parent b09ccf1a
...@@ -138,6 +138,8 @@ module Pod ...@@ -138,6 +138,8 @@ module Pod
GitSource.new(name, params) GitSource.new(name, params)
elsif params.key?(:podspec) elsif params.key?(:podspec)
PodspecSource.new(name, params) PodspecSource.new(name, params)
elsif params.key?(:local)
LocalSource.new(name, params)
else else
raise Informative, "Unknown external source parameters for #{name}: #{params}" raise Informative, "Unknown external source parameters for #{name}: #{params}"
end end
...@@ -211,6 +213,35 @@ module Pod ...@@ -211,6 +213,35 @@ module Pod
"from `#{@params[:podspec]}'" "from `#{@params[:podspec]}'"
end end
end end
class LocalSource < AbstractExternalSource
def pod_spec_path
root = Pathname.new(@params[:local])
path = spec_path = Dir[root + "*.podspec"].first
Pathname.new(path)
end
def copy_external_source_into_sandbox(sandbox, _)
output_path = sandbox.root + "Local Podspecs/#{name}.podspec"
output_path.dirname.mkpath
FileUtils.copy(pod_spec_path, output_path)
end
def specification_from_local(sandbox, platform)
specification_from_external(sandbox, platform)
end
def specification_from_external(sandbox, platform)
copy_external_source_into_sandbox(sandbox, platform)
spec = Specification.from_file(pod_spec_path)
spec.source = @params
spec
end
def description
"from `#{@params[:local]}'"
end
end
end end
end end
end end
...@@ -21,7 +21,11 @@ module Pod ...@@ -21,7 +21,11 @@ module Pod
@project.user_build_configurations = @podfile.user_build_configurations @project.user_build_configurations = @podfile.user_build_configurations
pods.each do |pod| pods.each do |pod|
# Add all source files to the project grouped by pod # Add all source files to the project grouped by pod
group = @project.add_pod_group(pod.name) if pod.local?
group = @project.add_local_pod_group(pod.name)
else
group = @project.add_pod_group(pod.name)
end
pod.relative_source_files.each do |path| pod.relative_source_files.each do |path|
group.files.new('path' => path.to_s) group.files.new('path' => path.to_s)
end end
...@@ -192,7 +196,11 @@ module Pod ...@@ -192,7 +196,11 @@ module Pod
specs_by_target.each do |target_definition, specs| specs_by_target.each do |target_definition, specs|
@pods_by_spec[target_definition.platform] = {} @pods_by_spec[target_definition.platform] = {}
result[target_definition] = specs.map do |spec| result[target_definition] = specs.map do |spec|
@sandbox.local_pod_for_spec(spec, target_definition.platform) if spec.local?
LocalPod::LocalSourcedPod.new(spec, sandbox, target_definition.platform)
else
@sandbox.local_pod_for_spec(spec, target_definition.platform)
end
end.uniq.compact end.uniq.compact
end end
result result
......
...@@ -98,9 +98,7 @@ module Pod ...@@ -98,9 +98,7 @@ module Pod
# the pods comes from a local source. # the pods comes from a local source.
# #
def to_s def to_s
result = top_specification.to_s top_specification.to_s
result << " [LOCAL]" if top_specification.local?
result
end end
# @return [String] The name of the Pod. # @return [String] The name of the Pod.
...@@ -142,6 +140,10 @@ module Pod ...@@ -142,6 +140,10 @@ module Pod
root.rmtree if exists? root.rmtree if exists?
end end
def local?
false
end
# @!group Cleaning # @!group Cleaning
# Deletes any path that is not used by the pod. # Deletes any path that is not used by the pod.
...@@ -501,5 +503,39 @@ module Pod ...@@ -501,5 +503,39 @@ module Pod
Pathname.glob(pattern, File::FNM_CASEFOLD) Pathname.glob(pattern, File::FNM_CASEFOLD)
end.flatten end.flatten
end end
# A {LocalSourcedPod} is a {LocalPod} that interacts with the files of
# a folder controlled by the users. As such this class does not alter
# in any way the contents of the folder.
#
class LocalSourcedPod < LocalPod
def downloaded?
true
end
def create
# No ops
end
def root
Pathname.new(@top_specification.defined_in_file).dirname
end
def implode
# No ops
end
def clean!
# No ops
end
def to_s
super + " [LOCAL]"
end
def local?
true
end
end
end end
end end
...@@ -39,6 +39,12 @@ module Pod ...@@ -39,6 +39,12 @@ module Pod
pods.groups.new('name' => name) pods.groups.new('name' => name)
end end
# Adds a group as child to the `Local Pods' group.
def add_local_pod_group(name)
local_pods = groups.find { |g| g.name == 'Local Pods' } || groups.new({ 'name' => 'Local Pods' })
local_pods.groups.new('name' => name)
end
def add_pod_target(name, platform) def add_pod_target(name, platform)
target = targets.new_static_library(platform.name, name) target = targets.new_static_library(platform.name, name)
......
...@@ -389,10 +389,6 @@ module Pod ...@@ -389,10 +389,6 @@ module Pod
!source.nil? && !source[:local].nil? !source.nil? && !source[:local].nil?
end end
def local_path
Pathname.new(File.expand_path(source[:local]))
end
def pod_destroot def pod_destroot
if local? if local?
local_path local_path
......
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