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.
Constant Summary collapse
- DATA =
{"arm-linux" => {"rust-target" => "arm-unknown-linux-gnueabihf", "rake-compiler-dock" => {"cc" => "arm-linux-gnueabihf-gcc"}, "docker-platform" => "linux/arm/v7", "supported" => true}, "aarch64-linux" => {"rust-target" => "aarch64-unknown-linux-gnu", "rake-compiler-dock" => {"cc" => "aarch64-linux-gnu-gcc"}, "docker-platform" => "linux/arm64/v8", "supported" => true}, "arm64-darwin" => {"rust-target" => "aarch64-apple-darwin", "rake-compiler-dock" => {"cc" => "aarch64-apple-darwin-clang"}, "docker-platform" => "linux/arm64/v8", "supported" => true}, "x64-mingw-ucrt" => {"rust-target" => "x86_64-pc-windows-gnu", "rake-compiler-dock" => {"cc" => "x86_64-windows-gnu-gcc"}, "docker-platform" => "linux/amd64", "supported" => true}, "x64-mingw32" => {"rust-target" => "x86_64-pc-windows-gnu", "rake-compiler-dock" => {"cc" => "x86_64-windows-gnu-gcc"}, "docker-platform" => "linux/amd64", "supported" => true}, "x86-linux" => {"rust-target" => "i686-unknown-linux-gnu", "rake-compiler-dock" => {"cc" => "i686-redhat-linux-gcc"}, "docker-platform" => "linux/i386", "supported" => false}, "x86-mingw32" => {"rust-target" => "i686-pc-windows-gnu", "rake-compiler-dock" => {"cc" => "i686-w64-mingw32-gcc"}, "docker-platform" => "linux/i386", "supported" => false}, "x86_64-darwin" => {"rust-target" => "x86_64-apple-darwin", "rake-compiler-dock" => {"cc" => "x86_64-apple-darwin-clang"}, "docker-platform" => "linux/amd64", "supported" => true}, "x86_64-linux" => {"rust-target" => "x86_64-unknown-linux-gnu", "rake-compiler-dock" => {"cc" => "x86_64-redhat-linux-gcc"}, "docker-platform" => "linux/amd64", "supported" => true}, "x86_64-linux-musl" => {"rust-target" => "x86_64-unknown-linux-musl", "rake-compiler-dock" => {"cc" => "x86_64-unknown-linux-musl-gcc"}, "docker-platform" => "linux/amd64", "supported" => true}}
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
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(platform) ⇒ ToolchainInfo
constructor
A new instance of ToolchainInfo.
- #supported? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(platform) ⇒ ToolchainInfo
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/rb_sys/toolchain_info.rb', line 30 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 ⇒ Object
17 18 19 |
# File 'lib/rb_sys/toolchain_info.rb', line 17 def all @all ||= DATA.keys.map { |k| new(k) } end |
.local ⇒ Object
25 26 27 |
# File 'lib/rb_sys/toolchain_info.rb', line 25 def local @current ||= new(RbConfig::CONFIG["arch"]) end |
.supported ⇒ Object
21 22 23 |
# File 'lib/rb_sys/toolchain_info.rb', line 21 def supported @supported ||= all.select(&:supported?) end |
Instance Method Details
#==(other) ⇒ Object
49 50 51 |
# File 'lib/rb_sys/toolchain_info.rb', line 49 def ==(other) @gem_platform == other.gem_platform end |
#supported? ⇒ Boolean
41 42 43 |
# File 'lib/rb_sys/toolchain_info.rb', line 41 def supported? @supported end |
#to_s ⇒ Object
45 46 47 |
# File 'lib/rb_sys/toolchain_info.rb', line 45 def to_s "#{gem_platform.cpu}-#{gem_platform.os}" end |