Class Mkrf::Availability
In: lib/mkrf/availability.rb
Parent: Object

The Availability class is concerned with libraries, headers, and functions. It can be easily wrapped (see Mkrf::Generator for an example) and should be able to be used as a basis for a variety of programs which need to determine functionality based on what libraries are available on the current system.

Methods

Constants

DEFAULT_INCLUDES = [Config::CONFIG['rubyhdrdir'], Config::CONFIG['rubyhdrdir'] + "/" + Config::CONFIG['arch'], Config::CONFIG["archdir"],Config::CONFIG['sitelibdir'], "."]
DEFAULT_INCLUDES = [Config::CONFIG['includedir'], Config::CONFIG["archdir"], Config::CONFIG['sitelibdir'], "."]
TEMP_SOURCE_FILE = "temp_source.c"   These really shouldn‘t be static like this..
TEMP_EXECUTABLE = "temp_executable"

Attributes

defines  [R] 
headers  [R] 
includes  [R] 
loaded_libs  [R] 
logger  [R] 

Public Class methods

Create a new Availability instance.

Valid keys for the options hash include:

  • :loaded_libs — libraries to load by default
  • :library_paths — libraries paths to include by default
  • :headers — headers to load by default
  • :compiler — which compiler to use when determining availability
  • :includes — directories that should be searched for include files

Public Instance methods

Returns the result of an attempt to compile and link the function body passed in

Takes the name of an executable and an optional set of paths to search. If no paths are given, the environmental path is used by default. Returns the absolute path to an executable, or nil if not found.

Returns true if the function is able to be called based on libraries and headers currently loaded. Returns false otherwise.

Params:

  • function — the function to check for

Returns true if the header is found in the default search path or in optional paths passed as an argument, false otherwise. If the header is found, the preprocessor constant HAVE_BLAH is defined where BLAH is the name of the header in uppercase without the file extension.

Params:

  • header — the header to be searched for
  • paths — an optional list of search paths if the header is not found in the default paths

Returns a boolean whether indicating whether the library can be found by attempting to reference the function passed (main by default).

Params:

  • library — the library to be included as a string
  • function — a method to base the inclusion of the library on. main by default.
  • paths — an optional list of search paths if the library is not found in the default paths

Include a header in the list of availiable headers. Returns false if the header is not available. Returns non-false otherwise. If the header is found, the preprocessor constant HAVE_BLAH is defined where BLAH is the name of the header in uppercase without the file extension.

Params:

  • header — the name of the header to be included as a string.
  • paths — an optional list of search paths if the header is not found in the default paths.

Include a library in the list of available libs. Returns false if the library is not available. Returns non-false otherwise.

Params:

  • library — the library to be included as a string.
  • function — a method to base the inclusion of the library on. main by default.
  • paths — an optional list of search paths if the library is not found in the default paths.

Returns a string of include directories formatted for compilation

Returns a string of libraries formatted for compilation

Returns a string of libraries directories formatted for compilation

[Validate]