1 /****************************************************************************
3 ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
6 ** This file is part of the qmake application of the Qt Toolkit.
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.
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.
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.
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.
40 ****************************************************************************/
45 #include <qmakeglobals.h>
46 #include <qmakeparser.h>
47 #include <qmakeevaluator.h>
50 #include <qstringlist.h>
52 #include <qlibraryinfo.h>
56 #define QMAKE_VERSION_STR "3.0"
58 QString qmake_getpwd();
59 bool qmake_setpwd(const QString &p);
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
67 WarnDeprecated = 0x04,
70 void warn_msg(QMakeWarn t, const char *fmt, ...);
74 class EvalHandler : public QMakeHandler {
76 void message(int type, const QString &msg, const QString &fileName, int lineNo);
78 void fileMessage(const QString &msg);
80 void aboutToEval(ProFile *, ProFile *, EvalFileType);
81 void doneWithEval(ProFile *);
86 static EvalHandler evalHandler;
88 static QMakeGlobals *globals;
89 static ProFileCache *proFileCache;
90 static QMakeParser *parser;
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;
115 QMAKE_CMDLINE_SUCCESS = 0x00,
116 QMAKE_CMDLINE_SHOW_USAGE = 0x01,
117 QMAKE_CMDLINE_BAIL = 0x02,
118 QMAKE_CMDLINE_ERROR = 0x04
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 *);
126 enum StringFixFlags {
129 FixPathCanonicalize = 0x02,
130 FixPathToLocalSeparators = 0x04,
131 FixPathToTargetSeparators = 0x08,
132 FixPathToNormalSeparators = 0x10
134 static QString fixString(QString string, uchar flags);
136 //and convenience functions
137 inline static QString fixPathToLocalOS(const QString &in, bool fix_env=true, bool canonical=true)
139 uchar flags = FixPathToLocalSeparators;
143 flags |= FixPathCanonicalize;
144 return fixString(in, flags);
146 inline static QString fixPathToTargetOS(const QString &in, bool fix_env=true, bool canonical=true)
148 uchar flags = FixPathToTargetSeparators;
152 flags |= FixPathCanonicalize;
153 return fixString(in, flags);
155 inline static QString normalizePath(const QString &in, bool fix_env=true, bool canonical=true)
157 uchar flags = FixPathToNormalSeparators;
161 flags |= FixPathCanonicalize;
162 return fixString(in, flags);
165 inline static bool hasFileExtension(const QString &str, const QStringList &extensions)
167 foreach (const QString &ext, extensions)
168 if (str.endsWith(ext))
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;
180 static QStringList qmake_args;
182 static QString output_dir;
183 static int debug_level;
184 static int warn_level;
185 static bool recursive;
187 //QMAKE_*_PROPERTY options
189 static QStringList properties;
192 //QMAKE_GENERATE_PROJECT options
195 static QStringList project_dirs;
198 //QMAKE_GENERATE_MAKEFILE options
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;
210 static int parseCommandLine(QStringList &args);
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); }