aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/modules/qt4.py
diff options
context:
space:
mode:
Diffstat (limited to 'mesonbuild/modules/qt4.py')
-rw-r--r--mesonbuild/modules/qt4.py47
1 files changed, 26 insertions, 21 deletions
diff --git a/mesonbuild/modules/qt4.py b/mesonbuild/modules/qt4.py
index 1c5a0d1..5108baa 100644
--- a/mesonbuild/modules/qt4.py
+++ b/mesonbuild/modules/qt4.py
@@ -12,26 +12,27 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from .. import dependencies, mlog
import os, subprocess
+from .. import mlog
from .. import build
from ..mesonlib import MesonException
+from ..dependencies import Qt4Dependency
import xml.etree.ElementTree as ET
class Qt4Module():
- def __init__(self):
- mlog.log('Detecting Qt tools.')
- # The binaries have different names on different
- # distros. Joy.
- self.moc = dependencies.ExternalProgram('moc-qt4', silent=True)
- if not self.moc.found():
- self.moc = dependencies.ExternalProgram('moc', silent=True)
- self.uic = dependencies.ExternalProgram('uic-qt4', silent=True)
- if not self.uic.found():
- self.uic = dependencies.ExternalProgram('uic', silent=True)
- self.rcc = dependencies.ExternalProgram('rcc-qt4', silent=True)
- if not self.rcc.found():
- self.rcc = dependencies.ExternalProgram('rcc', silent=True)
+ tools_detected = False
+
+ def _detect_tools(self, env):
+ if self.tools_detected:
+ return
+ mlog.log('Detecting Qt4 tools')
+ # FIXME: We currently require Qt4 to exist while importing the module.
+ # We should make it gracefully degrade and not create any targets if
+ # the import is marked as 'optional' (not implemented yet)
+ kwargs = {'required': 'true', 'modules': 'Core', 'silent': 'true'}
+ qt4 = Qt4Dependency(env, kwargs)
+ # Get all tools and then make sure that they are the right version
+ self.moc, self.uic, self.rcc = qt4.compilers_detect()
# Moc, uic and rcc write their version strings to stderr.
# Moc and rcc return a non-zero result when doing so.
# What kind of an idiot thought that was a good idea?
@@ -80,6 +81,7 @@ class Qt4Module():
% (' '.join(self.rcc.fullpath), rcc_ver.split()[-1]))
else:
mlog.log(' rcc:', mlog.red('NO'))
+ self.tools_detected = True
def parse_qrc(self, state, fname):
abspath = os.path.join(state.environment.source_dir, state.subdir, fname)
@@ -115,6 +117,7 @@ class Qt4Module():
if not isinstance(srctmp, list):
srctmp = [srctmp]
sources = args[1:] + srctmp
+ self._detect_tools(state.environment)
err_msg = "{0} sources specified and couldn't find {1}, " \
"please check your qt4 installation"
if len(moc_headers) + len(moc_sources) > 0 and not self.moc.found():
@@ -122,16 +125,18 @@ class Qt4Module():
if len(rcc_files) > 0:
if not self.rcc.found():
raise MesonException(err_msg.format('RCC', 'rcc-qt4'))
- rcc_kwargs = {'output' : '@BASENAME@.cpp',
- 'arguments' : ['@INPUT@', '-o', '@OUTPUT@']}
- rcc_gen = build.Generator([self.rcc], rcc_kwargs)
- rcc_output = build.GeneratedList(rcc_gen)
qrc_deps = []
for i in rcc_files:
qrc_deps += self.parse_qrc(state, i)
- rcc_output.extra_depends = qrc_deps
- [rcc_output.add_file(os.path.join(state.subdir, a)) for a in rcc_files]
- sources.append(rcc_output)
+ basename = os.path.split(rcc_files[0])[1]
+ name = 'qt4-' + basename.replace('.', '_')
+ rcc_kwargs = {'input' : rcc_files,
+ 'output' : name + '.cpp',
+ 'command' : [self.rcc, '-o', '@OUTPUT@', '@INPUT@'],
+ 'depend_files' : qrc_deps,
+ }
+ res_target = build.CustomTarget(name, state.subdir, rcc_kwargs)
+ sources.append(res_target)
if len(ui_files) > 0:
if not self.uic.found():
raise MesonException(err_msg.format('UIC', 'uic-qt4'))