Class: CCompiler

Inherits:
Object
  • Object
show all
Defined in:
lib/lake/plugins/cpp.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(compiler: "gcc", flags: "") ⇒ CCompiler

Returns a new instance of CCompiler.



3
4
5
# File 'lib/lake/plugins/cpp.rb', line 3

def initialize(compiler:"gcc",flags:"")
  @flags,@compiler = flags,compiler
end

Instance Attribute Details

#compilerObject

Returns the value of attribute compiler.



2
3
4
# File 'lib/lake/plugins/cpp.rb', line 2

def compiler
  @compiler
end

#flagsObject

Returns the value of attribute flags.



2
3
4
# File 'lib/lake/plugins/cpp.rb', line 2

def flags
  @flags
end

#sharedObject

Returns the value of attribute shared.



2
3
4
# File 'lib/lake/plugins/cpp.rb', line 2

def shared
  @shared
end

Instance Method Details

#compile(source, output = nil, object = false) ⇒ Object



12
13
14
15
# File 'lib/lake/plugins/cpp.rb', line 12

def compile(source,output=nil,object=false)
  output ||= File.basename(source,".*") + ".out"
  system "#{@compiler} #{@flags} #{object ? "-c" : ""}  -o \"#{output}\" \"#{source}\""
end


17
18
19
# File 'lib/lake/plugins/cpp.rb', line 17

def link(*files,output)
  system "#{@compiler} #{@flags} -o \"#{output}\" #{files.inject(""){|a,b| a + "\"#{b}\" "}}"
end

#system(code) ⇒ Object



7
8
9
10
# File 'lib/lake/plugins/cpp.rb', line 7

def system(code)
  puts code
  super code
end