1 /**************************************************************************** 2 ** 3 ** Copyright (C) 2016 The Qt Company Ltd. 4 ** Contact: https://www.qt.io/licensing/ 5 ** 6 ** This file is part of the qmake application of the Qt Toolkit. 7 ** 8 ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ 9 ** Commercial License Usage 10 ** Licensees holding valid commercial Qt licenses may use this file in 11 ** accordance with the commercial license agreement provided with the 12 ** Software or, alternatively, in accordance with the terms contained in 13 ** a written agreement between you and The Qt Company. For licensing terms 14 ** and conditions see https://www.qt.io/terms-conditions. For further 15 ** information use the contact form at https://www.qt.io/contact-us. 16 ** 17 ** GNU General Public License Usage 18 ** Alternatively, this file may be used under the terms of the GNU 19 ** General Public License version 3 as published by the Free Software 20 ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT 21 ** included in the packaging of this file. Please review the following 22 ** information to ensure the GNU General Public License requirements will 23 ** be met: https://www.gnu.org/licenses/gpl-3.0.html. 24 ** 25 ** $QT_END_LICENSE$ 26 ** 27 ****************************************************************************/ 28 29 #ifndef MAKEFILEDEPS_H 30 #define MAKEFILEDEPS_H 31 32 #include <proitems.h> 33 34 #include <qstringlist.h> 35 #include <qfileinfo.h> 36 #include <qvector.h> 37 38 QT_BEGIN_NAMESPACE 39 40 struct SourceFile; 41 struct SourceDependChildren; 42 class SourceFiles; 43 44 class QMakeLocalFileName { 45 bool is_null; 46 QString real_name; 47 mutable QString local_name; 48 public: QMakeLocalFileNamenull49 QMakeLocalFileName() : is_null(true) {} 50 QMakeLocalFileName(const QString &); isNullnull51 bool isNull() const { return is_null; } realnull52 inline const QString &real() const { return real_name; } localnull53 const QString &local() const; 54 55 bool operator==(const QMakeLocalFileName &other) const { 56 return (this->real_name == other.real_name); 57 } 58 bool operator!=(const QMakeLocalFileName &other) const { 59 return !(*this == other); 60 } 61 }; 62 63 class QMakeSourceFileInfo 64 { 65 private: 66 //quick project lookups 67 SourceFiles *files, *includes; 68 bool files_changed; 69 QVector<QMakeLocalFileName> depdirs; 70 QStringList systemIncludes; 71 72 //sleezy buffer code 73 char *spare_buffer; 74 int spare_buffer_size; 75 char *getBuffer(int s); 76 77 //actual guts 78 bool findMocs(SourceFile *); 79 bool findDeps(SourceFile *); 80 void dependTreeWalker(SourceFile *, SourceDependChildren *); 81 82 protected: 83 virtual QMakeLocalFileName fixPathForFile(const QMakeLocalFileName &, bool forOpen=false); 84 virtual QMakeLocalFileName findFileForDep(const QMakeLocalFileName &, const QMakeLocalFileName &); 85 virtual QFileInfo findFileInfo(const QMakeLocalFileName &); 86 87 public: 88 89 QMakeSourceFileInfo(const QString &cachefile=""); ~QMakeSourceFileInfonull90 virtual ~QMakeSourceFileInfo(); 91 92 QVector<QMakeLocalFileName> dependencyPaths() const { return depdirs; } 93 void setDependencyPaths(const QVector<QMakeLocalFileName> &); 94 95 enum DependencyMode { Recursive, NonRecursive }; 96 inline void setDependencyMode(DependencyMode mode) { dep_mode = mode; } dependencyModenull97 inline DependencyMode dependencyMode() const { return dep_mode; } 98 99 void setSystemIncludes(const ProStringList &list) list.toQStringListnull100 { systemIncludes = list.toQStringList(); } 101 102 enum SourceFileType { TYPE_UNKNOWN, TYPE_C, TYPE_UI, TYPE_QRC }; 103 enum SourceFileSeek { SEEK_DEPS=0x01, SEEK_MOCS=0x02 }; 104 void addSourceFiles(const ProStringList &, uchar seek, SourceFileType type=TYPE_C); 105 void addSourceFile(const QString &, uchar seek, SourceFileType type=TYPE_C); 106 bool containsSourceFile(const QString &, SourceFileType type=TYPE_C); 107 bool isSystemInclude(const QString &); 108 109 int included(const QString &file); 110 QStringList dependencies(const QString &file); 111 112 bool mocable(const QString &file); 113 114 private: 115 DependencyMode dep_mode; 116 }; 117 118 QT_END_NAMESPACE 119 120 #endif // MAKEFILEDEPS_H 121