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 collapse

Attributes inherited from Sandbox

#source_lockfile, #standard_sandbox

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Sandbox

#standard_sandbox_root

Instance Attribute Details

#index_project_create_stageObject

Returns the value of attribute index_project_create_stage.



54
55
56
# File 'lib/cocoapods-jxedt/binary/helper/prebuild_sandbox.rb', line 54

def index_project_create_stage
  @index_project_create_stage
end

Class Method Details

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

Pod::Sandbox

standard_sandbox



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

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



120
121
122
123
124
125
# File 'lib/cocoapods-jxedt/binary/helper/prebuild_sandbox.rb', line 120

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

#index_project_nameObject



116
117
118
# File 'lib/cocoapods-jxedt/binary/helper/prebuild_sandbox.rb', line 116

def index_project_name
  return 'Pods-Index.xcodeproj'
end

#prepare_dirObject



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

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



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

def project_path
  if index_project_create_stage
    return root + index_project_name
  end
  root + 'Pods-Source.xcodeproj'
end

#real_path_compiler?Boolean

Returns:

  • (Boolean)


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

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



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

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