Module: Neutron::CC

Defined in:
lib/neutron/cc.rb

Class Method Summary collapse

Class Method Details

.cc(*files, **opts) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/neutron/cc.rb', line 24

def self.cc(*files, **opts)
  o = {
    prog: 'cc',
    debug: false,
    args: ''
  }.merge(opts)
  files.each do |file|
    file = File.expand_path(file)
    Neutron.execute("#{o[:prog]} -c #{file} #{'-g' if o[:debug]} #{o[:args]}", must_success: true)
  end
end

.cpp(*files, **opts) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/neutron/cc.rb', line 36

def self.cpp(*files, **opts)
  o = {
    prog: 'c++',
    debug: false,
    args: ''
  }.merge(opts)
  files.each do |file|
    file = File.expand_path(file)
    Neutron.execute("#{o[:prog]} -c #{file} #{'-g' if o[:debug]} #{o[:args]}", must_success: true)
  end
end


4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/neutron/cc.rb', line 4

def self.link(*files, target, **opts)
  o = {
    prog: 'cc',
    debug: false,
    args: '',
    shared: false
  }.merge(opts)
  specific = ''
  if o[:shared]
    specific << ' -shared'
  end
  files.map! do |file|
    File.expand_path(file)
  end
  Neutron.execute(
    "#{o[:prog]} #{specific} -Wl,-rpath=./ -Wall -fpic -o #{target} #{files.join(' ')} #{'-g' if o[:debug]} #{o[:args]}",
    must_success: true
  )
end