Class: RbSys::Mkmf::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/rb_sys/mkmf/config.rb

Overview

Config that delegates to CargoBuilder if needded

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(builder) ⇒ Config

Returns a new instance of Config.



9
10
11
12
13
14
15
# File 'lib/rb_sys/mkmf/config.rb', line 9

def initialize(builder)
  @builder = builder
  @force_install_rust_toolchain = false
  @auto_install_rust_toolchain = true
  @clean_after_install = rubygems_invoked?
  @rubygems_clean_dirs = ["./cargo-vendor"]
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &blk) ⇒ Object



21
22
23
# File 'lib/rb_sys/mkmf/config.rb', line 21

def method_missing(name, *args, &blk)
  @builder.send(name, *args, &blk)
end

Instance Attribute Details

#auto_install_rust_toolchainObject

Returns the value of attribute auto_install_rust_toolchain.



7
8
9
# File 'lib/rb_sys/mkmf/config.rb', line 7

def auto_install_rust_toolchain
  @auto_install_rust_toolchain
end

#clean_after_installObject

Returns the value of attribute clean_after_install.



7
8
9
# File 'lib/rb_sys/mkmf/config.rb', line 7

def clean_after_install
  @clean_after_install
end

#force_install_rust_toolchainObject

Returns the value of attribute force_install_rust_toolchain.



7
8
9
# File 'lib/rb_sys/mkmf/config.rb', line 7

def force_install_rust_toolchain
  @force_install_rust_toolchain
end

#rubygems_clean_dirsObject

Returns the value of attribute rubygems_clean_dirs.



7
8
9
# File 'lib/rb_sys/mkmf/config.rb', line 7

def rubygems_clean_dirs
  @rubygems_clean_dirs
end

#target_dirObject

Returns the value of attribute target_dir.



7
8
9
# File 'lib/rb_sys/mkmf/config.rb', line 7

def target_dir
  @target_dir
end

Instance Method Details

#cross_compiling?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/rb_sys/mkmf/config.rb', line 17

def cross_compiling?
  RbConfig::CONFIG["CROSS_COMPILING"] == "yes"
end

#respond_to_missing?(name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/rb_sys/mkmf/config.rb', line 25

def respond_to_missing?(name, include_private = false)
  @builder.respond_to?(name) || super
end

#rubygems_invoked?Boolean

Seems to be the only way to reliably know if we were invoked by Rubygems. We want to know this so we can cleanup the target directory after an install, to remove bloat.

Returns:

  • (Boolean)


32
33
34
# File 'lib/rb_sys/mkmf/config.rb', line 32

def rubygems_invoked?
  ENV.key?("SOURCE_DATE_EPOCH")
end