Skip to content

Commit

Permalink
Merge branch 'chris.thuyen/prebuild_all_vendor_pods' into 'master'
Browse files Browse the repository at this point in the history
chore(*): support option to prebuild all vendor pods

See merge request mobile/dax-ios/cocoapods-binary-cache!10
  • Loading branch information
christhuyenatgrab committed Apr 15, 2020
2 parents f159cbf + 0338a48 commit 1bc2b9c
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 12 deletions.
27 changes: 20 additions & 7 deletions lib/cocoapods-binary-cache/pod-binary/Prebuild.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,19 @@ def prebuild_pods_changes
@prebuild_pods_changes
end

def should_not_prebuild(lib_name)
Pod::Podfile::DSL.unbuilt_pods.include?(lib_name) ||
Prebuild::CacheInfo.cache_hit_vendor_pods.include?(lib_name) ||
Prebuild::CacheInfo.cache_hit_dev_pods_dic.include?(lib_name)
def blacklisted?(name)
Pod::Podfile::DSL.unbuilt_pods.include?(name)
end

def cache_hit?(name)
Prebuild::CacheInfo.cache_hit_vendor_pods.include?(name) ||
Prebuild::CacheInfo.cache_hit_dev_pods_dic.include?(name)
end

def should_not_prebuild_vendor_pod(name)
return true if blacklisted?(name)
return false if Pod::Podfile::DSL.prebuild_all_vendor_pods
cache_hit?(name)
end

public
Expand Down Expand Up @@ -71,7 +80,7 @@ def have_exact_prebuild_cache?
if Pod::Podfile::DSL.enable_prebuild_dev_pod && Pod::Podfile::DSL.is_prebuild_job
needed += Pod::Prebuild::CacheInfo.cache_miss_dev_pods_dic.keys
end
needed = needed.reject { |name| should_not_prebuild(name) }
needed = needed.reject { |name| blacklisted?(name) || cache_hit?(name) }
UI.puts "Need to rebuild: #{needed.count} #{needed}"
return needed.empty?
end
Expand All @@ -95,7 +104,10 @@ def prebuild_frameworks!
bitcode_enabled = Pod::Podfile::DSL.bitcode_enabled
targets = []

if local_manifest != nil
if Pod::Podfile::DSL.prebuild_all_vendor_pods
UI.puts "Rebuild all vendor frameworks"
targets = self.pod_targets
elsif local_manifest != nil
UI.puts "Update some frameworks"
changes = prebuild_pods_changes
added = changes.added
Expand Down Expand Up @@ -133,7 +145,8 @@ def prebuild_frameworks!
UI.puts "Rebuild all frameworks"
targets = self.pod_targets
end
targets = targets.reject { |pod_target| should_not_prebuild(pod_target.name) }

targets = targets.reject { |pod_target| should_not_prebuild_vendor_pod(pod_target.name) }
if !Podfile::DSL.enable_prebuild_dev_pod
targets = targets.reject {|pod_target| sandbox.local?(pod_target.pod_name) }
end
Expand Down
7 changes: 7 additions & 0 deletions lib/cocoapods-binary-cache/pod-binary/prebuild_dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ def set_custom_xcodebuild_options_for_prebuilt_frameworks(options)
end
end

def prebuild_all_vendor_pods!
DSL.prebuild_all_vendor_pods = true
end

def enable_devpod_prebuild
DSL.enable_prebuild_dev_pod = true
end
Expand Down Expand Up @@ -104,6 +108,9 @@ def self.set_ignore_checksum_files(file_names)

private

class_attr_accessor :prebuild_all_vendor_pods
self.prebuild_all_vendor_pods = false

class_attr_accessor :enable_prebuild_dev_pod
self.enable_prebuild_dev_pod = false

Expand Down
18 changes: 13 additions & 5 deletions lib/cocoapods-binary-cache/pod-binary/prebuild_hook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,24 @@
end

binary_installer.clean_delta_file
if (binary_installer.have_exact_prebuild_cache? && !update) # If not in prebuild job, we never rebuild and just use cache
Pod::UI.puts "cache hit"
binary_installer.install_when_cache_hit!
else
Pod::UI.puts "cache miss -> need to update"

installer_exec = lambda do
binary_installer.update = update
binary_installer.repo_update = repo_update
binary_installer.install!
end

if Pod::Podfile::DSL.prebuild_all_vendor_pods
Pod::UI.puts "Prebuild all vendor pods"
installer_exec.call
elsif (binary_installer.have_exact_prebuild_cache? && !update) # If not in prebuild job, we never rebuild and just use cache
Pod::UI.puts "Cache hit"
binary_installer.install_when_cache_hit!
else
Pod::UI.puts "Cache miss -> need to update"
installer_exec.call
end

# reset the environment
Pod.is_prebuild_stage = false
Pod::Installer.force_disable_integration false
Expand Down

0 comments on commit 1bc2b9c

Please sign in to comment.