Class: Pod::JxedtPrebuildSandbox

Inherits:
Sandbox
  • Object
show all
Defined in:
lib/cocoapods-jxedt/binary/helper/prebuild_sandbox.rb

Overview

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.

Once completed the sandbox will have the following file structure:

   Pods
   |
   +-- Headers
   |   +-- Private
   |   |   +-- [Pod Name]
   |   +-- Public
   |       +-- [Pod Name]
   |
   +-- Local Podspecs
   |   +-- External Sources
   |   +-- Normal Sources
   |
   +-- Target Support Files
   |   +-- [Target Name]
   |       +-- Pods-acknowledgements.markdown
   |       +-- Pods-acknowledgements.plist
   |       +-- Pods-dummy.m
   |       +-- Pods-prefix.pch
   |       +-- Pods.xcconfig
   |
   +-- [Pod Name]
   |
   +-- Manifest.lock
   |
   +-- Pods.xcodeproj
(if installation option 'generate_multiple_pod_projects' is enabled)
   |
   +-- PodTarget1.xcodeproj
   |
  ...
   |
   +-- PodTargetN.xcodeproj

Instance Attribute Summary

Attributes inherited from Sandbox

#source_lockfile, #standard_sandbox

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Sandbox

#standard_sandbox_root

Class Method Details

.from_standard_sandbox(sandbox, sandbox_path: nil, real_path_compiler: false) ⇒ Object

Pod::Sandbox

standard_sandbox



55
56
57
58
59
60
61
62
63
# File 'lib/cocoapods-jxedt/binary/helper/prebuild_sandbox.rb', line 55

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

Instance Method Details

#clean_source_project!Object



111
112
113
114
115
116
# File 'lib/cocoapods-jxedt/binary/helper/prebuild_sandbox.rb', line 111

def clean_source_project!
  return if Jxedt.config.keep_source_project?

  sources_root.rmtree if real_path_compiler? && sources_root.exist?
  root.rmtree if root.exist?
end

#prepare_dirObject



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/cocoapods-jxedt/binary/helper/prebuild_sandbox.rb', line 78

def prepare_dir
  # clear
  root.children.each { |child| child.rmtree if '.xcodeproj' != child.extname }

  # 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

#project_pathObject



107
108
109
# File 'lib/cocoapods-jxedt/binary/helper/prebuild_sandbox.rb', line 107

def project_path
  root + 'Pods-Source.xcodeproj'
end

#real_path_compiler?Boolean

Returns:

  • (Boolean)


65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/cocoapods-jxedt/binary/helper/prebuild_sandbox.rb', line 65

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

#sources_rootObject



99
100
101
102
103
104
105
# File 'lib/cocoapods-jxedt/binary/helper/prebuild_sandbox.rb', line 99

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