Class: XCCache::SPM::Buildable
- Inherits:
-
Object
- Object
- XCCache::SPM::Buildable
- Defined in:
- lib/xccache/spm/build.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#library_evolution ⇒ Object
(also: #library_evolution?)
readonly
Returns the value of attribute library_evolution.
-
#module_name ⇒ Object
readonly
Returns the value of attribute module_name.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#pkg_desc ⇒ Object
readonly
Returns the value of attribute pkg_desc.
-
#pkg_dir ⇒ Object
readonly
Returns the value of attribute pkg_dir.
-
#sdk ⇒ Object
readonly
Returns the value of attribute sdk.
-
#sdks ⇒ Object
readonly
Returns the value of attribute sdks.
-
#tmpdir ⇒ Object
readonly
Returns the value of attribute tmpdir.
Instance Method Summary collapse
- #build(options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ Buildable
constructor
A new instance of Buildable.
- #pkg_target ⇒ Object
- #swift_build(target: nil) ⇒ Object
- #swift_build_args ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Buildable
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/xccache/spm/build.rb', line 7 def initialize( = {}) @name = [:name] @module_name = @name.c99extidentifier @pkg_dir = Pathname([:pkg_dir] || "."). @pkg_desc = [:pkg_desc] @ctx_desc = [:ctx_desc] # Context desc, could be an umbrella or a standalone pkg @sdks = [:sdks] || [] @sdk = [:sdk] || @sdks&.first @config = [:config] || "debug" @path = [:path] @tmpdir = [:tmpdir] @library_evolution = [:library_evolution] @sdks.each { |sdk| sdk.version = @ctx_desc.platforms[sdk.platform] } if @ctx_desc end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
4 5 6 |
# File 'lib/xccache/spm/build.rb', line 4 def config @config end |
#library_evolution ⇒ Object (readonly) Also known as: library_evolution?
Returns the value of attribute library_evolution.
4 5 6 |
# File 'lib/xccache/spm/build.rb', line 4 def library_evolution @library_evolution end |
#module_name ⇒ Object (readonly)
Returns the value of attribute module_name.
4 5 6 |
# File 'lib/xccache/spm/build.rb', line 4 def module_name @module_name end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/xccache/spm/build.rb', line 4 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
4 5 6 |
# File 'lib/xccache/spm/build.rb', line 4 def path @path end |
#pkg_desc ⇒ Object (readonly)
Returns the value of attribute pkg_desc.
4 5 6 |
# File 'lib/xccache/spm/build.rb', line 4 def pkg_desc @pkg_desc end |
#pkg_dir ⇒ Object (readonly)
Returns the value of attribute pkg_dir.
4 5 6 |
# File 'lib/xccache/spm/build.rb', line 4 def pkg_dir @pkg_dir end |
#sdk ⇒ Object (readonly)
Returns the value of attribute sdk.
4 5 6 |
# File 'lib/xccache/spm/build.rb', line 4 def sdk @sdk end |
#sdks ⇒ Object (readonly)
Returns the value of attribute sdks.
4 5 6 |
# File 'lib/xccache/spm/build.rb', line 4 def sdks @sdks end |
#tmpdir ⇒ Object (readonly)
Returns the value of attribute tmpdir.
4 5 6 |
# File 'lib/xccache/spm/build.rb', line 4 def tmpdir @tmpdir end |
Instance Method Details
#build(options = {}) ⇒ Object
22 23 24 |
# File 'lib/xccache/spm/build.rb', line 22 def build( = {}) raise NotImplementedError end |
#pkg_target ⇒ Object
50 51 52 |
# File 'lib/xccache/spm/build.rb', line 50 def pkg_target @pkg_target ||= pkg_desc.get_target(name) end |
#swift_build(target: nil) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/xccache/spm/build.rb', line 26 def swift_build(target: nil) cmd = ["swift", "build"] + swift_build_args cmd << "--package-path" << pkg_dir cmd << "--target" << (target || name) cmd << "--sdk" << sdk.sdk_path sdk.swiftc_args.each { |arg| cmd << "-Xswiftc" << arg } if library_evolution? # Workaround for swiftinterface emission # https://github.com/swiftlang/swift/issues/64669#issuecomment-1535335601 cmd << "-Xswiftc" << "-enable-library-evolution" cmd << "-Xswiftc" << "-alias-module-names-in-module-interface" cmd << "-Xswiftc" << "-emit-module-interface" cmd << "-Xswiftc" << "-no-verify-emitted-module-interface" end Sh.run(cmd) end |
#swift_build_args ⇒ Object
43 44 45 46 47 48 |
# File 'lib/xccache/spm/build.rb', line 43 def swift_build_args [ "--configuration", config, "--triple", sdk.triple(with_version: true), ] end |