Class: Take::Compiler::GCC

Inherits:
Base
  • Object
show all
Defined in:
lib/take/compiler/gcc.rb

Constant Summary collapse

DEBUG_OPTIONS =
{
  default: "0",
  normal: "1",
  more: "2",
  max: "3",
  debug: "g",
  fast: "fast",
  size: "s"
}.freeze

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#command

Constructor Details

#initializeGCC

Returns a new instance of GCC.



26
27
28
29
30
31
32
33
34
35
# File 'lib/take/compiler/gcc.rb', line 26

def initialize
  super
  @options[:libraries] = []
  @options[:directories] = { include: [],
                             quote: [],
                             library: [] }.freeze
  @options[:defines] = {}
  @options[:optimize] = DEBUG_OPTIONS.fetch(:default)
  @options[:warnings] = ["all", "extra"]
end

Class Method Details

.commandObject



22
23
24
# File 'lib/take/compiler/gcc.rb', line 22

def self.command
  "gcc".freeze
end

.on_platform?Boolean

Returns:

  • (Boolean)


15
16
17
18
19
20
# File 'lib/take/compiler/gcc.rb', line 15

def self.on_platform?
  @_on_platform ||= begin
    runner = Command::Runner.new(command, "--version")
    runner.run.successful?
  end
end

Instance Method Details

#[]=(key, value) ⇒ Object



60
61
62
# File 'lib/take/compiler/gcc.rb', line 60

def []=(key, value)
  @options[:extra][key] = value
end

#definesObject



72
73
74
# File 'lib/take/compiler/gcc.rb', line 72

def defines
  @options[:defines]
end

#directoriesObject



68
69
70
# File 'lib/take/compiler/gcc.rb', line 68

def directories
  @options[:directories]
end

#language=(lang) ⇒ Object



41
42
43
# File 'lib/take/compiler/gcc.rb', line 41

def language=(lang)
  @options[:lang] = lang || "none"
end

#librariesObject



64
65
66
# File 'lib/take/compiler/gcc.rb', line 64

def libraries
  @options[:libraries]
end

#objectObject



93
94
95
96
# File 'lib/take/compiler/gcc.rb', line 93

def object
  stop_after :link
  self
end

#optimize_mode=(mode) ⇒ Object



53
54
55
56
57
58
# File 'lib/take/compiler/gcc.rb', line 53

def optimize_mode=(mode)
  mode = :default unless mode
  @options[:optimize] = DEBUG_OPTIONS.fetch(mode) do
    DEBUG_OPTIONS.fetch(:default)
  end
end

#output=(file) ⇒ Object



37
38
39
# File 'lib/take/compiler/gcc.rb', line 37

def output=(file)
  @options[:output] = file
end

#runObject



98
99
100
# File 'lib/take/compiler/gcc.rb', line 98

def run

end

#standard=(standard) ⇒ Object



45
46
47
48
49
50
51
# File 'lib/take/compiler/gcc.rb', line 45

def standard=(standard)
  if standard
    @options[:std] = standard
  else
    @options.delete(:std)
  end
end

#stop_after(stage = nil) ⇒ Object



80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/take/compiler/gcc.rb', line 80

def stop_after(stage = nil)
  case stage
  when :link
    @options[:stop] = "c"
  when :assemble
    @options[:stop] = "S"
  when :preprocess
    @options[:stop] = "E"
  else
    @options.delete(:stop)
  end
end

#warningsObject



76
77
78
# File 'lib/take/compiler/gcc.rb', line 76

def warnings
  @options[:warnings]
end