Class: Rubex::CompilerConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/rubex/compiler_config.rb

Overview

Class for storing configuration of the compiler (gcc) that will compile

the generated C code. This includes file names, compiler flags and other
options required by Rubex.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCompilerConfig

Returns a new instance of CompilerConfig.



8
9
10
11
12
# File 'lib/rubex/compiler_config.rb', line 8

def initialize
  @links = []
  @srcs = []
  @objs = []
end

Instance Attribute Details

#debugObject

Returns the value of attribute debug.



6
7
8
# File 'lib/rubex/compiler_config.rb', line 6

def debug
  @debug
end

#objsObject

Returns the value of attribute objs.



6
7
8
# File 'lib/rubex/compiler_config.rb', line 6

def objs
  @objs
end

#srcsObject

Returns the value of attribute srcs.



6
7
8
# File 'lib/rubex/compiler_config.rb', line 6

def srcs
  @srcs
end

Instance Method Details

#add_dep(file_name) ⇒ Object

add dependency on file so extconf will recognise it.



29
30
31
32
# File 'lib/rubex/compiler_config.rb', line 29

def add_dep(file_name)
  @srcs << "#{file_name}.c"
  @objs << "#{file_name}.o"
end


14
15
16
# File 'lib/rubex/compiler_config.rb', line 14

def add_link link_str
  @links << link_str
end

#flushObject



22
23
24
25
26
# File 'lib/rubex/compiler_config.rb', line 22

def flush
  @links = []
  @srcs = []
  @objs = []
end


18
19
20
# File 'lib/rubex/compiler_config.rb', line 18

def link_flags
  @links.map { |l| l.dup.prepend('-l') }.join(' ')
end