Module: Neutron::Valac

Defined in:
lib/neutron/valac.rb

Class Method Summary collapse

Class Method Details

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



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/neutron/valac.rb', line 4

def self.compile(*files, **opts)
  o = {
    prog: 'valac',
    debug: false,
    type: :object,
    args: ''
  }.merge(opts)

  specific = ''
  
  if o[:debug]
    specific << ' -g'
  end

  case o[:type]
  when :object
    specific << ' -c'
  else
    raise TypeError, "Invalid output type: #{o[:type]}!"
  end

  files.each do |file|
    file = File.expand_path(file)
    
    Neutron.execute("#{o[:prog]} #{file} #{specific} -b ./ --thread #{o[:args]}", must_success: true)
  end
end