diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2015-04-08 23:05:14 +0300 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2015-04-08 23:05:14 +0300 |
commit | bfa68aaeaff35ad59110ca34cd4afc6cc8238f29 (patch) | |
tree | 941f4a11a2133fb735725ec29b16fd0c3d31e013 | |
parent | c89bbae0ad9136031b35928688700aff6dc05334 (diff) | |
download | meson-bfa68aaeaff35ad59110ca34cd4afc6cc8238f29.zip meson-bfa68aaeaff35ad59110ca34cd4afc6cc8238f29.tar.gz meson-bfa68aaeaff35ad59110ca34cd4afc6cc8238f29.tar.bz2 |
Autodetect Qt5 rcc dependencies as well as reasonably possible.
-rw-r--r-- | build.py | 1 | ||||
-rw-r--r-- | modules/qt5.py | 23 | ||||
-rw-r--r-- | ninjabackend.py | 3 | ||||
-rw-r--r-- | test cases/frameworks/4 qt5/meson.build | 10 | ||||
-rw-r--r-- | test cases/frameworks/4 qt5/stuff.qrc | 11 |
5 files changed, 39 insertions, 9 deletions
@@ -555,6 +555,7 @@ class GeneratedList(): self.infilelist = [] self.outfilelist = [] self.outmap = {} + self.extra_depends = [] def add_file(self, newfile): self.infilelist.append(newfile) diff --git a/modules/qt5.py b/modules/qt5.py index 2b9e7d8..5312416 100644 --- a/modules/qt5.py +++ b/modules/qt5.py @@ -16,6 +16,7 @@ import dependencies, mlog import os, subprocess import build from coredata import MesonException +import xml.etree.ElementTree as ET class Qt5Module(): @@ -87,6 +88,22 @@ class Qt5Module(): else: mlog.log(' rcc:', mlog.red('NO')) + def parse_qrc(self, state, fname): + abspath = os.path.join(state.environment.source_dir, state.subdir, fname) + try: + tree = ET.parse(abspath) + root = tree.getroot() + result = [] + for child in root[0]: + if child.tag != 'file': + mlog.log("Warning, malformed rcc file: ", os.path.join(state.subdir, fname)) + break + else: + result.append(os.path.join(state.subdir, child.text)) + return result + except Exception: + return [] + def preprocess(self, state, args, kwargs): rcc_files = kwargs.pop('qresources', []) if not isinstance(rcc_files, list): @@ -109,6 +126,10 @@ class Qt5Module(): '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) if len(ui_files) > 0: @@ -135,4 +156,6 @@ class Qt5Module(): return sources def initialize(): + mlog.log('Warning, rcc dependencies will not work properly until this upstream issue is fixed:', + mlog.bold('https://bugreports.qt.io/browse/QTBUG-45460')) return Qt5Module() diff --git a/ninjabackend.py b/ninjabackend.py index 741e72d..adfc59f 100644 --- a/ninjabackend.py +++ b/ninjabackend.py @@ -998,6 +998,7 @@ rule FORTRAN_DEP_HACK else: exe_arr = exe.get_command() base_args = generator.get_arglist() + extra_dependencies = [os.path.join(self.build_to_src, i) for i in genlist.extra_depends] for i in range(len(infilelist)): if len(generator.outputs) == 1: sole_output = os.path.join(self.get_target_private_dir(target), outfilelist[i]) @@ -1014,6 +1015,8 @@ rule FORTRAN_DEP_HACK for x in args] cmdlist = exe_arr + args elem = NinjaBuildElement(outfiles, 'CUSTOM_COMMAND', infilename) + if len(extra_dependencies) > 0: + elem.add_dep(extra_dependencies) elem.add_item('DESC', 'Generating $out') if isinstance(exe, build.BuildTarget): elem.add_dep(self.get_target_filename(exe)) diff --git a/test cases/frameworks/4 qt5/meson.build b/test cases/frameworks/4 qt5/meson.build index 9542331..ae85d1d 100644 --- a/test cases/frameworks/4 qt5/meson.build +++ b/test cases/frameworks/4 qt5/meson.build @@ -7,12 +7,14 @@ if meson.get_compiler('cpp').get_id() != 'msvc' add_global_arguments('-std=c++11', language : 'cpp') endif +prep = qt5.preprocess(moc_headers : ['mainWindow.h'], # These need to be fed through the moc tool before use. + ui_files : 'mainWindow.ui', # XML files that need to be compiled with the uic tol. + qresources : 'stuff.qrc', # Resource file for rcc compiler. +) + q5exe = executable('qt5app', sources : ['main.cpp', 'mainWindow.cpp', # Sources that don't need preprocessing. -qt5.preprocess(moc_headers : ['mainWindow.h'], # These need to be fed through the moc tool before use. - ui_files : 'mainWindow.ui', # XML files that need to be compiled with the uic tol. - qresources : 'stuff.qrc', # Resource file for rcc compiler. -)], +prep], dependencies : qt5dep) # We need a console test application because some test environments diff --git a/test cases/frameworks/4 qt5/stuff.qrc b/test cases/frameworks/4 qt5/stuff.qrc index 48f8fda..9152500 100644 --- a/test cases/frameworks/4 qt5/stuff.qrc +++ b/test cases/frameworks/4 qt5/stuff.qrc @@ -1,6 +1,7 @@ -<!DOCTYPE RCC><RCC version="1.0"> -<qresource> - <file>thing.png</file> - <file>thing2.png</file> -</qresource> +<!DOCTYPE RCC> +<RCC version="1.0"> + <qresource> + <file>thing.png</file> + <file>thing2.png</file> + </qresource> </RCC> |