Class: Benchcc::Compiler

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

Overview

Basic interface to compiler frontends.

Direct Known Subclasses

Clang, GCC

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.guess_from_binary(binary) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/benchcc/compiler.rb', line 28

def self.guess_from_binary(binary)
  stdout, stderr, status = Open3.capture3("#{binary} --version")
  case stdout
  when /\(GCC\)/
    return GCC.new(binary)
  when /clang/
    return Clang.new(binary)
  else
    raise ArgumentError("unknown compiler #{binary}")
  end
end

Instance Method Details

#compile(file, *args) ⇒ Object

compile: Path -> Hash

Compile the given file and return compilation statistics.

Additional compiler-specific arguments may be specified. A CompilationError is raised if the compilation fails for whatever reason.

Raises:

  • (NotImplementedError)


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

def compile(file, *args)
  raise NotImplementedError
end

#to_sObject

Show the name and the version of the compiler.

Raises:

  • (NotImplementedError)


13
14
15
# File 'lib/benchcc/compiler.rb', line 13

def to_s
  raise NotImplementedError
end