Skip to main content

RbConfig

Struct RbConfig 

Source
pub struct RbConfig {
    pub search_paths: Vec<SearchPath>,
    pub libs: Vec<Library>,
    pub link_args: Vec<String>,
    pub cflags: Vec<String>,
    pub blocklist_lib: Vec<String>,
    pub blocklist_link_arg: Vec<String>,
    /* private fields */
}
Expand description

Extracts structured information from raw compiler/linker flags to make compiling Ruby gems easier.

Fields§

§search_paths: Vec<SearchPath>§libs: Vec<Library>§link_args: Vec<String>§cflags: Vec<String>§blocklist_lib: Vec<String>§blocklist_link_arg: Vec<String>

Implementations§

Source§

impl RbConfig

Source

pub fn all_keys(&self) -> Keys<'_, String, String>

All keys in the RbConfig’s value map.

Source

pub fn current() -> RbConfig

Instantiates a new RbConfig for the current Ruby.

Pushes the LIBRUBYARG flags so Ruby will be linked.

Source

pub fn libruby_static_name(&self) -> String

Get the name for libruby-static (i.e. ruby.3.1-static).

Source

pub fn libruby_so_name(&self) -> String

Get the name for libruby (i.e. ruby.3.1)

Source

pub fn platform(&self) -> String

Get the platform for the current ruby.

Source

pub fn blocklist_lib(&mut self, name: &str) -> &mut RbConfig

Filter the libs, removing the ones that are not needed.

Blocklist a link argument.

Source

pub fn ruby_version_slug(&self) -> String

Returns the current ruby program version.

Source

pub fn cppflags(&self) -> Vec<String>

Get the CPPFLAGS from the RbConfig, making sure to subsitute variables.

Source

pub fn is_cross_compiling(&self) -> bool

Returns true if the current Ruby is cross compiling.

Source

pub fn validate_cargo_target(&self) -> Result<(), String>

Checks that Ruby’s C headers use the same operating-system ABI as Cargo’s target.

Bindgen can locate headers from a cross-compilation sysroot, but headers from a Ruby built for a different target are not compatible. In particular, RubyInstaller uses MinGW headers which cannot be used with Rust’s MSVC target.

Source

pub fn get(&self, key: &str) -> Option<String>

Returns the value of the given key from the either the matching RBCONFIG_{key} environment variable or RbConfig::CONFIG[{key}] hash.

Source

pub fn use_rpath(&mut self) -> &mut RbConfig

Enables the use of rpath for linking.

Source

pub fn push_cflags(&mut self, cflags: &str) -> &mut Self

Push cflags string

Source

pub fn major_minor(&self) -> Option<(u32, u32)>

Get major/minor version tuple of Ruby

Source

pub fn cargo_args(&self) -> Vec<String>

Get the rb_config output for cargo

Source

pub fn print_cargo_args(&self)

Print to rb_config output for cargo

Source

pub fn push_dldflags(&mut self, input: &str) -> &mut Self

Adds items to the rb_config based on a string from LDFLAGS/DLDFLAGS

Source

pub fn set_value_for_key(&mut self, key: &str, value: String)

Sets a value for a key

Source

pub fn has_ruby_dln_check_abi(&self) -> bool

Source

pub fn ruby_engine(&self) -> RubyEngine

The RUBY_ENGINE we are building for

Source

pub fn have_ruby_header<T: AsRef<str>>(&self, header: T) -> bool

Trait Implementations§

Source§

impl Debug for RbConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for RbConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for RbConfig

Source§

impl PartialEq for RbConfig

Source§

fn eq(&self, other: &RbConfig) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for RbConfig

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.