File: which_qmake.rb

package info (click to toggle)
liblastfm 0.4.0~git20090710-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 808 kB
  • sloc: cpp: 7,614; ruby: 397; ansic: 108; makefile: 49; sh: 5
file content (38 lines) | stat: -rw-r--r-- 787 bytes parent folder | download | duplicates (2)
1
2
3
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
31
32
33
34
35
36
37
38
require "#{File.dirname __FILE__}/platform.rb"

class QMakeNotFound < RuntimeError; end
class QMakeTooOld < RuntimeError; end

def which_qmake
  args = '-v'
  args += ' 2> /dev/null' unless Platform::IMPL == :mswin

  versions = Hash.new
  ['qmake','qmake-qt4'].each do |qmake|
    begin
      /^Using Qt version (\d\.\d\.\d)(-(.+))?/.match( `#{qmake} #{args}` )
    rescue
    end
    versions[qmake] = $1 unless $1.nil?
  end

  raise QMakeNotFound if versions.empty? 

  versions.each do |key, v|
    i = 1
    j = 0
    v.split( '.' ).reverse.each {|n| j += (n.to_i * i); i *= 100}
    versions[key] = j
  end

  versions.sort {|a,b| a[1]<=>b[1]}

  versions.each do |k, v| 
    if v >= 40400
      return k
    end
    raise QMakeTooOld
  end
end

puts which_qmake if __FILE__ == $0