Class: Truffle::CExt::MkMf

Inherits:
Object
  • Object
show all
Defined in:
truffle/src/main/ruby/core/truffle/cext/mkmf.rb

Overview

MkMf is the DSL to create Makefiles for C extensions. A basic 'extconf.rb' file will require 'mkmf', set some $CFLAGS and then call create_makefile. We run that 'extconf.rb' in an #instance_eval using an instance of this class. See Truffle::CExt.load_extconf.

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (MkMf) initialize(directory)

Returns a new instance of MkMf



23
24
25
26
# File 'truffle/src/main/ruby/core/truffle/cext/mkmf.rb', line 23

def initialize(directory)
  @directory = directory
  @c_files = []
end

Instance Attribute Details

- (Object) c_files (readonly)

Returns the value of attribute c_files



21
22
23
# File 'truffle/src/main/ruby/core/truffle/cext/mkmf.rb', line 21

def c_files
  @c_files
end

- (Object) target_name (readonly)

Returns the value of attribute target_name



20
21
22
# File 'truffle/src/main/ruby/core/truffle/cext/mkmf.rb', line 20

def target_name
  @target_name
end

Instance Method Details

- (Object) create_makefile(target)



34
35
36
37
# File 'truffle/src/main/ruby/core/truffle/cext/mkmf.rb', line 34

def create_makefile(target)
  @target_name = target.split('/').last
  @c_files = Dir.glob(File.join(@directory, '**', '*.c'))
end

- (Object) require(path)

We're mocking mkmf so don't actually load it



30
31
32
# File 'truffle/src/main/ruby/core/truffle/cext/mkmf.rb', line 30

def require(path)
  super.require unless path == 'mkmf'
end