File indexing completed on 2024-05-12 04:17:32
0001 #! /usr/bin/env ruby 0002 0003 # ============================================================ 0004 # 0005 # This file is a part of digiKam project 0006 # https://www.digikam.org 0007 # 0008 # Date : 2012-07-14 0009 # Description : a helper script for finding source code with no moc includes 0010 # 0011 # SPDX-FileCopyrightText: 2012 by Andi Clemens <andi dot clemens at gmail dot com> 0012 # 0013 # SPDX-License-Identifier: BSD-3-Clause 0014 # 0015 # ============================================================ */ 0016 0017 # get all header files containing the line "Q_OBJECT" 0018 candidates = Dir.glob("**/*.h").select do |file_name| 0019 File.read(file_name) =~ /^\s*Q_OBJECT\s*$/ rescue false 0020 end 0021 0022 # get all source files with missing MOC includes 0023 missingMocIncludes = candidates.select do |file_name| 0024 source_file = file_name.sub(/\.h$/, ".cpp") 0025 moc_file = File.basename(file_name, '.h') + '.moc' 0026 pattern = /#include\s+[<"]#{moc_file}[>"]/ 0027 0028 (File.read(source_file) =~ pattern) == nil rescue false 0029 end 0030 0031 # display missing MOC includes 0032 puts "missing MOC include:" 0033 width = missingMocIncludes.length.to_s.length 0034 0035 missingMocIncludes.each_with_index do |file_name, idx| 0036 puts "%#{width}s: #{file_name}" % (idx + 1) 0037 end