Class: PodAlexandria::FrameworkCache
- Inherits:
-
Object
- Object
- PodAlexandria::FrameworkCache
- Defined in:
- lib/cocoapods-alexandria/rome/framework_cache.rb
Instance Attribute Summary collapse
-
#build_dir ⇒ Object
readonly
Returns the value of attribute build_dir.
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
-
#destination ⇒ Object
readonly
Returns the value of attribute destination.
-
#flags ⇒ Object
readonly
Returns the value of attribute flags.
-
#project_dir ⇒ Object
readonly
Returns the value of attribute project_dir.
-
#sandbox ⇒ Object
readonly
Returns the value of attribute sandbox.
-
#sandbox_root ⇒ Object
readonly
Returns the value of attribute sandbox_root.
-
#umbrella_targets ⇒ Object
readonly
Returns the value of attribute umbrella_targets.
Instance Method Summary collapse
- #build_frameworks ⇒ Object
- #cache_lockfile ⇒ Object
- #cached_podfile_lock ⇒ Object
- #delete_changed_frameworks ⇒ Object
-
#initialize(installer_context) ⇒ FrameworkCache
constructor
A new instance of FrameworkCache.
- #podfile_lock ⇒ Object
Constructor Details
#initialize(installer_context) ⇒ FrameworkCache
Returns a new instance of FrameworkCache.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/cocoapods-alexandria/rome/framework_cache.rb', line 5 def initialize(installer_context) @configuration = 'Release' @flags = [] @sandbox_root = Pathname(installer_context.sandbox_root) @sandbox = Pod::Sandbox.new(sandbox_root) @project_dir = sandbox_root.parent @build_dir = project_dir + 'build' @destination = project_dir + 'Rome' @umbrella_targets = installer_context.umbrella_targets end |
Instance Attribute Details
#build_dir ⇒ Object (readonly)
Returns the value of attribute build_dir.
3 4 5 |
# File 'lib/cocoapods-alexandria/rome/framework_cache.rb', line 3 def build_dir @build_dir end |
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
3 4 5 |
# File 'lib/cocoapods-alexandria/rome/framework_cache.rb', line 3 def configuration @configuration end |
#destination ⇒ Object (readonly)
Returns the value of attribute destination.
3 4 5 |
# File 'lib/cocoapods-alexandria/rome/framework_cache.rb', line 3 def destination @destination end |
#flags ⇒ Object (readonly)
Returns the value of attribute flags.
3 4 5 |
# File 'lib/cocoapods-alexandria/rome/framework_cache.rb', line 3 def flags @flags end |
#project_dir ⇒ Object (readonly)
Returns the value of attribute project_dir.
3 4 5 |
# File 'lib/cocoapods-alexandria/rome/framework_cache.rb', line 3 def project_dir @project_dir end |
#sandbox ⇒ Object (readonly)
Returns the value of attribute sandbox.
3 4 5 |
# File 'lib/cocoapods-alexandria/rome/framework_cache.rb', line 3 def sandbox @sandbox end |
#sandbox_root ⇒ Object (readonly)
Returns the value of attribute sandbox_root.
3 4 5 |
# File 'lib/cocoapods-alexandria/rome/framework_cache.rb', line 3 def sandbox_root @sandbox_root end |
#umbrella_targets ⇒ Object (readonly)
Returns the value of attribute umbrella_targets.
3 4 5 |
# File 'lib/cocoapods-alexandria/rome/framework_cache.rb', line 3 def umbrella_targets @umbrella_targets end |
Instance Method Details
#build_frameworks ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/cocoapods-alexandria/rome/framework_cache.rb', line 48 def build_frameworks compiler = Compiler.new(sandbox, build_dir, destination, configuration, flags) frameworks = umbrella_targets.select { |t| t.specs.any? }.flat_map { |target| compiler.build(target) }.uniq Pod::UI.info "🔥 Built #{frameworks.count} #{'frameworks'.pluralize(frameworks.count)}" unless frameworks.empty? FileUtils.mkdir_p destination collect_files(frameworks).each do |file| FileUtils.cp_r file, destination, :remove_destination => true end build_dir.rmtree if build_dir.directory? end |
#cache_lockfile ⇒ Object
64 65 66 67 68 69 70 71 72 |
# File 'lib/cocoapods-alexandria/rome/framework_cache.rb', line 64 def cache_lockfile if podfile_lock.exists? Pod::UI.info "Caching new Podfile.lock" podfile_lock.copy_to(cached_podfile_lock) else Pod::UI.info "Deleting cached Podfile.lock" cached_podfile_lock.delete end end |
#cached_podfile_lock ⇒ Object
20 21 22 |
# File 'lib/cocoapods-alexandria/rome/framework_cache.rb', line 20 def cached_podfile_lock @cached_podfile_lock ||= Lockfile.new(sandbox_root + 'Rome-Podfile.lock') end |
#delete_changed_frameworks ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/cocoapods-alexandria/rome/framework_cache.rb', line 24 def delete_changed_frameworks # if first run (no cache), make sure we nuke partials if !cached_podfile_lock.exists? Pod::UI.info 'No cached lockfile, deleting all cached frameworks' delete_all return end # return early if identical return unless podfile_lock.exists? and cached_podfile_lock.exists? if podfile_lock.matches? cached_podfile_lock Pod::UI.info 'Podfile.lock did not change, leaving frameworks as is' return end Pod::UI.info '⚠️ Podfile.lock did change, deleting updated frameworks' changed = podfile_lock.changed_specs(cached_podfile_lock) affected = podfile_lock.specs_affected_by(changed) # delete affected frameworks Pod::UI.info "Affected frameworks: #{affected.sort.join(', ')}" unless affected.empty? affected.each { |pod| delete(pod) } end |