lib/cocoapods-jxedt/binary/helper/prebuild_sandbox.rb in cocoapods-jxedt-0.0.13 vs lib/cocoapods-jxedt/binary/helper/prebuild_sandbox.rb in cocoapods-jxedt-0.0.14
- old
+ new
@@ -1,6 +1,15 @@
module Pod
+ class Sandbox
+ attr_accessor :standard_sandbox
+
+ def standard_sandbox_root
+ return root if standard_sandbox.nil?
+ standard_sandbox.root
+ end
+ end
+
# The sandbox provides support for the directory that CocoaPods uses for an
# installation. In this directory the Pods projects, the support files and
# the sources of the Pods are stored.
#
# CocoaPods assumes to have control of the sandbox.
@@ -39,64 +48,73 @@
# ...
# |
# +-- PodTargetN.xcodeproj
#
#
- class PrebuildSandbox < Sandbox
- # [String] standard_sandbox_path
- def self.from_standard_sandbox_path(path)
- prebuild_sandbox_path = Pathname.new(path).realpath
- new(prebuild_sandbox_path)
+ class JxedtPrebuildSandbox < Sandbox
+ # [Pod::Sandbox] standard_sandbox
+ def self.from_standard_sandbox(sandbox, sandbox_path: nil, real_path_compiler: false)
+ prebuild_sandbox_path = Pathname.new(sandbox.root).realpath + '../Pods-Source'
+ prebuild_sandbox = new(prebuild_sandbox_path)
+ # initialize
+ prebuild_sandbox.standard_sandbox = sandbox
+ # prepare
+ prebuild_sandbox.prepare_dir
+ prebuild_sandbox
end
- def self.from_standard_sandbox(sandbox)
- from_standard_sandbox_path(sandbox.root)
+ def real_path_compiler?
+ @real_path_compiler ||= begin
+ prebuild_sandbox_path = Jxedt.config.prebuild_sandbox_path
+ real_path_compiler = prebuild_sandbox_path && prebuild_sandbox_path.length > 0
+ if real_path_compiler
+ prebuild_sources_root = Pathname.new(prebuild_sandbox_path)
+ prebuild_sources_root.rmtree if prebuild_sources_root.exist?
+ prebuild_sources_root.mkpath
+ end
+ real_path_compiler
+ end
end
- def make_source_link(source, target)
- source = Pathname.new(source)
- target = Pathname.new(target)
- target.parent.mkpath unless target.parent.exist?
- target.rmtree if target.exist?
- relative_source = source.relative_path_from(target.parent)
- FileUtils.ln_sf(relative_source, target)
- end
+ def prepare_dir
+ # clear
+ root.children.each { |child| child.rmtree if '.xcodeproj' != child.extname }
- def source_path
- '../Pods-Source'
+ # copy
+ standard_sandbox.root.children.each do |child|
+ # skip headers_root & target_support_files_root & project_path
+ should_skip_paths = [standard_sandbox.headers_root, standard_sandbox.target_support_files_root, standard_sandbox.project_path]
+ next if should_skip_paths.include?(child)
+
+ should_copy_paths = [standard_sandbox.specifications_root, standard_sandbox.manifest_path]
+ if should_copy_paths.include?(child)
+ # copy Local Podspecs & manifest path
+ FileUtils.cp_r(child, root + child.basename)
+ else
+ # 真实的路径去编译,则拷贝文件到prebuild_sandbox
+ FileUtils.cp_r(child, sources_root) if real_path_compiler?
+ end
+ end
end
- def headers_root
- root + source_path + 'Headers'
+ def sources_root
+ if real_path_compiler?
+ # 真实的路径去编译,则返回prebuild sources root
+ return @prebuild_sources_root ||= Pathname.new(Jxedt.config.prebuild_sandbox_path)
+ end
+ standard_sandbox.root
end
def project_path
- root + source_path + 'Pods-Source.xcodeproj'
+ root + 'Pods-Source.xcodeproj'
end
- def specifications_root
- # root + source_path + 'Local Podspecs'
- super
- end
-
- def target_support_files_root
- root + source_path + 'Target Support Files'
- end
-
- def link_source_project!
- root.children.each do |child|
- next if ['Headers', 'Local Podspecs', 'Target Support Files'].include? child.basename.to_s
- next if ['.lock', '.xcodeproj'].include? child.extname.to_s
- make_source_link(child, root + source_path + child.basename)
- end
- end
-
def clean_source_project!
return if Jxedt.config.keep_source_project?
- source_project_path = root + source_path
- source_project_path.rmtree if source_project_path.exist?
+ sources_root.rmtree if sources_root.exist?
+ root.rmtree if root.exist?
end
end
end
module Pod
@@ -106,23 +124,10 @@
# projects.
#
class UserProjectIntegrator
alias_method :old_create_workspace, :create_workspace
def create_workspace
- old_create_workspace unless sandbox.is_a?(Pod::PrebuildSandbox)
- end
- end
- end
-end
-
-module Pod
- class Installer
- # Cleans up the sandbox directory by removing stale target support files and headers.
- #
- class SandboxDirCleaner
- alias_method :old_clean!, :clean!
- def clean!
- old_clean! unless @sandbox.is_a?(Pod::PrebuildSandbox)
+ old_create_workspace unless sandbox.is_a?(Pod::JxedtPrebuildSandbox)
end
end
end
end
\ No newline at end of file