Class: CCompiler
- Inherits:
-
Object
- Object
- CCompiler
- Defined in:
- lib/lake/plugins/cpp.rb
Instance Attribute Summary collapse
-
#compiler ⇒ Object
Returns the value of attribute compiler.
-
#flags ⇒ Object
Returns the value of attribute flags.
-
#shared ⇒ Object
Returns the value of attribute shared.
Instance Method Summary collapse
- #compile(source, output = nil, object = false) ⇒ Object
-
#initialize(compiler: "gcc", flags: "") ⇒ CCompiler
constructor
A new instance of CCompiler.
- #link(*files, output) ⇒ Object
- #system(code) ⇒ Object
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
#compiler ⇒ Object
Returns the value of attribute compiler.
2 3 4 |
# File 'lib/lake/plugins/cpp.rb', line 2 def compiler @compiler end |
#flags ⇒ Object
Returns the value of attribute flags.
2 3 4 |
# File 'lib/lake/plugins/cpp.rb', line 2 def flags @flags end |
#shared ⇒ Object
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 |
#link(*files, output) ⇒ Object
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 |