119 |
163 |
120 # ============================================================================ |
164 # ============================================================================ |
121 # OptionParser |
165 # OptionParser |
122 # ============================================================================ |
166 # ============================================================================ |
123 class OptionParser(optparse.OptionParser): |
167 class OptionParser(optparse.OptionParser): |
124 def __init__(self, platform, make, prefix): |
168 def __init__(self): |
125 optparse.OptionParser.__init__(self, formatter=optparse.TitledHelpFormatter()) |
169 optparse.OptionParser.__init__(self, formatter=optparse.TitledHelpFormatter()) |
126 self.add_option("-v", "--verbose", action="store_true", dest="verbose", |
170 self.add_option("-v", "--verbose", action="store_true", dest="verbose", |
127 help="Print verbose information during the configure.") |
171 help="Print verbose information during the configure.") |
128 self.set_defaults(verbose=False) |
172 self.set_defaults(verbose=False) |
129 |
173 |
130 if platform != "symbian": |
174 if QMAKE.platform() != "symbian": |
131 group = optparse.OptionGroup(self, "Installation options") |
175 group = optparse.OptionGroup(self, "Installation options") |
132 group.add_option("--prefix", dest="prefix", metavar="dir", |
176 group.add_option("--prefix", dest="prefix", metavar="dir", |
133 help="Install everything relative to <dir>. The default value is '%s'. " |
177 help="Install everything relative to <dir>. The default value is '%s'. " |
134 "NOTE: Use '--prefix .' to configure a local setup. A local " |
178 "NOTE: Use '--prefix .' to configure a local setup. A local " |
135 "setup will install nothing else than the qmake " |
179 "setup will install nothing else than the qmake " |
136 "feature file." % prefix) |
180 "feature file." % BUILDENV.default_prefix()) |
137 group.add_option("--bin-dir", dest="bindir", metavar="dir", |
181 group.add_option("--bin-dir", dest="bindir", metavar="dir", |
138 help="Install executables to <dir>. The default value is 'PREFIX/bin'.") |
182 help="Install executables to <dir>. The default value is 'PREFIX/bin'.") |
139 group.add_option("--lib-dir", dest="libdir", metavar="dir", |
183 group.add_option("--lib-dir", dest="libdir", metavar="dir", |
140 help="Install libraries to <dir>. The default value is 'PREFIX/lib'.") |
184 help="Install libraries to <dir>. The default value is 'PREFIX/lib'.") |
141 group.add_option("--doc-dir", dest="docdir", metavar="dir", |
185 group.add_option("--doc-dir", dest="docdir", metavar="dir", |
142 help="Install documentation to <dir>. The default value is 'PREFIX/doc'.") |
186 help="Install documentation to <dir>. The default value is 'PREFIX/doc'.") |
143 group.add_option("--include-dir", dest="includedir", metavar="dir", |
187 group.add_option("--include-dir", dest="includedir", metavar="dir", |
144 help="Install headers to <dir>. The default value is 'PREFIX/include'.") |
188 help="Install headers to <dir>. The default value is 'PREFIX/include'.") |
145 group.add_option("--plugin-dir", dest="plugindir", metavar="dir", |
189 group.add_option("--plugin-dir", dest="plugindir", metavar="dir", |
146 help="Install plugins to <dir>. The default value is 'PREFIX/plugins'.") |
190 help="Install plugins to <dir>. The default value is 'PREFIX/plugins'.") |
147 group.add_option("--resource-dir", dest="resourcedir", metavar="dir", |
191 group.add_option("--features-dir", dest="featuresdir", metavar="dir", |
|
192 help="Install qmake feature files to <dir>. The default value is 'QTDIR/mkspecs/features'.") |
|
193 group.add_option("--resources-dir", dest="resourcesdir", metavar="dir", |
148 help="Install resources to <dir>. The default value is 'PREFIX/resources'.") |
194 help="Install resources to <dir>. The default value is 'PREFIX/resources'.") |
149 group.add_option("--feature-dir", dest="featuredir", metavar="dir", |
|
150 help="Install qmake feature files to <dir>. The default value is 'QTDIR/mkspecs/features'.") |
|
151 self.add_option_group(group) |
195 self.add_option_group(group) |
152 self.set_defaults(prefix=None) |
196 self.set_defaults(prefix=None) |
153 self.set_defaults(bindir=None) |
197 self.set_defaults(bindir=None) |
154 self.set_defaults(libdir=None) |
198 self.set_defaults(libdir=None) |
155 self.set_defaults(docdir=None) |
199 self.set_defaults(docdir=None) |
156 self.set_defaults(includedir=None) |
200 self.set_defaults(includedir=None) |
157 self.set_defaults(plugindir=None) |
201 self.set_defaults(pluginsdir=None) |
158 self.set_defaults(resourcedir=None) |
202 self.set_defaults(featuresdir=None) |
159 self.set_defaults(featuredir=None) |
203 self.set_defaults(resourcesdir=None) |
160 |
204 |
161 group = optparse.OptionGroup(self, "Configure options") |
205 group = optparse.OptionGroup(self, "Configure options") |
162 group.add_option("--platform", dest="platform", metavar="platform", |
206 group.add_option("--platform", dest="platform", metavar="platform", |
163 help="Specify the platform (symbian/win32/unix). " |
207 help="Specify the platform (symbian/win32/unix). " |
164 "The one detected by qmake is used by default " |
208 "The one detected by qmake is used by default " |
165 "if not specified.") |
209 "if not specified.") |
166 group.add_option("--make-bin", dest="makebin", metavar="path", |
210 group.add_option("--make-bin", dest="makebin", metavar="path", |
167 help="Specify the make tool (make, nmake, mingw32-make, gmake...). " |
211 help="Specify the make tool (make, nmake, mingw32-make, gmake...). " |
168 "The one detected in PATH is used by default if not specified.") |
212 "The one detected in PATH is used by default if not specified.") |
169 if platform == "win32" and make == "nmake": |
213 if QMAKE.platform() == "win32" and MAKE.bin() == "nmake": |
170 group.add_option("--msvc", action="store_true", dest="msvc", |
214 group.add_option("--msvc", action="store_true", dest="msvc", |
171 help="Generate a MSVC solution.") |
215 help="Generate a MSVC solution.") |
172 group.add_option("--release", action="store_const", dest="config", const="release", |
216 group.add_option("--release", action="store_const", dest="config", const="release", |
173 help="Build in release mode.") |
217 help="Build in release mode.") |
174 group.add_option("--debug", action="store_const", dest="config", const="debug", |
218 group.add_option("--debug", action="store_const", dest="config", const="debug", |
232 help="Do not build effects.") |
282 help="Do not build effects.") |
233 group.add_option("--no-gestures", action="store_false", dest="gestures", |
283 group.add_option("--no-gestures", action="store_false", dest="gestures", |
234 help="Do not build gestures.") |
284 help="Do not build gestures.") |
235 group.add_option("--no-text-measurement", action="store_false", dest="textMeasurement", |
285 group.add_option("--no-text-measurement", action="store_false", dest="textMeasurement", |
236 help="Do not build text measurement support (needed for localization).") |
286 help="Do not build text measurement support (needed for localization).") |
237 group.add_option("--no-inputs", action="store_false", dest="inputs", |
|
238 help="DEPRECATED: Use --nomake hbinput.") |
|
239 group.add_option("--no-feedback", action="store_false", dest="feedback", |
|
240 help="DEPRECATED: Use --nomake hbfeedback.") |
|
241 group.add_option("--no-tutorials", action="store_false", dest="tutorials", |
|
242 help="DEPRECATED: Use --nomake tutorials.") |
|
243 self.add_option_group(group) |
287 self.add_option_group(group) |
244 self.set_defaults(make=None) |
288 self.set_defaults(make=None) |
245 self.set_defaults(nomake=None) |
289 self.set_defaults(nomake=None) |
246 self.set_defaults(effects=True) |
290 self.set_defaults(effects=True) |
247 self.set_defaults(gestures=True) |
291 self.set_defaults(gestures=True) |
248 self.set_defaults(textMeasurement=True) |
292 self.set_defaults(textMeasurement=True) |
249 self.set_defaults(inputs=None) |
|
250 self.set_defaults(feedback=None) |
|
251 self.set_defaults(tutorials=None) |
|
252 |
293 |
253 group = optparse.OptionGroup(self, "Qt options") |
294 group = optparse.OptionGroup(self, "Qt options") |
254 group.add_option("--qt-mobility", action="store_true", dest="qtmobility", |
295 group.add_option("--qt-mobility", action="store_true", dest="qtmobility", |
255 help="Assumes that Qt Mobility is available without performing a compilation test.") |
296 help="Assumes that Qt Mobility is available without performing a compilation test.") |
256 group.add_option("--no-qt-mobility", action="store_false", dest="qtmobility", |
297 group.add_option("--no-qt-mobility", action="store_false", dest="qtmobility", |
257 help="Assumes that Qt Mobility is not available without performing a compilation test.") |
298 help="Assumes that Qt Mobility is not available without performing a compilation test.") |
258 group.add_option("--qt-animation", action="store_true", dest="qtanimation", |
299 group.add_option("--meegotouch", action="store_true", dest="meegotouch", |
259 help="DEPRECATED: Qt 4.6 includes the animation framework.") |
300 help="Assumes that MeeGoTouch UI is available without performing a compilation test.") |
260 group.add_option("--no-qt-animation", action="store_false", dest="qtanimation", |
301 group.add_option("--no-meegotouch", action="store_false", dest="meegotouch", |
261 help="DEPRECATED: Qt 4.6 includes the animation framework.") |
302 help="Assumes that MeeGoTouch UI is not available without performing a compilation test.") |
262 group.add_option("--qt-gestures", action="store_true", dest="qtgestures", |
303 group.add_option("--qt-openvg", action="store_true", dest="qtopenvg", |
263 help="DEPRECATED: Qt 4.6 includes the gestures framework.") |
304 help="Assumes that OpenVG is available without performing a compilation test.") |
264 group.add_option("--no-qt-gestures", action="store_false", dest="qtgestures", |
305 group.add_option("--no-qt-openvg", action="store_false", dest="qtopenvg", |
265 help="DEPRECATED: Qt 4.6 includes the gestures framework.") |
306 help="Assumes that OpenVG is not available without performing a compilation test.") |
266 if platform == "symbian" or platform == None: |
|
267 group.add_option("--qt-symbian-eventfilter", action="store_false", dest="s60eventfilter", |
|
268 help="DEPRECATED: Qt 4.6 includes QApplication::symbianEventFilter().") |
|
269 group.add_option("--qt-s60-eventfilter", action="store_true", dest="s60eventfilter", |
|
270 help="DEPRECATED: Qt 4.6 includes QApplication::symbianEventFilter().") |
|
271 group.add_option("--dui", action="store_true", dest="dui", |
|
272 help="Assumes that Maemo Direct UI is available without performing a compilation test.") |
|
273 group.add_option("--no-dui", action="store_false", dest="dui", |
|
274 help="Assumes that Maemo Direct UI is not available without performing a compilation test.") |
|
275 self.add_option_group(group) |
307 self.add_option_group(group) |
276 self.set_defaults(qtmobility=None) |
308 self.set_defaults(qtmobility=None) |
277 self.set_defaults(qtanimation=None) |
309 self.set_defaults(qtopenvg=None) |
278 self.set_defaults(qtgestures=None) |
|
279 self.set_defaults(qts60eventfilter=None) |
|
280 |
310 |
281 group = optparse.OptionGroup(self, "Developer options") |
311 group = optparse.OptionGroup(self, "Developer options") |
282 group.add_option("--developer", action="store_true", dest="developer", |
312 group.add_option("--developer", action="store_true", dest="developer", |
283 help="Enables the developer mode ie. builds tests and exports necessary symbols. " |
313 help="Enables the developer mode. The developer mode implies " |
284 "NOTE: The developer mode implies a local setup by default.") |
314 "a local setup, enables tests and exports extra symbols for " |
285 if platform != "symbian": |
315 "testing purposes. NOTE: this is equal to: --prefix . --make tests " |
|
316 "--developer-export") |
|
317 group.add_option("--developer-export", action="store_true", dest="developerexport", |
|
318 help="Enables developer exports ie. extra symbols for testing purposes.") |
|
319 if QMAKE.platform() != "symbian": |
286 group.add_option("--coverage", action="store_true", dest="coverage", |
320 group.add_option("--coverage", action="store_true", dest="coverage", |
287 help="Builds with test coverage measurement support. " |
321 help="Builds with test coverage measurement support. " |
288 "This implies the developer mode.") |
322 "This implies the developer mode.") |
289 group.add_option("--tests", action="store_true", dest="tests", |
|
290 help="DEPRECATED: Use --make tests.") |
|
291 group.add_option("--performance", action="store_true", dest="performance", |
|
292 help="DEPRECATED: Use --make performance.") |
|
293 group.add_option("--localization", action="store_true", dest="localization", |
|
294 help="DEPRECATED: Use --make localization.") |
|
295 self.add_option_group(group) |
323 self.add_option_group(group) |
296 self.set_defaults(developer=False) |
324 self.set_defaults(developer=False) |
|
325 self.set_defaults(developerexport=None) |
297 self.set_defaults(coverage=False) |
326 self.set_defaults(coverage=False) |
298 self.set_defaults(tests=None) |
327 |
299 self.set_defaults(performance=None) |
328 # ============================================================================ |
300 self.set_defaults(localization=None) |
329 # Make |
301 |
330 # ============================================================================ |
302 # ============================================================================ |
331 class Make: |
303 # Platform |
332 def __init__(self): |
304 # ============================================================================ |
333 self._bin = None |
305 class Platform: |
334 |
306 def __init__(self, qmake): |
335 def init(self, cmdline): |
|
336 match = re.search("--make-bin[=\s](\S+)", cmdline) |
|
337 if match: |
|
338 self._bin = match.group(1) |
|
339 else: |
|
340 self._bin = self._detect_make() |
|
341 |
|
342 def command(self, target=None): |
|
343 _args = [self._bin] |
|
344 if target: |
|
345 _args += [target] |
|
346 return _args |
|
347 |
|
348 def bin(self): |
|
349 return self._bin |
|
350 |
|
351 def _detect_make(self): |
|
352 if QMAKE.platform() == "win32" and self._test_make("nmake", "/?"): |
|
353 return "nmake" |
|
354 if self._test_make("make", "-v"): |
|
355 return "make" |
|
356 if self._test_make("gmake", "-v"): |
|
357 return "gmake" |
|
358 if QMAKE.platform() == "win32" and self._test_make("mingw32-make", "-v"): |
|
359 return "mingw32-make" |
|
360 return "make" |
|
361 |
|
362 def _test_make(self, command, param): |
|
363 try: |
|
364 return run_process([command, param])[0] == 0 |
|
365 except: |
|
366 return False |
|
367 |
|
368 # ============================================================================ |
|
369 # QMake |
|
370 # ============================================================================ |
|
371 class QMake: |
|
372 def __init__(self): |
|
373 self._bin = "qmake" |
307 self._platform = None |
374 self._platform = None |
308 self._make = None |
|
309 self._error = None |
375 self._error = None |
310 self._qmake = qmake |
|
311 self._spec = None |
376 self._spec = None |
312 self._version = None |
|
313 self._features = None |
377 self._features = None |
314 self._qtdir = None |
378 self._qtdir = None |
315 |
379 self._qtversion = None |
316 def name(self): |
380 self._args = [] |
317 if not self._platform: |
381 |
318 self._detect_qt() |
382 def init(self, cmdline): |
|
383 match = re.search("--qmake-bin[=\s](\S+)", cmdline) |
|
384 if match: |
|
385 self._bin = match.group(1) |
|
386 match = re.search("--platform[=\s](\S+)", cmdline) |
|
387 if match: |
|
388 self._platform = match.group(1) |
|
389 match = re.search("--qmake-spec[=\s](\S+)", cmdline) |
|
390 if match: |
|
391 self._spec = match.group(1) |
|
392 return self._run_qmake() |
|
393 |
|
394 def command(self, profile=None): |
|
395 _args = [self._bin] |
|
396 if self._spec: |
|
397 _args += ["-spec", self._spec] |
|
398 if len(self._args): |
|
399 _args += self._args |
|
400 if profile: |
|
401 _args += [profile] |
|
402 return _args |
|
403 |
|
404 def add_args(self, args): |
|
405 self._args += args |
|
406 |
|
407 def platform(self): |
319 return self._platform |
408 return self._platform |
320 |
409 |
321 def make(self): |
410 def bin(self): |
322 if not self._make: |
411 return self._bin |
323 self._make = self._detect_make() |
|
324 return self._make |
|
325 |
|
326 def qmake(self): |
|
327 if not self._qmake: |
|
328 self._detect_qt() |
|
329 return self._qmake |
|
330 |
412 |
331 def error(self): |
413 def error(self): |
332 return self._error |
414 return self._error |
333 |
415 |
334 def spec(self): |
416 def spec(self): |
335 if not self._spec: |
|
336 self._detect_qt() |
|
337 return self._spec |
417 return self._spec |
338 |
418 |
339 def version(self): |
|
340 if not self._version: |
|
341 self._detect_qt() |
|
342 return self._version |
|
343 |
|
344 def features(self): |
419 def features(self): |
345 if not self._features: |
|
346 self._detect_qt() |
|
347 return self._features |
420 return self._features |
348 |
421 |
349 def qtdir(self): |
422 def qtdir(self): |
350 if not self._qtdir: |
|
351 self._detect_qt() |
|
352 return self._qtdir |
423 return self._qtdir |
353 |
424 |
354 def _detect_qt(self): |
425 def qtversion(self): |
355 lines = list() |
426 return self._qtversion |
356 lines.append("symbian:message(platform:symbian)\n") |
427 |
357 lines.append("else:macx:message(platform:macx)\n") |
428 def _run_qmake(self): |
358 lines.append("else:unix:message(platform:unix)\n") |
429 # write .pro |
359 lines.append("else:win32:message(platform:win32)\n") |
430 content = """ |
360 |
431 symbian:message(platform:symbian) |
361 lines.append("message(version:$$[QT_VERSION])\n") |
432 symbian:message(platform:symbian) |
362 lines.append("message(libraries:$$[QT_INSTALL_LIBS])\n") |
433 else:macx:message(platform:macx) |
363 lines.append("message(features:$$[QMAKE_MKSPECS]/features)\n") |
434 else:unix:message(platform:unix) |
364 |
435 else:win32:message(platform:win32) |
365 try: |
436 message(features:$$[QMAKE_MKSPECS]/features) |
366 if not os.path.exists("tmp"): |
437 message(qtversion:$$[QT_VERSION]) |
367 os.makedirs("tmp") |
438 message(qtdir:$$[QT_INSTALL_LIBS]) |
368 fd, filepath = tempfile.mkstemp(dir="tmp", text=True, suffix=".pro") |
439 """ |
369 file = os.fdopen(fd, "w+") |
440 if not write_file("tmp/qmake.pro", content): |
370 file.writelines(lines) |
441 self._error = "Unable to write 'tmp/qmake.pro'. Make sure to configure in a writable directory." |
371 file.close() |
442 return False |
372 except Exception, e: |
443 |
373 print(e) |
444 # run qmake |
374 self._error = "Unable to write a temporary file. Make sure to configure in a writable directory." |
445 args = [self._bin, "-nocache", "qmake.pro"] |
375 return |
|
376 |
|
377 # do not use .qmake.cache when detecting the platform |
|
378 args = [self._qmake, "-nocache", os.path.split(filepath)[1]] |
|
379 if self._spec: |
446 if self._spec: |
380 args += ["-spec", self._spec] |
447 args += ["-spec", self._spec] |
381 (code, output) = run_process(args, "tmp") |
448 (code, output) = run_process(args, "tmp") |
|
449 |
|
450 # cleanup & check return |
382 shutil.rmtree("tmp", ignore_errors=True) |
451 shutil.rmtree("tmp", ignore_errors=True) |
383 if code != 0: |
452 if code != 0: |
384 self._error = "Unable to execute %s" % self._qmake |
453 self._error = "Unable to execute %s" % self._bin |
385 if self._qmake == "qmake": |
454 if self._bin == "qmake": |
386 self._error += ". Add qmake to PATH or pass --qmake-bin <path/to/qmake>." |
455 self._error += ". Add qmake to PATH or pass --qmake-bin <path/to/qmake>." |
387 |
456 return False |
|
457 |
|
458 # parse output |
388 try: |
459 try: |
389 self._platform = re.search("Project MESSAGE: platform:(\S+)", output).group(1) |
460 if not self._platform: |
390 self._version = re.search("Project MESSAGE: version:(\S+)", output).group(1) |
461 self._platform = re.search("Project MESSAGE: platform:(\S+)", output).group(1) |
391 self._qtdir = re.search("Project MESSAGE: libraries:(\S+)", output).group(1) |
|
392 self._features = re.search("Project MESSAGE: features:(\S+)", output).group(1) |
462 self._features = re.search("Project MESSAGE: features:(\S+)", output).group(1) |
|
463 self._qtversion = re.search("Project MESSAGE: qtversion:(\S+)", output).group(1) |
|
464 self._qtdir = re.search("Project MESSAGE: qtdir:(\S+)", output).group(1) |
393 except: |
465 except: |
394 self._error = "Unable to parse qmake output (%s)" % output.strip() |
466 self._error = "Unable to parse qmake output (%s)" % output.strip() |
395 if output.find("QMAKESPEC") != -1: |
467 if output.find("QMAKESPEC") != -1: |
396 self._error += ". Set QMAKESPEC environment variable or pass --qmake-spec <spec>." |
468 self._error += ". Set QMAKESPEC environment variable or pass --qmake-spec <spec>." |
397 return None |
|
398 |
|
399 def _detect_make(self): |
|
400 if self.name() == "win32" and Platform._test_make("nmake", "/?"): |
|
401 return "nmake" |
|
402 if Platform._test_make("make", "-v"): |
|
403 return "make" |
|
404 if Platform._test_make("gmake", "-v"): |
|
405 return "gmake" |
|
406 if self.name() == "win32" and Platform._test_make("mingw32-make", "-v"): |
|
407 return "mingw32-make" |
|
408 return "(n)make" |
|
409 |
|
410 def _test_make(command, param): |
|
411 try: |
|
412 return run_process([command, param])[0] == 0 |
|
413 except: |
|
414 return False |
469 return False |
415 |
470 return True |
416 _test_make = staticmethod(_test_make) |
471 |
|
472 # ============================================================================ |
|
473 # BuildEnvironment |
|
474 # ============================================================================ |
|
475 class BuildEnvironment: |
|
476 def __init__(self): |
|
477 self._blddir = os.path.abspath(os.getcwd()) |
|
478 self._srcdir = os.path.abspath(sys.path[0]) |
|
479 self._prefix = None |
|
480 self._bindir = None |
|
481 self._libdir = None |
|
482 self._docdir = None |
|
483 self._includedir = None |
|
484 self._pluginsdir = None |
|
485 self._featuresdir = None |
|
486 self._resourcesdir = None |
|
487 |
|
488 def init(self, options): |
|
489 # prefix |
|
490 if options.prefix: |
|
491 # explicit |
|
492 self._prefix = options.prefix |
|
493 elif options.developer: |
|
494 # developer mode implies a "local" build |
|
495 self._prefix = self._blddir |
|
496 else: |
|
497 # fall back to default |
|
498 self._prefix = self.default_prefix() |
|
499 if QMAKE.platform() != "symbian": |
|
500 self._prefix = os.path.abspath(self._prefix) |
|
501 |
|
502 self._bindir = self._dir_option(options.bindir, self._prefix + "/bin") |
|
503 self._libdir = self._dir_option(options.libdir, self._prefix + "/lib") |
|
504 self._docdir = self._dir_option(options.docdir, self._prefix + "/doc") |
|
505 self._includedir = self._dir_option(options.includedir, self._prefix + "/include") |
|
506 self._pluginsdir = self._dir_option(options.pluginsdir, self._prefix + "/plugins") |
|
507 self._featuresdir = self._dir_option(options.featuresdir, QMAKE.features()) |
|
508 self._resourcesdir = self._dir_option(options.resourcesdir, self._prefix + "/resources") |
|
509 |
|
510 # symbian specific adjustments |
|
511 if QMAKE.platform() == "symbian": |
|
512 # TODO: fix to "$${EPOCROOT}resource/hb/plugins" |
|
513 self._pluginsdir = "$${EPOCROOT}resource/qt/plugins/hb" |
|
514 |
|
515 if not options.developer: |
|
516 if os.path.isdir("/s60"): |
|
517 self._includedir = self._prefix + "/include/hb" |
|
518 else: |
|
519 self._includedir = self._prefix + "/include/mw/hb" |
|
520 |
|
521 def builddir(self): |
|
522 return self._blddir |
|
523 |
|
524 def sourcedir(self): |
|
525 return self._srcdir |
|
526 |
|
527 def prefix(self): |
|
528 return self._prefix |
|
529 |
|
530 def bindir(self): |
|
531 return self._bindir |
|
532 |
|
533 def libdir(self): |
|
534 return self._libdir |
|
535 |
|
536 def docdir(self): |
|
537 return self._docdir |
|
538 |
|
539 def includedir(self): |
|
540 return self._includedir |
|
541 |
|
542 def pluginsdir(self): |
|
543 return self._pluginsdir |
|
544 |
|
545 def featuresdir(self): |
|
546 return self._featuresdir |
|
547 |
|
548 def resourcesdir(self): |
|
549 return self._resourcesdir |
|
550 |
|
551 def exportdir(self, category=None): |
|
552 if os.path.isdir("/s60"): |
|
553 if category: |
|
554 return "hb/%1/" + category + "/%2" |
|
555 return "hb/%1/%2" |
|
556 else: |
|
557 if category: |
|
558 return "$${EPOCROOT}epoc32/include/mw/hb/%1/" + category + "/%2" |
|
559 return "$${EPOCROOT}epoc32/include/mw/hb/%1/%2" |
|
560 |
|
561 def default_prefix(self): |
|
562 prefixes = { "symbian" : "$${EPOCROOT}epoc32", |
|
563 "unix" : "/usr/local/hb", |
|
564 "macx" : "/usr/local/hb", |
|
565 "win32" : "C:/hb" } |
|
566 return prefixes.get(QMAKE.platform(), self._blddir) |
|
567 |
|
568 def local(self): |
|
569 prefix = self.prefix() |
|
570 return os.path.isdir(prefix) and (prefix == self._blddir) |
|
571 |
|
572 def _dir_option(self, explicit, default): |
|
573 if explicit: |
|
574 return explicit |
|
575 return default |
417 |
576 |
418 # ============================================================================ |
577 # ============================================================================ |
419 # ConfigTest |
578 # ConfigTest |
420 # ============================================================================ |
579 # ============================================================================ |
421 class ConfigTest: |
580 class ConfigTest: |
422 def __init__(self, platform): |
581 def __init__(self, sourcedir=os.getcwd(), builddir=os.getcwd()): |
423 self._make = platform.make() |
|
424 self._qmake = platform.qmake() |
|
425 self._platform = platform.name() |
|
426 self._spec = platform.spec() |
|
427 |
|
428 def setup(self, sourcedir, builddir): |
|
429 self._sourcedir = sourcedir |
582 self._sourcedir = sourcedir |
430 self._builddir = builddir |
583 self._builddir = builddir |
431 |
584 |
432 def compile(self, test): |
585 def compile(self, test): |
433 code = -1 |
586 code = -1 |
509 |
664 |
510 # ============================================================================ |
665 # ============================================================================ |
511 # main() |
666 # main() |
512 # ============================================================================ |
667 # ============================================================================ |
513 def main(): |
668 def main(): |
514 global HB_MAKE_PARTS, HB_NOMAKE_PARTS |
669 global QMAKE, MAKE, BUILDENV, HB_MAKE_PARTS, HB_NOMAKE_PARTS |
515 |
670 |
516 qmake = "qmake" |
671 help = False |
517 cmdline = " ".join(sys.argv[1:]) |
672 cmdline = " ".join(sys.argv[1:]) |
518 match = re.search("--qmake-bin[=\s](\S+)", cmdline) |
|
519 if match: |
|
520 qmake = match.group(1) |
|
521 |
|
522 # detect platform |
|
523 platform = Platform(qmake) |
|
524 match = re.search("--platform[=\s](\S+)", cmdline) |
|
525 if match: |
|
526 platform._platform = match.group(1) |
|
527 |
|
528 match = re.search("--qmake-spec[=\s](\S+)", cmdline) |
|
529 if match: |
|
530 platform._spec = match.group(1) |
|
531 |
|
532 help = False |
|
533 match = re.search("--help\s*", cmdline) |
673 match = re.search("--help\s*", cmdline) |
534 if match or re.search("-h\s*", cmdline): |
674 if match or re.search("-h\s*", cmdline): |
535 help = True |
675 help = True |
536 |
676 |
537 if not help and not platform.name(): |
677 QMAKE = QMake() |
538 print("ERROR: %s" % platform.error()) |
678 QMAKE.init(cmdline) |
|
679 |
|
680 if not help and not QMAKE.platform(): |
|
681 print("ERROR: %s" % QMAKE.error()) |
539 return |
682 return |
540 |
683 |
541 # detect make |
684 MAKE = Make() |
542 match = re.search("--make-bin[=\s](\S+)", cmdline) |
685 MAKE.init(cmdline) |
543 if match: |
686 |
544 platform._make = match.group(1) |
687 BUILDENV = BuildEnvironment() |
545 if not platform.make(): |
|
546 print("ERROR: %s" % platform.error()) |
|
547 return |
|
548 |
|
549 currentdir = os.path.abspath(os.getcwd()) |
|
550 sourcedir = os.path.abspath(sys.path[0]) |
|
551 |
|
552 # default prefixes |
|
553 prefixes = { "symbian" : "$${EPOCROOT}epoc32", |
|
554 "unix" : "/usr/local/hb", |
|
555 "macx" : "/usr/local/hb", |
|
556 "win32" : "C:/hb" } |
|
557 |
688 |
558 # parse command line options |
689 # parse command line options |
559 parser = OptionParser(platform.name(), platform.make(), prefixes.get(platform.name(), currentdir)) |
690 parser = OptionParser() |
560 (options, args) = parser.parse_args() |
691 (options, args) = parser.parse_args() |
|
692 |
|
693 BUILDENV.init(options) |
561 |
694 |
562 # coverage implies developer mode |
695 # coverage implies developer mode |
563 if options.coverage: |
696 if options.coverage: |
564 options.developer = True |
697 options.developer = True |
565 |
698 |
|
699 # developer mode implies tests, including perf & loc |
|
700 if options.developer: |
|
701 add_remove_part("tests", True) |
|
702 add_remove_part("performance", True) |
|
703 add_remove_part("localization", True) |
|
704 |
|
705 # developer mode implies developer exports |
|
706 if options.developer: |
|
707 options.developerexport = True |
|
708 |
566 print("Configuring Hb...") |
709 print("Configuring Hb...") |
567 print("INFO: Platform: %s" % platform.name()) |
710 print("INFO: Platform: %s" % QMAKE.platform()) |
568 print("INFO: Make: %s" % platform.make()) |
711 print("INFO: Make: %s" % MAKE.bin()) |
569 print("INFO: Qt: %s in %s" % (platform.version(), platform.qtdir())) |
712 print("INFO: Qt: %s in %s" % (QMAKE.qtversion(), QMAKE.qtdir())) |
570 |
|
571 # warn about deprecated options |
|
572 if options.qtanimation != None: |
|
573 print("WARNING: --qt-animation and --qt-no-animation are DEPRECATED. Qt 4.6 includes the animation framework.") |
|
574 if options.qtgestures != None: |
|
575 print("WARNING: --qt-gestures and --qt-no-gestures are DEPRECATED. Qt 4.6 includes the gestures framework.") |
|
576 if options.qts60eventfilter != None: |
|
577 print("WARNING: --qt-symbian-eventfilter and --qt-s60-eventfilter are DEPRECATED. Qt 4.6 includes QApplication::symbianEventFilter().") |
|
578 if options.inputs != None: |
|
579 print("WARNING: --no-inputs is DEPRECATED. Use --nomake hbinput.") |
|
580 add_remove_part("hbinput", options.inputs) |
|
581 if options.feedback != None: |
|
582 print("WARNING: --no-feedback is DEPRECATED. Use --nomake hbfeedback.") |
|
583 add_remove_part("hbfeedback", options.feedback) |
|
584 if options.tutorials != None: |
|
585 print("WARNING: --no-tutorials is DEPRECATED. Use --nomake tutorials.") |
|
586 add_remove_part("tutorials", options.tutorials) |
|
587 if options.tests != None: |
|
588 print("WARNING: --tests is DEPRECATED. Use --make tests.") |
|
589 add_remove_part("tests", options.tests) |
|
590 if options.performance != None: |
|
591 print("WARNING: --performance is DEPRECATED. Use --make performance.") |
|
592 add_remove_part("performance", options.performance) |
|
593 if options.localization != None: |
|
594 print("WARNING: --localization is DEPRECATED. Use --make localization.") |
|
595 add_remove_part("localization", options.localization) |
|
596 |
|
597 # sort out directories |
|
598 if not options.prefix: |
|
599 # developer mode implies local setup |
|
600 if options.developer: |
|
601 options.prefix = currentdir |
|
602 else: |
|
603 options.prefix = prefixes.get(platform.name(), currentdir) |
|
604 basedir = options.prefix |
|
605 if platform.name() != "symbian": |
|
606 basedir = os.path.abspath(basedir) |
|
607 |
|
608 local = os.path.isdir(basedir) and (basedir == currentdir) |
|
609 |
|
610 # generate local build wrapper headers |
|
611 synchb = "bin/synchb.py" |
|
612 if options.verbose: |
|
613 synchb = "%s -v" % synchb |
|
614 print("INFO: Running %s" % synchb) |
|
615 os.system("python %s/%s -i %s -o %s" % (sourcedir, synchb, sourcedir, currentdir)) |
|
616 |
|
617 # generate a qrc for resources |
|
618 args = [os.path.join(sourcedir, "bin/resourcifier.py")] |
|
619 args += ["-i", "%s" % os.path.join(sys.path[0], "src/hbcore/resources")] |
|
620 # TODO: make it currentdir |
|
621 args += ["-o", "%s" % os.path.join(sourcedir, "src/hbcore/resources/resources.qrc")] |
|
622 args += ["--exclude", "\"*distribution.policy.s60\""] |
|
623 args += ["--exclude", "\"*readme.txt\""] |
|
624 args += ["--exclude", "\"*.pr?\""] |
|
625 args += ["--exclude", "\"*.qrc\""] |
|
626 args += ["--exclude", "\"*~\""] |
|
627 args += ["--exclude", "variant/*"] |
|
628 if options.verbose: |
|
629 print("INFO: Running %s" % " ".join(args)) |
|
630 os.system("python %s" % " ".join(args)) |
|
631 |
713 |
632 # compilation tests to detect available features |
714 # compilation tests to detect available features |
633 config = ConfigFile() |
715 config = ConfigFile() |
634 test = ConfigTest(platform) |
716 test = ConfigTest(BUILDENV.sourcedir(), BUILDENV.builddir()) |
635 test.setup(sourcedir, currentdir) |
|
636 print("\nDetecting available features...") |
717 print("\nDetecting available features...") |
637 if options.qtmobility == None: |
718 if options.qtmobility == None: |
638 options.qtmobility = test.compile("config.tests/all/mobility") |
719 options.qtmobility = test.compile("config.tests/all/mobility") |
639 if options.qtmobility: |
720 if options.qtmobility: |
640 config.add_value("DEFINES", "HB_HAVE_QT_MOBILITY") |
721 config.add_value("DEFINES", "HB_HAVE_QT_MOBILITY") |
641 print("INFO: Qt Mobility:\t\t\t%s" % options.qtmobility) |
722 print("INFO: Qt Mobility:\t\t\t%s" % options.qtmobility) |
642 if platform.name() == "symbian": |
723 if options.qtopenvg == None: |
|
724 options.qtopenvg = test.compile("config.tests/all/openvg") |
|
725 if options.qtopenvg: |
|
726 config.add_value("DEFINES", "HB_EFFECTS_OPENVG") |
|
727 config.add_value("DEFINES", "HB_FILTER_EFFECTS") |
|
728 print("INFO: OpenVG:\t\t\t\t%s" % options.qtopenvg) |
|
729 if QMAKE.platform() == "symbian": |
643 sgimagelite_result = test.compile("config.tests/symbian/sgimagelite") |
730 sgimagelite_result = test.compile("config.tests/symbian/sgimagelite") |
644 if sgimagelite_result: |
731 if sgimagelite_result: |
645 config.add_value("CONFIG", "sgimage") |
732 config.add_value("CONFIG", "sgimage") |
646 print("INFO: SgImage-Lite:\t\t\t%s" % sgimagelite_result) |
733 print("INFO: SgImage-Lite:\t\t\t%s" % sgimagelite_result) |
647 if options.dui == None: |
734 tchunkcreateinfo_result = test.compile("config.tests/symbian/tchunkcreateinfo") |
648 options.dui = test.compile("config.tests/maemo/dui") |
735 if tchunkcreateinfo_result: |
649 if options.dui: |
736 config.add_value("DEFINES", "HB_HAVE_PROTECTED_CHUNK") |
650 config.add_value("CONFIG", "hb_maemo_dui") |
737 touchfeedback_result = test.compile("config.tests/symbian/touchfeedback") |
651 config.add_value("DEFINES", "HB_MAEMO_DUI") |
738 if touchfeedback_result: |
652 print("INFO: Direct UI:\t\t\t%s" % options.dui) |
739 config.add_value("DEFINES", "HB_TOUCHFEEDBACK_TYPE_IS_LONGPRESS") |
653 |
740 print("INFO: ETouchFeedbackLongPress:\t\t%s" % touchfeedback_result) |
654 # directories |
741 if options.meegotouch == None: |
655 if options.bindir == None: |
742 options.meegotouch = test.compile("config.tests/meego/meegotouch") |
656 # TODO: symbian |
743 if options.meegotouch: |
657 options.bindir = basedir + "/bin" |
744 config.add_value("CONFIG", "hb_meegotouch") |
658 if options.libdir == None: |
745 config.add_value("DEFINES", "HB_MEEGOTOUCH") |
659 # TODO: symbian |
746 print("INFO: MeeGo Touch:\t\t\t%s" % options.meegotouch) |
660 options.libdir = basedir + "/lib" |
747 |
661 if options.docdir == None: |
748 config.set_value("HB_INSTALL_DIR", ConfigFile.format_dir(BUILDENV.prefix())) |
662 # TODO: symbian |
749 config.set_value("HB_BIN_DIR", ConfigFile.format_dir(BUILDENV.bindir())) |
663 options.docdir = basedir + "/doc" |
750 config.set_value("HB_LIB_DIR", ConfigFile.format_dir(BUILDENV.libdir())) |
664 if options.includedir == None: |
751 config.set_value("HB_DOC_DIR", ConfigFile.format_dir(BUILDENV.docdir())) |
665 if platform.name() == "symbian" and not options.developer: |
752 config.set_value("HB_INCLUDE_DIR", ConfigFile.format_dir(BUILDENV.includedir())) |
666 if os.path.isdir("/s60"): |
753 config.set_value("HB_PLUGINS_DIR", ConfigFile.format_dir(BUILDENV.pluginsdir())) |
667 options.includedir = basedir + "/include/hb" |
754 config.set_value("HB_FEATURES_DIR", ConfigFile.format_dir(BUILDENV.featuresdir())) |
668 else: |
755 config.set_value("HB_RESOURCES_DIR", ConfigFile.format_dir(BUILDENV.resourcesdir())) |
669 options.includedir = basedir + "/include/mw/hb" |
|
670 else: |
|
671 options.includedir = basedir + "/include" |
|
672 if options.plugindir == None: |
|
673 if platform.name() == "symbian": |
|
674 # TODO: fix to "$${EPOCROOT}resource/hb/plugins" |
|
675 options.plugindir = "$${EPOCROOT}resource/qt/plugins/hb" |
|
676 else: |
|
677 options.plugindir = basedir + "/plugins" |
|
678 if options.featuredir == None: |
|
679 options.featuredir = platform.features() |
|
680 if options.resourcedir == None: |
|
681 # TODO: fix this, some components want to write resources... |
|
682 # thus, cannot point to the source tree! |
|
683 if not local: |
|
684 options.resourcedir = basedir + "/resources" |
|
685 else: |
|
686 options.resourcedir = sourcedir + "/src/hbcore/resources" |
|
687 |
|
688 config.set_value("HB_INSTALL_DIR", ConfigFile.format_dir(basedir)) |
|
689 config.set_value("HB_BIN_DIR", ConfigFile.format_dir(options.bindir)) |
|
690 config.set_value("HB_LIB_DIR", ConfigFile.format_dir(options.libdir)) |
|
691 config.set_value("HB_DOC_DIR", ConfigFile.format_dir(options.docdir)) |
|
692 config.set_value("HB_INCLUDE_DIR", ConfigFile.format_dir(options.includedir)) |
|
693 config.set_value("HB_PLUGINS_DIR", ConfigFile.format_dir(options.plugindir)) |
|
694 config.set_value("HB_RESOURCES_DIR", ConfigFile.format_dir(options.resourcedir)) |
|
695 config.set_value("HB_FEATURES_DIR", ConfigFile.format_dir(options.featuredir)) |
|
696 |
|
697 |
|
698 if os.name == "posix" or os.name == "mac": |
|
699 sharedmem = test.compile("config.tests/unix/sharedmemory") |
|
700 if sharedmem: |
|
701 (code, output) = run_process(["./hbconftest_sharedmemory"], "config.tests/unix/sharedmemory") |
|
702 sharedmem = (code == 0) |
|
703 if not sharedmem: |
|
704 print("DEBUG:%s" % output) |
|
705 print("INFO: Shared Memory:\t\t\t%s" % sharedmem) |
|
706 if not sharedmem: |
|
707 print("WARNING:The amount of available shared memory is too low!") |
|
708 print "\tTry adjusting the shared memory configuration", |
|
709 if os.path.exists("/proc/sys/kernel/shmmax"): |
|
710 print "(/proc/sys/kernel/shmmax)" |
|
711 elif os.path.exists("/etc/sysctl.conf"): |
|
712 print "(/etc/sysctl.conf)" |
|
713 |
|
714 |
|
715 |
756 |
716 # TODO: get rid of this! |
757 # TODO: get rid of this! |
717 if platform.name() == "symbian": |
758 if QMAKE.platform() == "symbian": |
718 config.set_value("HB_PLUGINS_EXPORT_DIR", ConfigFile.format_dir("$${EPOCROOT}epoc32/winscw/c/resource/qt/plugins/hb")) |
759 config.set_value("HB_PLUGINS_EXPORT_DIR", ConfigFile.format_dir("$${EPOCROOT}epoc32/winscw/c/resource/qt/plugins/hb")) |
719 |
760 |
720 if options.gestures: |
761 if options.gestures: |
721 config.add_value("DEFINES", "HB_GESTURE_FW") |
762 config.add_value("DEFINES", "HB_GESTURE_FW") |
722 if options.effects: |
763 if options.effects: |
723 config.add_value("DEFINES", "HB_EFFECTS") |
764 config.add_value("DEFINES", "HB_EFFECTS") |
724 if options.textMeasurement: |
765 if options.textMeasurement: |
725 config.add_value("DEFINES", "HB_TEXT_MEASUREMENT_UTILITY") |
766 config.add_value("DEFINES", "HB_TEXT_MEASUREMENT_UTILITY") |
726 if platform.name() != "symbian" and options.developer: |
767 if QMAKE.platform() != "symbian" and options.developer: |
727 config.add_value("DEFINES", "HB_CSS_INSPECTOR") |
768 config.add_value("DEFINES", "HB_CSS_INSPECTOR") |
728 if options.defines: |
769 if options.defines: |
729 config.add_value("DEFINES", " ".join(options.defines.split(","))) |
770 config.add_value("DEFINES", " ".join(options.defines.split(","))) |
730 if options.developer: |
771 if options.developerexport: |
731 config.add_value("DEFINES", "HB_DEVELOPER") |
772 config.add_value("DEFINES", "HB_DEVELOPER") |
|
773 if options.rpath == None or options.rpath == True: |
|
774 config.add_value("QMAKE_RPATHDIR", "$${HB_LIB_DIR}") |
732 |
775 |
733 if options.verbose: |
776 if options.verbose: |
734 print("INFO: Writing hb_install.prf") |
777 print("INFO: Writing hb_install.prf") |
735 if not config.write("hb_install.prf"): |
778 if not config.write("hb_install.prf"): |
736 print("ERROR: Unable to write hb_install_prf.") |
779 print("ERROR: Unable to write hb_install_prf.") |
737 return |
780 return |
738 |
781 |
739 config.set_value("HB_BUILD_DIR", ConfigFile.format_dir(currentdir)) |
782 config.set_value("HB_BUILD_DIR", ConfigFile.format_dir(BUILDENV.builddir())) |
740 config.set_value("HB_SOURCE_DIR", ConfigFile.format_dir(sourcedir)) |
783 config.set_value("HB_SOURCE_DIR", ConfigFile.format_dir(BUILDENV.sourcedir())) |
741 config.set_value("HB_MKSPECS_DIR", ConfigFile.format_dir(basedir + "/mkspecs")) |
784 if QMAKE.platform() == "symbian": |
742 |
785 config.set_value("HB_EXPORT_DIR", ConfigFile.format_dir(BUILDENV.exportdir())) |
743 if platform.name() == "symbian": |
786 config.set_value("HB_RESTRICTED_EXPORT_DIR", ConfigFile.format_dir(BUILDENV.exportdir("restricted"))) |
744 if os.path.isdir("/s60"): |
|
745 config.set_value("HB_EXPORT_DIR", "hb/%1/%2") |
|
746 config.set_value("HB_PRIVATE_EXPORT_DIR", "hb/%1/private/%2") |
|
747 else: |
|
748 config.set_value("HB_EXPORT_DIR", "$${EPOCROOT}epoc32/include/mw/hb/%1/%2") |
|
749 config.set_value("HB_PRIVATE_EXPORT_DIR", "$${EPOCROOT}epoc32/include/mw/hb/%1/private/%2") |
|
750 |
|
751 if options.developer: |
|
752 add_remove_part("tests", True) |
|
753 add_remove_part("performance", True) |
|
754 add_remove_part("localization", True) |
|
755 |
787 |
756 if options.make: |
788 if options.make: |
757 for part in options.make: |
789 for part in options.make: |
758 add_remove_part(part, True) |
790 add_remove_part(part, True) |
759 if options.nomake: |
791 if options.nomake: |
808 config._lines.append(" DEFINES += QT_NO_DEBUG_OUTPUT\n") |
840 config._lines.append(" DEFINES += QT_NO_DEBUG_OUTPUT\n") |
809 config._lines.append(" DEFINES += QT_NO_WARNING_OUTPUT\n") |
841 config._lines.append(" DEFINES += QT_NO_WARNING_OUTPUT\n") |
810 config._lines.append(" }\n") |
842 config._lines.append(" }\n") |
811 config._lines.append("}\n") |
843 config._lines.append("}\n") |
812 |
844 |
|
845 # ensure that no QString(0) -like constructs slip in |
|
846 config.add_value("DEFINES", "QT_QCHAR_CONSTRUCTOR") |
|
847 |
813 # TODO: is there any better way to expose functions to the whole source tree? |
848 # TODO: is there any better way to expose functions to the whole source tree? |
814 config._lines.append("include(%s)\n" % (os.path.splitdrive(sourcedir)[1] + "/mkspecs/hb_functions.prf")) |
849 config._lines.append("include(%s)\n" % (os.path.splitdrive(BUILDENV.sourcedir())[1] + "/mkspecs/hb_functions.prf")) |
815 |
850 |
816 if options.verbose: |
851 if options.verbose: |
817 print("INFO: Writing .qmake.cache") |
852 print("INFO: Writing .qmake.cache") |
818 if not config.write(".qmake.cache"): |
853 if not config.write(".qmake.cache"): |
819 print("ERROR: Unable to write .qmake.cache.") |
854 print("ERROR: Unable to write .qmake.cache.") |
820 return |
855 return |
821 |
856 |
|
857 if os.name == "posix" or os.name == "mac": |
|
858 sharedmem = test.compile("config.tests/unix/sharedmemory") |
|
859 if sharedmem: |
|
860 (code, output) = run_process(["./hbconftest_sharedmemory"], "config.tests/unix/sharedmemory") |
|
861 sharedmem = (code == 0) |
|
862 if not sharedmem: |
|
863 print("DEBUG:%s" % output) |
|
864 print("INFO: Shared Memory:\t\t\t%s" % sharedmem) |
|
865 if not sharedmem: |
|
866 print("WARNING:The amount of available shared memory is too low!") |
|
867 print "\tTry adjusting the shared memory configuration", |
|
868 if os.path.exists("/proc/sys/kernel/shmmax"): |
|
869 print "(/proc/sys/kernel/shmmax)" |
|
870 elif os.path.exists("/etc/sysctl.conf"): |
|
871 print "(/etc/sysctl.conf)" |
|
872 |
|
873 # generate local build wrapper headers |
|
874 print("\nGenerating files...") |
|
875 print("INFO: Wrapper headers") |
|
876 synchb = "bin/synchb.py" |
|
877 if options.verbose: |
|
878 print("INFO: Running %s" % synchb) |
|
879 synchb = "%s -v" % synchb |
|
880 os.system("python %s/%s -i %s -o %s" % (BUILDENV.sourcedir(), synchb, BUILDENV.sourcedir(), BUILDENV.builddir())) |
|
881 |
|
882 # generate a qrc for resources |
|
883 print("INFO: Qt resource collection") |
|
884 args = [os.path.join(BUILDENV.sourcedir(), "bin/resourcifier.py")] |
|
885 args += ["-i", "%s" % os.path.join(sys.path[0], "src/hbcore/resources")] |
|
886 # TODO: make it BUILDENV.builddir() |
|
887 args += ["-o", "%s" % os.path.join(BUILDENV.sourcedir(), "src/hbcore/resources/resources.qrc")] |
|
888 args += ["--exclude", "\"*distribution.policy.s60\""] |
|
889 args += ["--exclude", "\"*readme.txt\""] |
|
890 args += ["--exclude", "\"*.pr?\""] |
|
891 args += ["--exclude", "\"*.qrc\""] |
|
892 args += ["--exclude", "\"*~\""] |
|
893 args += ["--exclude", "variant/*"] |
|
894 args += ["--exclude", "\"*hbdefault.cssbin\""] |
|
895 |
|
896 if QMAKE.platform() != "symbian": |
|
897 args += ["--exclude", "\"*symbian*\""] |
|
898 if QMAKE.platform() != "macx": |
|
899 args += ["--exclude", "\"*macx*\""] |
|
900 if QMAKE.platform() != "unix": |
|
901 args += ["--exclude", "\"*unix*\""] |
|
902 if QMAKE.platform() != "win32": |
|
903 args += ["--exclude", "\"*win32*\""] |
|
904 |
|
905 if options.verbose: |
|
906 print("INFO: Running %s" % " ".join(args)) |
|
907 os.system("python %s" % " ".join(args)) |
|
908 |
822 # build host tools |
909 # build host tools |
823 if platform.name() == "symbian" or options.hostqmakebin != None or options.hostmakebin != None: |
910 if QMAKE.platform() == "symbian" or options.hostqmakebin != None or options.hostmakebin != None: |
824 print("\nBuilding host tools...") |
911 print("\nBuilding host tools...") |
825 if options.hostqmakebin != None and options.hostmakebin != None: |
912 if options.hostqmakebin != None and options.hostmakebin != None: |
826 profile = "%s/src/hbtools/hbtools.pro" % sourcedir |
913 profile = "%s/src/hbtools/hbtools.pro" % BUILDENV.sourcedir() |
827 if os.path.exists(profile): |
914 if os.path.exists(profile): |
828 toolsdir = os.path.join(currentdir, "src/hbtools") |
915 toolsdir = os.path.join(BUILDENV.builddir(), "src/hbtools") |
829 if not os.path.exists(toolsdir): |
916 if not os.path.exists(toolsdir): |
830 os.makedirs(toolsdir) |
917 os.makedirs(toolsdir) |
831 os.chdir(toolsdir) |
918 os.chdir(toolsdir) |
832 os.system("\"%s\" -config silent %s" % (options.hostqmakebin, profile)) |
919 os.system("\"%s\" -config silent %s" % (options.hostqmakebin, profile)) |
833 os.system("\"%s\"" % (options.hostmakebin)) |
920 os.system("\"%s\"" % (options.hostmakebin)) |
834 os.chdir(currentdir) |
921 os.chdir(BUILDENV.builddir()) |
835 else: |
922 else: |
836 print("WARNING: Cannot build host tools, because no --host-qmake-bin and/or") |
923 print("WARNING: Cannot build host tools, because no --host-qmake-bin and/or") |
837 print(" --host-make-bin was provided. Hb will attempt to run host") |
924 print(" --host-make-bin was provided. Hb will attempt to run host") |
838 print(" tools from PATH.") |
925 print(" tools from PATH.") |
839 |
926 |
840 # run qmake |
927 # run qmake |
841 if options.qmakebin: |
928 profile = os.path.join(BUILDENV.sourcedir(), "hb.pro") |
842 qmake = options.qmakebin |
929 QMAKE.add_args(["-cache", os.path.join(BUILDENV.builddir(), ".qmake.cache")]) |
843 profile = os.path.join(sourcedir, "hb.pro") |
|
844 cachefile = os.path.join(currentdir, ".qmake.cache") |
|
845 if options.msvc: |
930 if options.msvc: |
846 qmake = "%s -tp vc" % qmake |
931 QMAKE.add_args(["-tp", "vc"]) |
847 if not options.fast: |
932 if not options.fast: |
848 qmake = "%s -r" % qmake |
933 QMAKE.add_args(["-r"]) |
849 if options.qmakespec: |
|
850 qmake = "%s -spec %s" % (qmake, options.qmakespec) |
|
851 if options.qmakeopt: |
|
852 qmake = "%s \\\"%s\\\"" % (qmake, options.qmakeopt) |
|
853 if options.verbose: |
934 if options.verbose: |
854 print("\nRunning %s -cache %s %s" % (qmake, cachefile, profile)) |
935 print("\nRunning %s" % QMAKE.command(profile)) |
855 else: |
936 else: |
856 print("\nRunning qmake...") |
937 print("\nRunning qmake...") |
857 try: |
938 try: |
858 ret = os.system("%s -cache %s %s" % (qmake, cachefile, profile)) |
939 ret = run_system(QMAKE.command(profile)) |
859 except KeyboardInterrupt: |
940 except KeyboardInterrupt: |
860 ret = -1 |
941 ret = -1 |
861 if ret != 0: |
942 if ret != 0: |
862 print("") |
943 print("") |
863 print("ERROR: Aborted!") |
944 print("ERROR: Aborted!") |
864 print("") |
945 print("") |
865 return |
946 return |
866 |
947 |
867 if "tests" not in HB_NOMAKE_PARTS: |
948 if "tests" not in HB_NOMAKE_PARTS: |
868 # run qmake for tests |
949 # run qmake for tests |
869 profile = "%s/tsrc/tsrc.pro" % sourcedir |
950 profile = "%s/tsrc/tsrc.pro" % BUILDENV.sourcedir() |
870 if os.path.exists(profile): |
951 if os.path.exists(profile): |
871 tsrcdir = os.path.join(currentdir, "tsrc") |
952 tsrcdir = os.path.join(BUILDENV.builddir(), "tsrc") |
872 if not os.path.exists(tsrcdir): |
953 if not os.path.exists(tsrcdir): |
873 os.makedirs(tsrcdir) |
954 os.makedirs(tsrcdir) |
874 os.chdir(tsrcdir) |
955 os.chdir(tsrcdir) |
875 if options.verbose: |
956 if options.verbose: |
876 print("\nRunning %s %s" % (qmake, profile)) |
957 print("\nRunning %s" % QMAKE.command(profile)) |
877 else: |
958 else: |
878 print("\nRunning qmake in tsrc...") |
959 print("\nRunning qmake in tsrc...") |
879 os.system("%s %s" % (qmake, profile)) |
960 run_system(QMAKE.command(profile)) |
880 os.chdir(currentdir) |
961 os.chdir(BUILDENV.builddir()) |
881 |
962 |
882 # create output dirs |
963 # create output dirs |
883 outputdir = os.path.join(currentdir, "autotest") |
964 outputdir = os.path.join(BUILDENV.builddir(), "autotest") |
884 if not os.path.exists(outputdir): |
965 if not os.path.exists(outputdir): |
885 os.makedirs(outputdir) |
966 os.makedirs(outputdir) |
886 outputdir = os.path.join(currentdir, "coverage") |
967 outputdir = os.path.join(BUILDENV.builddir(), "coverage") |
887 if not os.path.exists(outputdir): |
968 if not os.path.exists(outputdir): |
888 os.makedirs(outputdir) |
969 os.makedirs(outputdir) |
889 # nag about tests that are commented out |
970 # nag about tests that are commented out |
890 result = grep(sourcedir + "/tsrc", "#\s*SUBDIRS\s*\+=\s*(\S+)", ["*.pr?"]) |
971 result = grep(BUILDENV.sourcedir() + "/tsrc", "#\s*SUBDIRS\s*\+=\s*(\S+)", ["*.pr?"]) |
891 maxlen = 0 |
972 maxlen = 0 |
892 for profile in result: |
973 for profile in result: |
893 maxlen = max(maxlen, len(profile)) |
974 maxlen = max(maxlen, len(profile)) |
894 if len(result): |
975 if len(result): |
895 print "" |
976 print "" |