Class: Canoe::Compiler

Inherits:
Object
  • Object
show all
Includes:
SystemCommand
Defined in:
lib/compiler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from SystemCommand

#issue_command, #run_command

Constructor Details

#initialize(name, compiling_flags, linking_flags) ⇒ Compiler

@name: String @flgs: Array of String



15
16
17
18
19
# File 'lib/compiler.rb', line 15

def initialize(name, compiling_flags, linking_flags)
  @name = name
  @linking_flags = linking_flags
  @compiling_flags = compiling_flags
end

Instance Attribute Details

#flagsObject (readonly)

Returns the value of attribute flags.



10
11
12
# File 'lib/compiler.rb', line 10

def flags
  @flags
end

#nameObject (readonly)

Returns the value of attribute name.



10
11
12
# File 'lib/compiler.rb', line 10

def name
  @name
end

Instance Method Details

#append_compiling_flag(flag) ⇒ Object



29
30
31
# File 'lib/compiler.rb', line 29

def append_compiling_flag(flag)
  @compiling_flags << flag
end

#append_linking_flag(flag) ⇒ Object



33
34
35
# File 'lib/compiler.rb', line 33

def append_linking_flag(flag)
  @linking_flags << flag
end

#compile(src, out) ⇒ Object



37
38
39
# File 'lib/compiler.rb', line 37

def compile(src, out)
  issue_command "#{name} -o #{out} #{compiling_flags_as_str} -c #{src}"
end

#compiling_flags_as_strObject



21
22
23
# File 'lib/compiler.rb', line 21

def compiling_flags_as_str
  @compiling_flags.join ' '
end


41
42
43
# File 'lib/compiler.rb', line 41

def link_executable(out, objs)
  issue_command "#{name} -o #{out} #{objs.join(' ')} #{linking_flags_as_str}"
end


45
46
47
# File 'lib/compiler.rb', line 45

def link_shared(out, objs)
  issue_command "#{name} -shared -o #{out}.so #{objs.join(' ')} #{linking_flags_as_str}"
end

#linking_flags_as_strObject



25
26
27
# File 'lib/compiler.rb', line 25

def linking_flags_as_str
  @linking_flags.join ' '
end