3
require 'qonf/detectos'
4
require 'rexml/parsers/sax2parser'
5
require 'rexml/sax2listener'
17
def initialize(rulesPath, qmake)
24
def run(config, conf, debug, isLucid)
27
parser.os = DetectOS::OS[DetectOS.whatOS].to_s.downcase
29
return false if not parser.parse(@rules) or parser.name.empty?
31
@optional = parser.optional
33
Info.info << "Checking for " << parser.name << "... "
35
dir = "#{File.dirname(@rules)}/#{parser.dir}"
38
Info.warn << "Running in " << dir << $endl
44
if File.stat(dir).directory?
49
if RUBY_PLATFORM == "x86_64-linux"
50
extraLib = "-L/usr/lib64 "
53
if File.dirname(@rules).end_with?("ffmpeg")
54
if conf.hasArgument?("with-ffmpeg")
55
ffmpegLib = conf.argumentValue("with-ffmpeg") + "/lib"
56
extraLib += "-L#{ffmpegLib}"
57
extraInclude = conf.argumentValue("with-ffmpeg") + "/include"
63
if extraLib.length > 0
64
qmakeLine = "'LIBS += #{extraLib} #{parser.libs.join(" ")}'";
67
if extraInclude.length > 0
68
qmakeLine += " 'INCLUDEPATH += #{extraInclude} #{parser.includes.join(" ")}'";
72
qmakeLine = "'DEFINES += K_LUCID' " + qmakeLine
75
@qmake.run(qmakeLine, true)
77
if not @qmake.compile(debug)
80
print "[ \033[91mFAILED\033[0m ]\n"
82
priority = "\033[92moptional\033[0m"
83
flag = "\033[92mCOULD\033[0m"
85
priority = "\033[91mrequired\033[0m"
86
flag = "\033[91mMUST\033[0m"
89
Info.info << "Priority: " << priority << "\n"
93
solution = parser.solution
95
Info.warn << "Seems like you are running " << parser.os << "..." << $endl
96
Info.warn << "You " << flag << " install these dependencies: " << solution[:package] << $endl
97
Info.warn << "URL: " << solution[:url] << $endl
98
Info.warn << solution[:comment] << $endl
104
raise QonfException.new("'#{dir}' isn't a directory!")
109
raise QonfException.new("'#{dir}' doesn't exists!")
115
parser.includes.each { |inc|
116
config.addIncludePath(inc)
119
parser.libs.each { |lib|
123
parser.defines.each { |define|
124
config.addDefine(define)
127
parser.modules.each { |mod|
128
config.addModule(mod)
131
print "[ \033[92mOK\033[0m ]\n"
133
priority = "\033[92moptional\033[0m"
134
if @optional == false
135
priority = "\033[91mrequired\033[0m"
138
Info.info << "Priority: " << priority << "\n"
149
include REXML::SAX2Listener
154
attr_reader :includes
158
attr_reader :solution
159
attr_reader :optional
181
def start_element( uri, localname, qname, attributes)
184
@optional = (attributes["optional"] == "true")
187
@name = attributes["name"].to_s
189
if @section == "test"
190
@dir = attributes["path"]
195
if @section == "provide"
196
@defines << attributes["value"]
199
if @section == "provide"
200
@includes << attributes["path"]
203
if @section == "provide"
204
@libs << attributes["path"]
207
if @section == "provide"
208
@modules << attributes["value"]
211
if @section == "provide"
212
if @current_tag == "includes"
213
IO.popen(attributes["value"]) { |c|
214
output = c.readlines.join("").split(" ")
218
@includes << $1.chomp
224
elsif @current_tag == "libs"
225
IO.popen(attributes["value"]) { |c|
226
output = c.readlines.join("").split(" ")
231
elsif lib[0].chr != "-"
240
@section = "solution"
242
if @os == qname and @solution.size == 0
243
fillSolution(attributes)
246
if @os == qname and @solution.size == 0
247
fillSolution(attributes)
250
if @os == qname and @solution.size == 0
251
fillSolution(attributes)
254
if @os == attributes["name"].to_s.downcase and @solution.size == 0
255
fillSolution(attributes)
262
def end_element(uri, localname, qname)
276
sax2 = REXML::Parsers::SAX2Parser.new( File.new( path ) )
289
def fillSolution(attributes)
290
@solution[:package] = attributes["package"]
291
@solution[:url] = attributes["url"]
292
@solution[:comment] = attributes["comment"]