From c565fb97c2925b66f81e05ffb6a394d3d53173a0 Mon Sep 17 00:00:00 2001 From: Tobias Markmann Date: Tue, 16 Jun 2015 00:06:31 +0200 Subject: Have SCons qt4 tool check for real moc or qtchooser Some platforms, e.g. KUbuntu, provide a wrapper around Qt's commands that allow easy switching between different Qt versions. With this change SCons will execute the found moc tool and check whether it works or not. Test-Information: Tested with correctly installed Qt and uninstalled Qt on KUbuntu 14.04. Change-Id: I88f0a36af462e909829c30115aa5481abdcd3ac6 diff --git a/BuildTools/SCons/Tools/qt4.py b/BuildTools/SCons/Tools/qt4.py index afa61de..625f807 100644 --- a/BuildTools/SCons/Tools/qt4.py +++ b/BuildTools/SCons/Tools/qt4.py @@ -36,6 +36,7 @@ __revision__ = "/home/scons/scons/branch.0/branch.96/baseline/src/engine/SCons/T import os.path import re +import subprocess import SCons.Action import SCons.Builder @@ -207,14 +208,18 @@ def _detect(env): else : moc = env.WhereIs('moc-qt4') or env.WhereIs('moc4') or env.WhereIs('moc') if moc: - import sys - if sys.platform == "darwin" : - return "" - QTDIR = os.path.dirname(os.path.dirname(moc)) - SCons.Warnings.warn( - QtdirNotFound, - "QTDIR variable is not defined, using moc executable as a hint (QTDIR=%s)" % QTDIR) - return QTDIR + # Test whether the moc command we found is real, or whether it is just the qtchooser dummy. + p = subprocess.Popen([moc, "-v"], shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE) + p.communicate() + if p.returncode == 0: + import sys + if sys.platform == "darwin" : + return "" + QTDIR = os.path.dirname(os.path.dirname(moc)) + SCons.Warnings.warn( + QtdirNotFound, + "QTDIR variable is not defined, using moc executable as a hint (QTDIR=%s)" % QTDIR) + return QTDIR raise SCons.Errors.StopError( QtdirNotFound, -- cgit v0.10.2-6-g49f6