Qdoc: put hardcoded url as workaround QTBUG-28500
[profile/ivi/qtbase.git] / qmake / option.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the qmake application of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
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 Digia.  For licensing terms and
14 ** conditions see http://qt.digia.com/licensing.  For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file.  Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights.  These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file.  Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #ifndef OPTION_H
43 #define OPTION_H
44
45 #include <qmakeglobals.h>
46 #include <qmakeparser.h>
47 #include <qmakeevaluator.h>
48
49 #include <qstring.h>
50 #include <qstringlist.h>
51 #include <qfile.h>
52 #include <qlibraryinfo.h>
53
54 QT_BEGIN_NAMESPACE
55
56 #define QMAKE_VERSION_STR "3.0"
57
58 QString qmake_getpwd();
59 bool qmake_setpwd(const QString &p);
60
61 #define debug_msg if(Option::debug_level) debug_msg_internal
62 void debug_msg_internal(int level, const char *fmt, ...); //don't call directly, use debug_msg
63 enum QMakeWarn {
64     WarnNone    = 0x00,
65     WarnParser  = 0x01,
66     WarnLogic   = 0x02,
67     WarnDeprecated = 0x04,
68     WarnAll     = 0xFF
69 };
70 void warn_msg(QMakeWarn t, const char *fmt, ...);
71
72 class QMakeProject;
73
74 class EvalHandler : public QMakeHandler {
75 public:
76     void message(int type, const QString &msg, const QString &fileName, int lineNo);
77
78     void fileMessage(const QString &msg);
79
80     void aboutToEval(ProFile *, ProFile *, EvalFileType);
81     void doneWithEval(ProFile *);
82 };
83
84 struct Option
85 {
86     static EvalHandler evalHandler;
87
88     static QMakeGlobals *globals;
89     static ProFileCache *proFileCache;
90     static QMakeParser *parser;
91
92     //simply global convenience
93     static QString libtool_ext;
94     static QString pkgcfg_ext;
95     static QString prf_ext;
96     static QString prl_ext;
97     static QString ui_ext;
98     static QStringList h_ext;
99     static QStringList cpp_ext;
100     static QStringList c_ext;
101     static QString cpp_moc_ext;
102     static QString obj_ext;
103     static QString lex_ext;
104     static QString yacc_ext;
105     static QString h_moc_mod;
106     static QString lex_mod;
107     static QString yacc_mod;
108     static QString dir_sep;
109     static QString pro_ext;
110     static QString res_ext;
111     static char field_sep;
112     static const char *application_argv0;
113
114     enum CmdLineFlags {
115         QMAKE_CMDLINE_SUCCESS       = 0x00,
116         QMAKE_CMDLINE_SHOW_USAGE    = 0x01,
117         QMAKE_CMDLINE_BAIL          = 0x02,
118         QMAKE_CMDLINE_ERROR         = 0x04
119     };
120
121     //both of these must be called..
122     static int init(int argc=0, char **argv=0); //parse cmdline
123     static void prepareProject(const QString &pfile);
124     static bool postProcessProject(QMakeProject *);
125
126     enum StringFixFlags {
127         FixNone                 = 0x00,
128         FixEnvVars              = 0x01,
129         FixPathCanonicalize     = 0x02,
130         FixPathToLocalSeparators  = 0x04,
131         FixPathToTargetSeparators = 0x08,
132         FixPathToNormalSeparators = 0x10
133     };
134     static QString fixString(QString string, uchar flags);
135
136     //and convenience functions
137     inline static QString fixPathToLocalOS(const QString &in, bool fix_env=true, bool canonical=true)
138     {
139         uchar flags = FixPathToLocalSeparators;
140         if(fix_env)
141             flags |= FixEnvVars;
142         if(canonical)
143             flags |= FixPathCanonicalize;
144         return fixString(in, flags);
145     }
146     inline static QString fixPathToTargetOS(const QString &in, bool fix_env=true, bool canonical=true)
147     {
148         uchar flags = FixPathToTargetSeparators;
149         if(fix_env)
150             flags |= FixEnvVars;
151         if(canonical)
152             flags |= FixPathCanonicalize;
153         return fixString(in, flags);
154     }
155     inline static QString normalizePath(const QString &in, bool fix_env=true, bool canonical=true)
156     {
157         uchar flags = FixPathToNormalSeparators;
158         if (fix_env)
159             flags |= FixEnvVars;
160         if (canonical)
161             flags |= FixPathCanonicalize;
162         return fixString(in, flags);
163     }
164
165     inline static bool hasFileExtension(const QString &str, const QStringList &extensions)
166     {
167         foreach (const QString &ext, extensions)
168             if (str.endsWith(ext))
169                 return true;
170         return false;
171     }
172
173     //global qmake mode, can only be in one mode per invocation!
174     enum QMAKE_MODE { QMAKE_GENERATE_NOTHING,
175                       QMAKE_GENERATE_PROJECT, QMAKE_GENERATE_MAKEFILE, QMAKE_GENERATE_PRL,
176                       QMAKE_SET_PROPERTY, QMAKE_UNSET_PROPERTY, QMAKE_QUERY_PROPERTY };
177     static QMAKE_MODE qmake_mode;
178
179     //all modes
180     static QStringList qmake_args;
181     static QFile output;
182     static QString output_dir;
183     static int debug_level;
184     static int warn_level;
185     static bool recursive;
186
187     //QMAKE_*_PROPERTY options
188     struct prop {
189         static QStringList properties;
190     };
191
192     //QMAKE_GENERATE_PROJECT options
193     struct projfile {
194         static bool do_pwd;
195         static QStringList project_dirs;
196     };
197
198     //QMAKE_GENERATE_MAKEFILE options
199     struct mkfile {
200         static bool do_deps;
201         static bool do_mocs;
202         static bool do_dep_heuristics;
203         static bool do_preprocess;
204         static bool do_stub_makefile;
205         static int cachefile_depth;
206         static QStringList project_files;
207     };
208
209 private:
210     static int parseCommandLine(QStringList &args);
211 };
212
213 inline QString fixEnvVariables(const QString &x) { return Option::fixString(x, Option::FixEnvVars); }
214 inline QStringList splitPathList(const QString &paths) { return paths.isEmpty() ? QStringList() : paths.split(Option::globals->dirlist_sep); }
215
216 QT_END_NAMESPACE
217
218 #endif // OPTION_H