module L::C::CompilerClang
The Clang Compiler
Public Class Methods
available?()
click to toggle source
# File lib/rub/l/c/compiler/clang.rb, line 33 def self.available? !!find end
compile_command(opt, src, obj)
click to toggle source
# File lib/rub/l/c/compiler/clang.rb, line 82 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/clang.rb, line 86 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/clang.rb, line 37 def self.find @exe and return @exe @exe = ::C.find_command 'clang' end
generate_flags(opt)
click to toggle source
# File lib/rub/l/c/compiler/clang.rb, line 59 def self.generate_flags(opt) f = [] #f << '-emit-llvm' 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.equal?(true)?"":"=#{v}"}" else "-U#{k}" end end f.flatten! end
linker()
click to toggle source
# File lib/rub/l/c/compiler/clang.rb, line 43 def self.linker :clang end
name()
click to toggle source
# File lib/rub/l/c/compiler/clang.rb, line 29 def self.name :clang end