diff options
author | Alexis Jeandet <alexis.jeandet@member.fsf.org> | 2018-04-04 01:06:43 +0200 |
---|---|---|
committer | Alexis Jeandet <alexis.jeandet@member.fsf.org> | 2018-04-04 01:06:43 +0200 |
commit | b4cd949c48ab67891e4bc6b14a8f9f247e28777d (patch) | |
tree | aadef1060ca47237291454781d26086bab632837 | |
parent | ebeb248c07693da5e5f4f7b80fafadd98939d045 (diff) | |
download | meson-b4cd949c48ab67891e4bc6b14a8f9f247e28777d.zip meson-b4cd949c48ab67891e4bc6b14a8f9f247e28777d.tar.gz meson-b4cd949c48ab67891e4bc6b14a8f9f247e28777d.tar.bz2 |
[Qt module] More qrc fixes
When several qrc files are given all qrc files dependencies were mixed.
Fixed non working use case:
When user try to guess build dir layout and add use a relative
path between a generated qrc file and a generated resource.
Signed-off-by: Alexis Jeandet <alexis.jeandet@member.fsf.org>
-rw-r--r-- | mesonbuild/modules/qt.py | 18 | ||||
-rw-r--r-- | test cases/frameworks/4 qt/subfolder/main.cpp | 25 | ||||
-rw-r--r-- | test cases/frameworks/4 qt/subfolder/meson.build | 3 | ||||
-rw-r--r-- | test cases/frameworks/4 qt/subfolder/resources/stuff4.qrc.in | 1 |
4 files changed, 28 insertions, 19 deletions
diff --git a/mesonbuild/modules/qt.py b/mesonbuild/modules/qt.py index 1625218..a306af7 100644 --- a/mesonbuild/modules/qt.py +++ b/mesonbuild/modules/qt.py @@ -74,10 +74,10 @@ class QtBaseModule: def parse_qrc(self, state, rcc_file): if type(rcc_file) is str: abspath = os.path.join(state.environment.source_dir, state.subdir, rcc_file) - relative_part = os.path.dirname(rcc_file) + rcc_dirname = os.path.dirname(abspath) elif type(rcc_file) is File: abspath = rcc_file.absolute_path(state.environment.source_dir, state.environment.build_dir) - relative_part = os.path.dirname(abspath) + rcc_dirname = os.path.dirname(abspath) try: tree = ET.parse(abspath) @@ -102,13 +102,14 @@ class QtBaseModule: else: result.append(File(is_built=False, subdir=state.subdir, fname=resource_path)) else: + path_from_build = os.path.normpath(os.path.join(state.environment.build_dir, resource_path)) + path_from_rcc = os.path.join(rcc_dirname, resource_path) # a) - if os.path.exists(state.environment.build_dir + resource_path): + if path_from_build.startswith(state.environment.build_dir) and not os.path.exists(path_from_rcc): result.append(File(is_built=True, subdir=state.subdir, fname=resource_path)) # b) else: - result.append(File(is_built=False, subdir=state.subdir, - fname=os.path.join(relative_part, resource_path))) + result.append(File(is_built=False, subdir=state.subdir, fname=path_from_rcc)) return result except Exception: return [] @@ -127,11 +128,11 @@ class QtBaseModule: if len(rcc_files) > 0: if not self.rcc.found(): raise MesonException(err_msg.format('RCC', 'rcc-qt{}'.format(self.qt_version), self.qt_version)) - qrc_deps = [] - for i in rcc_files: - qrc_deps += self.parse_qrc(state, i) # custom output name set? -> one output file, multiple otherwise if len(args) > 0: + qrc_deps = [] + for i in rcc_files: + qrc_deps += self.parse_qrc(state, i) name = args[0] rcc_kwargs = {'input': rcc_files, 'output': name + '.cpp', @@ -141,6 +142,7 @@ class QtBaseModule: sources.append(res_target) else: for rcc_file in rcc_files: + qrc_deps = self.parse_qrc(state, rcc_file) if type(rcc_file) is str: basename = os.path.basename(rcc_file) elif type(rcc_file) is File: diff --git a/test cases/frameworks/4 qt/subfolder/main.cpp b/test cases/frameworks/4 qt/subfolder/main.cpp index 042288b..9661811 100644 --- a/test cases/frameworks/4 qt/subfolder/main.cpp +++ b/test cases/frameworks/4 qt/subfolder/main.cpp @@ -8,19 +8,22 @@ int main(int argc, char **argv) { Q_INIT_RESOURCE(stuff4); #endif - QImage img1(":/thing.png"); - if(img1.width() != 640) { - return 1; - } - QImage img2(":/thing4.png"); - if(img2.width() != 640) { - return 1; + for(auto fname:{":/thing.png", ":/thing4.png"}) + { + QImage img1(fname); + if(img1.width() != 640) { + return 1; + } } - QFile file(":/txt_resource.txt"); - if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) + + for(auto fname:{":/txt_resource.txt",":/txt_resource2.txt"}) + { + QFile file(fname); + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) return 1; - QString line = file.readLine(); - if(line.compare("Hello World")) + QString line = file.readLine(); + if(line.compare("Hello World")) return 1; + } return 0; }
\ No newline at end of file diff --git a/test cases/frameworks/4 qt/subfolder/meson.build b/test cases/frameworks/4 qt/subfolder/meson.build index 0b54df7..f1b84e6 100644 --- a/test cases/frameworks/4 qt/subfolder/meson.build +++ b/test cases/frameworks/4 qt/subfolder/meson.build @@ -10,6 +10,9 @@ cfg = configuration_data() cfg.set('filepath', meson.current_source_dir()+'/../thing2.png') cfg.set('txt_resource', txt_resource.full_path()) +# here we abuse the system by guessing build dir layout +cfg.set('txt_resource2', 'txt_resource.txt') + rc_file = configure_file( configuration : cfg, diff --git a/test cases/frameworks/4 qt/subfolder/resources/stuff4.qrc.in b/test cases/frameworks/4 qt/subfolder/resources/stuff4.qrc.in index 97e2778..c30a358 100644 --- a/test cases/frameworks/4 qt/subfolder/resources/stuff4.qrc.in +++ b/test cases/frameworks/4 qt/subfolder/resources/stuff4.qrc.in @@ -3,5 +3,6 @@ <qresource> <file alias="thing4.png">@filepath@</file> <file alias="txt_resource.txt">@txt_resource@</file> + <file alias="txt_resource2.txt">@txt_resource2@</file> </qresource> </RCC> |