module L::C::CompilerGCC

GNU Compiler Collection

Public Class Methods

available?() click to toggle source
# File lib/rub/l/c/compiler/gcc.rb, line 34
def self.available?
        !!find
end
compile_command(opt, src, obj) click to toggle source
# File lib/rub/l/c/compiler/gcc.rb, line 81
def self.compile_command(opt, src, obj)
        [find, '-c', *generate_flags(opt), "-o#{obj}", *src]
end
do_compile_string(opt, str, obj) click to toggle source
# File lib/rub/l/c/compiler/gcc.rb, line 85
def self.do_compile_string(opt, str, obj)
        c = R::Command.new [find, '-c', '-xc', *generate_flags(opt), '-o', obj, '-']
        c.stdin = str
        c.run
        c
end
find() click to toggle source
# File lib/rub/l/c/compiler/gcc.rb, line 38
def self.find
        @exe and return @exe

        @exe = ::C.find_command 'gcc'
end
generate_flags(opt) click to toggle source
# File lib/rub/l/c/compiler/gcc.rb, line 60
def self.generate_flags(opt)
        f = []
        
        f << (@@o_flags[opt.optimize    ] || [])
        f << (@@o_flags[opt.optimize_for] || [])
        
        f << opt.include_dirs.map do |d|
                "-I#{d}"
        end
        f << opt.define.map do |k, v|
                if v
                        # -Dk if v is true else -Dk=v.
                        "-D#{k}#{v.eql?(true)?"":"=#{v}"}"
                else
                        "-U#{k}"
                end
        end
        
        f.flatten!
end
linker() click to toggle source
# File lib/rub/l/c/compiler/gcc.rb, line 44
def self.linker
        :gcc
end
name() click to toggle source
# File lib/rub/l/c/compiler/gcc.rb, line 30
def self.name
        :gcc
end