Class: Comet::Rules::Compile

Inherits:
Object
  • Object
show all
Defined in:
lib/comet/rules/compile.rb

Instance Method Summary collapse

Constructor Details

#initialize(source, file, linker) ⇒ Compile

Returns a new instance of Compile.



4
5
6
7
8
# File 'lib/comet/rules/compile.rb', line 4

def initialize(source, file, linker)
  @source = source
  @file = file
  @linker = linker
end

Instance Method Details

#commandsObject



34
35
36
# File 'lib/comet/rules/compile.rb', line 34

def commands
  { COMET_CC: 'clang' }
end

#contentsObject



23
24
25
26
27
28
# File 'lib/comet/rules/compile.rb', line 23

def contents
  [
    "#{target}: #{@file} #{dependencies.join ' '} | #{Comet::TMPDIR}",
    "\t#{clang_compile} #{formatted_flags.join ' '} -o $@ -c $<"
  ]
end

#rulesObject



30
31
32
# File 'lib/comet/rules/compile.rb', line 30

def rules
  []
end

#targetObject



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/comet/rules/compile.rb', line 10

def target
  @target ||= Comet::Makefile.fingerprint Hash[
    file: @file,
    triple: @linker.triple,
    isa: @linker.isa,
    cpu: @linker.cpu,
    language: @source.language,
    flags: Set[formatted_flags],
    headers: formatted_headers,
    dependencies: Set[dependencies]
  ], extension: :ll
end