Class: RbSys::ToolchainInfo
- Inherits:
-
Object
- Object
- RbSys::ToolchainInfo
- Defined in:
- lib/rb_sys/toolchain_info.rb,
lib/rb_sys/toolchain_info/data.rb
Overview
A class to get information about the Rust toolchains, and how they map to Ruby platforms.
Instance Attribute Summary collapse
-
#docker_platform ⇒ Object
readonly
Returns the value of attribute docker_platform.
-
#gem_platform ⇒ Object
readonly
Returns the value of attribute gem_platform.
-
#platform ⇒ Object
readonly
Returns the value of attribute platform.
-
#rake_compiler_dock_cc ⇒ Object
readonly
Returns the value of attribute rake_compiler_dock_cc.
-
#rake_compiler_dock_image ⇒ Object
readonly
Returns the value of attribute rake_compiler_dock_image.
-
#rust_target ⇒ Object
readonly
Returns the value of attribute rust_target.
-
#supported ⇒ Object
readonly
Returns the value of attribute supported.
Class Method Summary collapse
-
.all ⇒ Array<RbSys::ToolchainInfo>
Get all known toolchains.
-
.local ⇒ RbSys::ToolchainInfo
Get the toolchain for the current platform.
-
.supported ⇒ Array<RbSys::ToolchainInfo>
Get all supported toolchains.
-
.supported_ruby_platforms ⇒ Array<String>
Get all supported toolchain names, as strings.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
Compare two toolchains.
-
#initialize(platform) ⇒ ToolchainInfo
constructor
Create a new toolchain info object.
-
#supported? ⇒ Boolean
Whether this toolchain is supported.
-
#to_s ⇒ String
String representation of the toolchain.
Constructor Details
#initialize(platform) ⇒ ToolchainInfo
Create a new toolchain info object.
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/rb_sys/toolchain_info.rb', line 49 def initialize(platform) @platform = platform @gem_platform = Gem::Platform.new(platform) data = DATA[platform] || DATA["#{gem_platform.cpu}-#{gem_platform.os}"] || raise(ArgumentError, "unknown ruby platform: #{platform.inspect}") @rust_target = data["rust-target"] @rake_compiler_dock_cc = data["rake-compiler-dock"]["cc"] @supported = data["supported"] @rake_compiler_dock_image = "rbsys/#{platform}:#{RbSys::VERSION}" @docker_platform = data["docker-platform"] end |
Instance Attribute Details
#docker_platform ⇒ Object (readonly)
Returns the value of attribute docker_platform.
14 15 16 |
# File 'lib/rb_sys/toolchain_info.rb', line 14 def docker_platform @docker_platform end |
#gem_platform ⇒ Object (readonly)
Returns the value of attribute gem_platform.
14 15 16 |
# File 'lib/rb_sys/toolchain_info.rb', line 14 def gem_platform @gem_platform end |
#platform ⇒ Object (readonly)
Returns the value of attribute platform.
14 15 16 |
# File 'lib/rb_sys/toolchain_info.rb', line 14 def platform @platform end |
#rake_compiler_dock_cc ⇒ Object (readonly)
Returns the value of attribute rake_compiler_dock_cc.
14 15 16 |
# File 'lib/rb_sys/toolchain_info.rb', line 14 def rake_compiler_dock_cc @rake_compiler_dock_cc end |
#rake_compiler_dock_image ⇒ Object (readonly)
Returns the value of attribute rake_compiler_dock_image.
14 15 16 |
# File 'lib/rb_sys/toolchain_info.rb', line 14 def rake_compiler_dock_image @rake_compiler_dock_image end |
#rust_target ⇒ Object (readonly)
Returns the value of attribute rust_target.
14 15 16 |
# File 'lib/rb_sys/toolchain_info.rb', line 14 def rust_target @rust_target end |
#supported ⇒ Object (readonly)
Returns the value of attribute supported.
14 15 16 |
# File 'lib/rb_sys/toolchain_info.rb', line 14 def supported @supported end |
Class Method Details
.all ⇒ Array<RbSys::ToolchainInfo>
Get all known toolchains.
20 21 22 |
# File 'lib/rb_sys/toolchain_info.rb', line 20 def all @all ||= DATA.keys.map { |k| new(k) } end |
.local ⇒ RbSys::ToolchainInfo
Get the toolchain for the current platform.
41 42 43 |
# File 'lib/rb_sys/toolchain_info.rb', line 41 def local @current ||= new(RbConfig::CONFIG["arch"]) end |
.supported ⇒ Array<RbSys::ToolchainInfo>
Get all supported toolchains.
27 28 29 |
# File 'lib/rb_sys/toolchain_info.rb', line 27 def supported @supported ||= all.select(&:supported?) end |
.supported_ruby_platforms ⇒ Array<String>
Get all supported toolchain names, as strings.
34 35 36 |
# File 'lib/rb_sys/toolchain_info.rb', line 34 def supported_ruby_platforms supported.map(&:platform) end |
Instance Method Details
#==(other) ⇒ Boolean
Compare two toolchains.
78 79 80 |
# File 'lib/rb_sys/toolchain_info.rb', line 78 def ==(other) @gem_platform == other.gem_platform end |
#supported? ⇒ Boolean
Whether this toolchain is supported.
63 64 65 |
# File 'lib/rb_sys/toolchain_info.rb', line 63 def supported? @supported end |
#to_s ⇒ String
String representation of the toolchain.
70 71 72 |
# File 'lib/rb_sys/toolchain_info.rb', line 70 def to_s "#{gem_platform.cpu}-#{gem_platform.os}" end |