Class: XCCache::SPM::Package
- Inherits:
-
Object
- Object
- XCCache::SPM::Package
- Includes:
- Cacheable
- Defined in:
- lib/xccache/spm/desc/dep.rb,
lib/xccache/spm/pkg/base.rb,
lib/xccache/spm/desc/base.rb,
lib/xccache/spm/desc/desc.rb,
lib/xccache/spm/desc/target.rb,
lib/xccache/spm/desc/product.rb,
lib/xccache/spm/pkg/umbrella.rb,
lib/xccache/spm/pkg/umbrella/viz.rb,
lib/xccache/spm/desc/target/macro.rb,
lib/xccache/spm/desc/target/binary.rb,
lib/xccache/spm/pkg/umbrella/build.rb,
lib/xccache/spm/pkg/umbrella/descs.rb,
lib/xccache/spm/pkg/umbrella/cachemap.rb,
lib/xccache/spm/pkg/umbrella/manifest.rb,
lib/xccache/spm/pkg/umbrella/xcconfigs.rb
Direct Known Subclasses
Defined Under Namespace
Modules: UmbrellaBuildMixin, UmbrellaCachemapMixin, UmbrellaDescsMixin, UmbrellaManifestMixin, UmbrellaVizMixin, UmbrellaXCConfigsMixin Classes: BaseObject, BinaryTarget, Dependency, Description, MacroTarget, Product, Target, Umbrella
Instance Attribute Summary collapse
-
#root_dir ⇒ Object
readonly
Returns the value of attribute root_dir.
Instance Method Summary collapse
- #build(options = {}) ⇒ Object
- #build_target(target: nil, sdks: nil, config: nil, out_dir: nil, **options) ⇒ Object
-
#initialize(options = {}) ⇒ Package
constructor
A new instance of Package.
- #resolve(force: false) ⇒ Object
Methods included from Cacheable
#__cacheable_module_name, #cacheable, included
Constructor Details
Instance Attribute Details
#root_dir ⇒ Object (readonly)
Returns the value of attribute root_dir.
13 14 15 |
# File 'lib/xccache/spm/pkg/base.rb', line 13 def root_dir @root_dir end |
Instance Method Details
#build(options = {}) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/xccache/spm/pkg/base.rb', line 20 def build( = {}) validate! targets = .delete(:targets) || [] raise GeneralError, "No targets were specified" if targets.empty? targets.map { |t| t.split("/")[-1] }.each_with_index do |t, i| UI.section("\n▶ Building target: #{t} (#{i + 1}/#{targets.count})".bold.magenta) do build_target(**, target: t) rescue StandardError => e UI.error("Failed to build target: #{t}. Error: #{e}") raise e unless Config.instance.ignore_build_errors? end end end |
#build_target(target: nil, sdks: nil, config: nil, out_dir: nil, **options) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/xccache/spm/pkg/base.rb', line 35 def build_target(target: nil, sdks: nil, config: nil, out_dir: nil, **) target_pkg_desc = pkg_desc_of_target(target, skip_resolving_dependencies: [:skip_resolving_dependencies]) if target_pkg_desc.binary_targets.any? { |t| t.name == target } return UI.warn("Target #{target} is a binary target -> no need to build") end target = target_pkg_desc.get_target(target) out_dir = Pathname(out_dir || ".") out_dir /= target.name if [:checksum] basename = [:checksum] ? "#{target.name}-#{target.checksum}" : target.name basename += target.macro? ? ".macro" : ".xcframework" Dir.create_tmpdir do |_tmpdir| cls = target.macro? ? Macro : XCFramework cls.new( name: target.name, pkg_dir: root_dir, config: config, sdks: sdks, path: out_dir / basename, tmpdir: Dir.create_tmpdir, pkg_desc: target_pkg_desc, library_evolution: [:library_evolution], ).build(**) end end |
#resolve(force: false) ⇒ Object
63 64 65 66 67 68 69 70 |
# File 'lib/xccache/spm/pkg/base.rb', line 63 def resolve(force: false) return if @resolved && !force UI.section("Resolving package dependencies (package: #{root_dir.basename})", timing: true) do Sh.run("swift package resolve --package-path #{root_dir} 2>&1") end @resolved = true end |