dispose of Option::shellPath
[profile/ivi/qtbase.git] / qmake / option.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
5 **
6 ** This file is part of the qmake application of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
16 **
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
20 **
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
28 **
29 ** Other Usage
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
32 **
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #ifndef OPTION_H
43 #define OPTION_H
44
45 #include "project.h"
46 #include <qstring.h>
47 #include <qstringlist.h>
48 #include <qfile.h>
49 #include <qlibraryinfo.h>
50
51 QT_BEGIN_NAMESPACE
52
53 #define QMAKE_VERSION_MAJOR 2
54 #define QMAKE_VERSION_MINOR 1
55 #define QMAKE_VERSION_PATCH 0
56 const char *qmake_version();
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 struct Option
73 {
74     //simply global convenience
75     static QString libtool_ext;
76     static QString pkgcfg_ext;
77     static QString prf_ext;
78     static QString prl_ext;
79     static QString ui_ext;
80     static QStringList h_ext;
81     static QStringList cpp_ext;
82     static QStringList c_ext;
83     static QString cpp_moc_ext;
84     static QString obj_ext;
85     static QString lex_ext;
86     static QString yacc_ext;
87     static QString h_moc_mod;
88     static QString lex_mod;
89     static QString yacc_mod;
90     static QString dir_sep;
91     static QString dirlist_sep;
92     static QString pro_ext;
93     static QString res_ext;
94     static char field_sep;
95     static const char *application_argv0;
96
97     enum CmdLineFlags {
98         QMAKE_CMDLINE_SUCCESS       = 0x00,
99         QMAKE_CMDLINE_SHOW_USAGE    = 0x01,
100         QMAKE_CMDLINE_BAIL          = 0x02,
101         QMAKE_CMDLINE_ERROR         = 0x04
102     };
103
104     //both of these must be called..
105     static int init(int argc=0, char **argv=0); //parse cmdline
106     static void prepareProject(const QString &pfile);
107     static bool postProcessProject(QMakeProject *);
108
109     enum StringFixFlags {
110         FixNone                 = 0x00,
111         FixEnvVars              = 0x01,
112         FixPathCanonicalize     = 0x02,
113         FixPathToLocalSeparators  = 0x04,
114         FixPathToTargetSeparators = 0x08,
115         FixPathToNormalSeparators = 0x10
116     };
117     static QString fixString(QString string, uchar flags);
118
119     //and convenience functions
120     inline static QString fixPathToLocalOS(const QString &in, bool fix_env=true, bool canonical=true)
121     {
122         uchar flags = FixPathToLocalSeparators;
123         if(fix_env)
124             flags |= FixEnvVars;
125         if(canonical)
126             flags |= FixPathCanonicalize;
127         return fixString(in, flags);
128     }
129     inline static QString fixPathToTargetOS(const QString &in, bool fix_env=true, bool canonical=true)
130     {
131         uchar flags = FixPathToTargetSeparators;
132         if(fix_env)
133             flags |= FixEnvVars;
134         if(canonical)
135             flags |= FixPathCanonicalize;
136         return fixString(in, flags);
137     }
138     inline static QString normalizePath(const QString &in, bool fix_env=true, bool canonical=true)
139     {
140         uchar flags = FixPathToNormalSeparators;
141         if (fix_env)
142             flags |= FixEnvVars;
143         if (canonical)
144             flags |= FixPathCanonicalize;
145         return fixString(in, flags);
146     }
147
148     inline static bool hasFileExtension(const QString &str, const QStringList &extensions)
149     {
150         foreach (const QString &ext, extensions)
151             if (str.endsWith(ext))
152                 return true;
153         return false;
154     }
155
156     //global qmake mode, can only be in one mode per invocation!
157     enum QMAKE_MODE { QMAKE_GENERATE_NOTHING,
158                       QMAKE_GENERATE_PROJECT, QMAKE_GENERATE_MAKEFILE, QMAKE_GENERATE_PRL,
159                       QMAKE_SET_PROPERTY, QMAKE_UNSET_PROPERTY, QMAKE_QUERY_PROPERTY };
160     static QMAKE_MODE qmake_mode;
161
162     //all modes
163     static QString qmake_abslocation;
164     static QFile output;
165     static QString output_dir;
166     static int debug_level;
167     static int warn_level;
168     enum QMAKE_RECURSIVE { QMAKE_RECURSIVE_DEFAULT, QMAKE_RECURSIVE_YES, QMAKE_RECURSIVE_NO };
169     static QMAKE_RECURSIVE recursive;
170     static QStringList before_user_vars, after_user_vars;
171     enum HOST_MODE { HOST_UNKNOWN_MODE, HOST_UNIX_MODE, HOST_WIN_MODE, HOST_MACX_MODE };
172     static HOST_MODE host_mode;
173     static QString user_template, user_template_prefix;
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 QString qmakespec;
189         static QString xqmakespec;
190         static bool do_cache;
191         static bool do_deps;
192         static bool do_mocs;
193         static bool do_dep_heuristics;
194         static bool do_preprocess;
195         static bool do_stub_makefile;
196         static QString source_root;
197         static QString build_root;
198         static QString cachefile;
199         static int cachefile_depth;
200         static QStringList project_files;
201         static QString qmakespec_commandline;
202         static QString xqmakespec_commandline;
203     };
204
205 private:
206     static int parseCommandLine(int, char **, int=0);
207 };
208
209 inline QString fixEnvVariables(const QString &x) { return Option::fixString(x, Option::FixEnvVars); }
210 inline QStringList splitPathList(const QString &paths) { return paths.isEmpty() ? QStringList() : paths.split(Option::dirlist_sep); }
211
212 QT_END_NAMESPACE
213
214 #endif // OPTION_H