Class: XCCache::SPM::Package::Proxy
- Inherits:
-
XCCache::SPM::Package
- Object
- XCCache::SPM::Package
- XCCache::SPM::Package::Proxy
- Includes:
- Mixin
- Defined in:
- lib/xccache/spm/pkg/proxy.rb,
lib/xccache/spm/pkg/proxy_executable.rb
Defined Under Namespace
Modules: Mixin Classes: Executable
Instance Attribute Summary
Attributes inherited from XCCache::SPM::Package
Instance Method Summary collapse
- #gen_proxy ⇒ Object
- #graph ⇒ Object
- #invalidate_cache(sdks: []) ⇒ Object
- #prepare(options = {}) ⇒ Object
- #umbrella ⇒ Object
Methods included from Mixin
Methods inherited from XCCache::SPM::Package
#build, #build_target, #get_target, #initialize, #pkg_desc, #pkg_desc_of_target, #resolve
Methods included from Cacheable
#__cacheable_module_name, #cacheable, included
Methods included from Config::Mixin
Constructor Details
This class inherits a constructor from XCCache::SPM::Package
Instance Method Details
#gen_proxy ⇒ Object
27 28 29 30 |
# File 'lib/xccache/spm/pkg/proxy.rb', line 27 def gen_proxy xccache_proxy.run("gen-proxy") config.cachemap.update_from_graph(graph.reload) end |
#graph ⇒ Object
54 55 56 |
# File 'lib/xccache/spm/pkg/proxy.rb', line 54 def graph @graph ||= JSONRepresentable.new(root_dir / "graph.json") end |
#invalidate_cache(sdks: []) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/xccache/spm/pkg/proxy.rb', line 32 def invalidate_cache(sdks: []) UI.("Invalidating cache (sdks: #{sdks.map(&:to_s).join(', ')})") config.spm_cache_dir.glob("*/*.{xcframework,macro}").each do |p| cmps = p.basename(".*").to_s.split("-") name, checksum = cmps[...-1].join("-"), cmps[-1] p_without_checksum = config.spm_binaries_dir / name / "#{name}#{p.extname}" accept_cache = proc { p.symlink_to(p_without_checksum) } reject_cache = proc { p_without_checksum.rmtree if p_without_checksum.exist? } next reject_cache.call if (target = umbrella.get_target(name)).nil? next reject_cache.call if target.checksum != checksum # For macro, we just need the tool binary to exist next accept_cache.call if target.macro? # For regular targets, the xcframework must satisfy the sdk constraints (ie. containing all the slices) = XCFramework::Metadata.new(p / "Info.plist") expected_triples = sdks.map { |sdk| sdk.triple(with_vendor: false) } missing_triples = expected_triples - .triples missing_triples.empty? ? accept_cache.call : reject_cache.call end end |
#prepare(options = {}) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/xccache/spm/pkg/proxy.rb', line 20 def prepare( = {}) xccache_proxy.run("gen-umbrella") umbrella.resolve invalidate_cache(sdks: [:sdks]) gen_proxy end |