From 8b073325ea11d0e86092a8aae72535f16e70be35 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Mon, 1 Jan 2018 11:25:28 +0100 Subject: [PATCH] Rakefile: Qt: handle #includes in .h for .ui-based .h, too --- Rakefile | 2 +- rake.d/target.rb | 27 +++++++++++++-------------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/Rakefile b/Rakefile index 19aa7f638..1577272f2 100644 --- a/Rakefile +++ b/Rakefile @@ -946,7 +946,7 @@ end new("#{[ lib[:dir] ].flatten.first}/lib#{lib[:name]}"). sources([ lib[:dir] ].flatten, :type => :dir, :except => lib[:except]). only_if(c?(:USE_QT) && (lib[:name] == 'mtxcommon')). - sources(FileList["src/common/*.h"].select { |h| read_files(h)[h].any? { |line| /\bQ_OBJECT\b/.match line } }.map { |h| h.ext 'moc' }). + qt_dependencies_and_sources("common"). end_if. build_dll(lib[:name] == 'mtxcommon'). libraries(:iconv, :z, :matroska, :ebml, :rpcrt4). diff --git a/rake.d/target.rb b/rake.d/target.rb index 5e177167e..587c069c7 100644 --- a/rake.d/target.rb +++ b/rake.d/target.rb @@ -89,27 +89,26 @@ class Target end def qt_dependencies_and_sources(subdir, options = {}) - ui_files = FileList["src/#{subdir}/forms/**/*.ui"].to_a - ui_h_files = ui_files.collect { |ui| ui.ext 'h' } - cpp_files = FileList["src/#{subdir}/**/*.cpp"].to_a.for_target! - (options[:cpp_except] || []) - h_files = FileList["src/#{subdir}/**/*.h"].to_a.for_target! - ui_h_files - cpp_content = read_files cpp_files - h_content = read_files h_files - qobject_h_files = h_files.select { |h| h_content[h].any? { |line| /\bQ_OBJECT\b/.match line } } + ui_files = FileList["src/#{subdir}/forms/**/*.ui"].to_a + ui_h_files = ui_files.collect { |ui| ui.ext 'h' } + cpp_files = FileList["src/#{subdir}/**/*.cpp"].to_a.for_target! - (options[:cpp_except] || []) + h_files = FileList["src/#{subdir}/**/*.h"].to_a.for_target! - ui_h_files + content = read_files(cpp_files + h_files) + qobject_h_files = h_files.select { |h| content[h].any? { |line| /\bQ_OBJECT\b/.match line } } - form_include_re = %r{^\s* \# \s* include \s+ \" (#{subdir}/forms/[^\"]+) }x - cpp_dependencies = {} + form_include_re = %r{^\s* \# \s* include \s+ \" (#{subdir}/forms/[^\"]+) }x + extra_dependencies = {} - cpp_files.each do |cpp| - cpp_content[cpp].each do |line| + (cpp_files + h_files).each do |file_name| + content[file_name].each do |line| next unless form_include_re.match line - cpp_dependencies[cpp] ||= [] - cpp_dependencies[cpp] << "src/#{$1}" + extra_dependencies[file_name] ||= [] + extra_dependencies[file_name] << "src/#{$1}" end end - cpp_dependencies.each { |cpp, ui_hs| file cpp.ext('o') => ui_hs } + extra_dependencies.each { |file_name, ui_hs| file file_name => ui_hs } self. sources(ui_files).