Warning: That file was not part of the compilation database. It may have many parsing errors.

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 OPTION_H
30#define OPTION_H
31
32#include <qmakeglobals.h>
33#include <qmakevfs.h>
34#include <qmakeparser.h>
35#include <qmakeevaluator.h>
36
37#include <qstring.h>
38#include <qstringlist.h>
39#include <qfile.h>
40
41QT_BEGIN_NAMESPACE
42
43#define QMAKE_VERSION_STR "3.1"
44
45QString qmake_getpwd();
46bool qmake_setpwd(const QString &p);
47
48#define debug_msg if(Option::debug_level) debug_msg_internal
49void debug_msg_internal(int level, const char *fmt, ...); //don't call directly, use debug_msg
50enum QMakeWarn {
51 WarnNone = 0x00,
52 WarnParser = 0x01,
53 WarnLogic = 0x02,
54 WarnDeprecated = 0x04,
55 WarnAll = 0xFF
56};
57void warn_msg(QMakeWarn t, const char *fmt, ...);
58
59class QMakeProject;
60
61class EvalHandler : public QMakeHandler {
62public:
63 void message(int type, const QString &msg, const QString &fileName, int lineNo) override;
64
65 void fileMessage(int type, const QString &msg) override;
66
67 void aboutToEval(ProFile *, ProFile *, EvalFileType) override;
68 void doneWithEval(ProFile *) override;
69};
70
71struct Option
72{
73 static EvalHandler evalHandler;
74
75 static QMakeGlobals *globals;
76 static ProFileCache *proFileCache;
77 static QMakeVfs *vfs;
78 static QMakeParser *parser;
79
80 //simply global convenience
81 static QString libtool_ext;
82 static QString pkgcfg_ext;
83 static QString prf_ext;
84 static QString prl_ext;
85 static QString ui_ext;
86 static QStringList h_ext;
87 static QStringList cpp_ext;
88 static QStringList c_ext;
89 static QString objc_ext;
90 static QString objcpp_ext;
91 static QString cpp_moc_ext;
92 static QString obj_ext;
93 static QString lex_ext;
94 static QString yacc_ext;
95 static QString h_moc_mod;
96 static QString lex_mod;
97 static QString yacc_mod;
98 static QString dir_sep;
99 static QString pro_ext;
100 static QString res_ext;
101 static char field_sep;
102
103 enum CmdLineFlags {
104 QMAKE_CMDLINE_SUCCESS = 0x00,
105 QMAKE_CMDLINE_SHOW_USAGE = 0x01,
106 QMAKE_CMDLINE_BAIL = 0x02,
107 QMAKE_CMDLINE_ERROR = 0x04
108 };
109
110 //both of these must be called..
111 static int init(int argc = 0, char **argv = nullptr); //parse cmdline
112 static void prepareProject(const QString &pfile);
113 static bool postProcessProject(QMakeProject *);
114
115 enum StringFixFlags {
116 FixNone = 0x00,
117 FixEnvVars = 0x01,
118 FixPathCanonicalize = 0x02,
119 FixPathToLocalSeparators = 0x04,
120 FixPathToTargetSeparators = 0x08,
121 FixPathToNormalSeparators = 0x10
122 };
123 static QString fixString(QString string, uchar flags);
124
125 //and convenience functions
126 inline static QString fixPathToLocalOS(const QString &in, bool fix_env=true, bool canonical=true)
127 {
128 uchar flags = FixPathToLocalSeparators;
129 if(fix_env)
130 flags |= FixEnvVars;
131 if(canonical)
132 flags |= FixPathCanonicalize;
133 return fixString(in, flags);
134 }
135 inline static QString fixPathToTargetOS(const QString &in, bool fix_env=true, bool canonical=true)
136 {
137 uchar flags = FixPathToTargetSeparators;
138 if(fix_env)
139 flags |= FixEnvVars;
140 if(canonical)
141 flags |= FixPathCanonicalize;
142 return fixString(in, flags);
143 }
144 inline static QString normalizePath(const QString &in, bool fix_env=true, bool canonical=true)
145 {
146 uchar flags = FixPathToNormalSeparators;
147 if (fix_env)
148 flags |= FixEnvVars;
149 if (canonical)
150 flags |= FixPathCanonicalize;
151 return fixString(in, flags);
152 }
153
154 inline static bool hasFileExtension(const QString &str, const QStringList &extensions)
155 {
156 for (const QString &ext : extensions)
157 if (str.endsWith(ext))
158 return true;
159 return false;
160 }
161
162 //global qmake mode, can only be in one mode per invocation!
163 enum QMAKE_MODE { QMAKE_GENERATE_NOTHING,
164 QMAKE_GENERATE_PROJECT, QMAKE_GENERATE_MAKEFILE, QMAKE_GENERATE_PRL,
165 QMAKE_SET_PROPERTY, QMAKE_UNSET_PROPERTY, QMAKE_QUERY_PROPERTY };
166 static QMAKE_MODE qmake_mode;
167
168 //all modes
169 static QFile output;
170 static QString output_dir;
171 static int debug_level;
172 static int warn_level;
173 static bool recursive;
174
175 //QMAKE_*_PROPERTY options
176 struct prop {
177 static QStringList properties;
178 };
179
180 //QMAKE_GENERATE_PROJECT options
181 struct projfile {
182 static bool do_pwd;
183 static QStringList project_dirs;
184 };
185
186 //QMAKE_GENERATE_MAKEFILE options
187 struct mkfile {
188 static bool do_deps;
189 static bool do_mocs;
190 static bool do_dep_heuristics;
191 static bool do_preprocess;
192 static bool do_stub_makefile;
193 static int cachefile_depth;
194 static QStringList project_files;
195 };
196
197private:
198 static int parseCommandLine(QStringList &args, QMakeCmdLineParserState &state);
199};
200
201inline QString fixEnvVariables(const QString &x) { return Option::fixString(x, Option::FixEnvVars); }
202inline QStringList splitPathList(const QString &paths) { return paths.isEmpty() ? QStringList() : paths.split(Option::globals->dirlist_sep); }
203
204QT_END_NAMESPACE
205
206#endif // OPTION_H
207

Warning: That file was not part of the compilation database. It may have many parsing errors.