Module: XCCache::SPM::Package::UmbrellaManifestMixin
- Included in:
- Umbrella
- Defined in:
- lib/xccache/spm/pkg/umbrella/manifest.rb
Instance Method Summary collapse
- #manifest_pkg_dependencies ⇒ Object
- #manifest_platforms ⇒ Object
- #manifest_products_to_targets_json(no_cache: false) ⇒ Object
- #manifest_targets_json(no_cache: false) ⇒ Object
- #write_manifest(no_cache: false) ⇒ Object
Instance Method Details
#manifest_pkg_dependencies ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/xccache/spm/pkg/umbrella/manifest.rb', line 30 def manifest_pkg_dependencies decl = proc do |hash| if (path_from_root = hash["path_from_root"]) absolute_path = (Pathname(".") / path_from_root). next ".package(path: \"#{absolute_path}\")" end requirement = hash["requirement"] case requirement["kind"] when "upToNextMajorVersion" opt = ".upToNextMajor(from: \"#{requirement['minimumVersion']}\")" when "upToNextMinorVersion" opt = ".upToNextMinor(from: \"#{requirement['minimumVersion']}\")" when "exactVersion" opt = "exact: \"#{requirement['version']}\"" when "branch" opt = "branch: \"#{requirement['branch']}\"" when "revision" opt = "revision: \"#{requirement['revision']}\"" when "versionRange" opt = "\"#{requirement['minimumVersion']}\"..<\"#{requirement['maximumVersion']}\"" end ".package(url: \"#{hash['repositoryURL']}\", #{opt})" end config.lockfile.pkgs.map { |h| " #{decl.call(h)}," }.join("\n") end |
#manifest_platforms ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/xccache/spm/pkg/umbrella/manifest.rb', line 58 def manifest_platforms @manifest_platforms ||= begin to_spm_platform = { :ios => "iOS", :macos => "macOS", :osx => "macOS", :tvos => "tvOS", :watchos => "watchOS", :visionos => "visionOS", } hash = {} config.project_targets.each do |t| platform = to_spm_platform[t.platform_name] hash[platform] ||= [] hash[platform] << t.deployment_target.split(".")[0] end hash .transform_values(&:min) .map { |platform, version| " .#{platform}(.v#{version})," } .join("\n") end end |
#manifest_products_to_targets_json(no_cache: false) ⇒ Object
25 26 27 28 |
# File 'lib/xccache/spm/pkg/umbrella/manifest.rb', line 25 def manifest_products_to_targets_json(no_cache: false) data = no_cache ? {} : config.cachemap.manifest_data["deps"] JSON.pretty_generate(data) end |
#manifest_targets_json(no_cache: false) ⇒ Object
20 21 22 23 |
# File 'lib/xccache/spm/pkg/umbrella/manifest.rb', line 20 def manifest_targets_json(no_cache: false) data = no_cache ? config.lockfile.targets_data : config.cachemap.manifest_data["targets"] JSON.pretty_generate(data) end |
#write_manifest(no_cache: false) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/xccache/spm/pkg/umbrella/manifest.rb', line 5 def write_manifest(no_cache: false) UI.info("Writing Package.swift (package: #{root_dir.basename})") Template.new("umbrella.Package.swift").render( { :timestamp => Time.new.strftime("%F %T"), :json => manifest_targets_json(no_cache: no_cache), :products_to_targets => manifest_products_to_targets_json(no_cache: no_cache), :platforms => manifest_platforms, :dependencies => manifest_pkg_dependencies, :swift_version => Swift::Swiftc.version_without_patch, }, save_to: root_dir / "Package.swift", ) end |