Class: PodBuilder::Install

Inherits:
Object
  • Object
show all
Defined in:
lib/pod_builder/install.rb

Class Method Summary collapse

Class Method Details

.podfile(podfile_content, podfile_items, build_configuration) ⇒ Object

This method will generate prebuilt data by building from “/tmp/pod_builder/Podfile”



142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# File 'lib/pod_builder/install.rb', line 142

def self.podfile(podfile_content, podfile_items, build_configuration)
  puts "Preparing build Podfile".yellow
  
  PodBuilder::safe_rm_rf(Configuration.build_path)
  FileUtils.mkdir_p(Configuration.build_path)
  
  init_git(Configuration.build_path) # this is needed to be able to call safe_rm_rf
  
  podfile_content = copy_development_pods_source_code(podfile_content, podfile_items)
  
  podfile_content = Podfile.update_path_entries(podfile_content, Install.method(:podfile_path_transform))
  podfile_content = Podfile.update_project_entries(podfile_content, Install.method(:podfile_path_transform))
  podfile_content = Podfile.update_require_entries(podfile_content, Install.method(:podfile_path_transform))
  
  podfile_path = File.join(Configuration.build_path, "Podfile")
  File.write(podfile_path, podfile_content)
  
  begin  
    lock_file = "#{Configuration.build_path}/pod_builder.lock"
    FileUtils.touch(lock_file)
    
    prebuilt_entries = use_prebuilt_entries_for_unchanged_pods(podfile_path, podfile_items)
    
    install
    
    copy_prebuilt_items(podfile_items - prebuilt_entries)   

    prebuilt_info = prebuilt_info(podfile_items)
    licenses = license_specifiers()
    
    if !OPTIONS.has_key?(:debug)
      PodBuilder::safe_rm_rf(Configuration.build_path)
    end  
    
    return InstallResult.new(licenses, prebuilt_info)
  rescue Exception => e
    if File.directory?("#{Configuration.build_path}/Pods/Pods.xcodeproj")
      activate_pod_scheme()

      if ENV["DEBUGGING"]
        system("xed #{Configuration.build_path}/Pods")  
      elsif !OPTIONS.has_key?(:no_stdin_available)
        confirm = ask("\n\nOh no! Something went wrong during prebuild phase! Do you want to open the prebuild project to debug the error, you will need to add and run the Pods-Dummy scheme? [Y/N] ".red) { |yn| yn.limit = 1, yn.validate = /[yn]/i }

        if confirm.downcase == 'y'
          system("xed #{Configuration.build_path}/Pods")  
        end
      end
    end
    
    raise e
  ensure        
    FileUtils.rm(lock_file) if File.exist?(lock_file)
  end
end

.prebuilt_info(podfile_items) ⇒ Object



198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
# File 'lib/pod_builder/install.rb', line 198

def self.prebuilt_info(podfile_items)
  gitignored_files = PodBuilder::gitignoredfiles
  
  swift_version = PodBuilder::system_swift_version

  write_prebuilt_info_filename_gitattributes
  
  ret = Hash.new
  root_names = podfile_items.reject(&:is_prebuilt).map(&:root_name).uniq
  root_names.each do |prebuilt_name| 
    path = PodBuilder::prebuiltpath(prebuilt_name)
    
    unless File.directory?(path)
      puts "Prebuilt items for #{prebuilt_name} not found".blue
      next
    end
    
    unless podfile_item = podfile_items.detect { |t| t.name == prebuilt_name } || podfile_items.detect { |t| t.root_name == prebuilt_name }
      puts "Prebuilt items for #{prebuilt_name} not found #2".blue
      next
    end
    
    podbuilder_file = File.join(path, Configuration.prebuilt_info_filename)
    entry = podfile_item.entry(true, false)
    
    data = {}
    data["entry"] = entry
    data["is_prebuilt"] = podfile_item.is_prebuilt  
    if Dir.glob(File.join(path, "#{podfile_item.prebuilt_rel_path}/Headers/*-Swift.h")).count > 0
      data["swift_version"] = swift_version
    end
    
    specs = podfile_items.select { |x| x.module_name == podfile_item.module_name }
    subspecs_deps = specs.map(&:dependency_names).flatten
    subspec_self_deps = subspecs_deps.select { |x| x.start_with?("#{prebuilt_name}/") }
    data["specs"] = (specs.map(&:name) + subspec_self_deps).uniq
    data["is_static"] = podfile_item.is_static
    data["original_compile_path"] = Pathname.new(Configuration.build_path).realpath.to_s
    if hash = build_folder_hash(podfile_item, gitignored_files)
      data["build_folder_hash"] = hash
    end
    
    ret.merge!({ podbuilder_file => data })
  end

  return ret
end