[2] | 1 | /****************************************************************************
|
---|
| 2 | **
|
---|
[846] | 3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
[561] | 4 | ** All rights reserved.
|
---|
| 5 | ** Contact: Nokia Corporation ([email protected])
|
---|
[2] | 6 | **
|
---|
| 7 | ** This file is part of the qmake application of the Qt Toolkit.
|
---|
| 8 | **
|
---|
| 9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
| 10 | ** Commercial Usage
|
---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
| 14 | ** a written agreement between you and Nokia.
|
---|
| 15 | **
|
---|
| 16 | ** GNU Lesser General Public License Usage
|
---|
| 17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
| 18 | ** General Public License version 2.1 as published by the Free Software
|
---|
| 19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
| 20 | ** packaging of this file. Please review the following information to
|
---|
| 21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
| 22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
| 23 | **
|
---|
[561] | 24 | ** In addition, as a special exception, Nokia gives you certain additional
|
---|
| 25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
---|
| 26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
---|
[2] | 27 | **
|
---|
| 28 | ** GNU General Public License Usage
|
---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
| 32 | ** packaging of this file. Please review the following information to
|
---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
| 35 | **
|
---|
[561] | 36 | ** If you have questions regarding the use of this file, please contact
|
---|
| 37 | ** Nokia at [email protected].
|
---|
[2] | 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 |
|
---|
| 50 | QT_BEGIN_NAMESPACE
|
---|
| 51 |
|
---|
| 52 | #define QMAKE_VERSION_MAJOR 2
|
---|
| 53 | #define QMAKE_VERSION_MINOR 1
|
---|
| 54 | #define QMAKE_VERSION_PATCH 0
|
---|
| 55 | const char *qmake_version();
|
---|
| 56 |
|
---|
| 57 | QString qmake_getpwd();
|
---|
| 58 | bool qmake_setpwd(const QString &p);
|
---|
| 59 |
|
---|
| 60 | #define debug_msg if(Option::debug_level) debug_msg_internal
|
---|
| 61 | void debug_msg_internal(int level, const char *fmt, ...); //don't call directly, use debug_msg
|
---|
| 62 | enum QMakeWarn {
|
---|
| 63 | WarnNone = 0x00,
|
---|
| 64 | WarnParser = 0x01,
|
---|
| 65 | WarnLogic = 0x02,
|
---|
[846] | 66 | WarnDeprecated = 0x04,
|
---|
[2] | 67 | WarnAll = 0xFF
|
---|
| 68 | };
|
---|
| 69 | void warn_msg(QMakeWarn t, const char *fmt, ...);
|
---|
| 70 |
|
---|
| 71 | struct Option
|
---|
| 72 | {
|
---|
| 73 | //simply global convenience
|
---|
| 74 | static QString js_ext;
|
---|
| 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 h_moc_ext;
|
---|
| 84 | static QString cpp_moc_ext;
|
---|
| 85 | static QString obj_ext;
|
---|
| 86 | static QString lex_ext;
|
---|
| 87 | static QString yacc_ext;
|
---|
| 88 | static QString h_moc_mod;
|
---|
| 89 | static QString cpp_moc_mod;
|
---|
| 90 | static QString lex_mod;
|
---|
| 91 | static QString yacc_mod;
|
---|
| 92 | static QString dir_sep;
|
---|
| 93 | static QString dirlist_sep;
|
---|
| 94 | static QString sysenv_mod;
|
---|
| 95 | static QString pro_ext;
|
---|
[561] | 96 | static QString mmp_ext;
|
---|
[2] | 97 | static QString res_ext;
|
---|
| 98 | static char field_sep;
|
---|
| 99 | static const char *application_argv0;
|
---|
| 100 |
|
---|
| 101 | enum CmdLineFlags {
|
---|
| 102 | QMAKE_CMDLINE_SUCCESS = 0x00,
|
---|
| 103 | QMAKE_CMDLINE_SHOW_USAGE = 0x01,
|
---|
| 104 | QMAKE_CMDLINE_BAIL = 0x02,
|
---|
| 105 | QMAKE_CMDLINE_ERROR = 0x04
|
---|
| 106 | };
|
---|
| 107 |
|
---|
| 108 | //both of these must be called..
|
---|
| 109 | static int init(int argc=0, char **argv=0); //parse cmdline
|
---|
[846] | 110 | static void applyHostMode();
|
---|
[2] | 111 | static bool postProcessProject(QMakeProject *);
|
---|
| 112 |
|
---|
| 113 | enum StringFixFlags {
|
---|
| 114 | FixNone = 0x00,
|
---|
| 115 | FixEnvVars = 0x01,
|
---|
| 116 | FixPathCanonicalize = 0x02,
|
---|
| 117 | FixPathToLocalSeparators = 0x04,
|
---|
| 118 | FixPathToTargetSeparators = 0x08
|
---|
| 119 | };
|
---|
| 120 | static QString fixString(QString string, uchar flags);
|
---|
| 121 |
|
---|
| 122 | //and convenience functions
|
---|
| 123 | inline static QString fixPathToLocalOS(const QString &in, bool fix_env=true, bool canonical=true)
|
---|
| 124 | {
|
---|
| 125 | uchar flags = FixPathToLocalSeparators;
|
---|
| 126 | if(fix_env)
|
---|
| 127 | flags |= FixEnvVars;
|
---|
| 128 | if(canonical)
|
---|
| 129 | flags |= FixPathCanonicalize;
|
---|
| 130 | return fixString(in, flags);
|
---|
| 131 | }
|
---|
| 132 | inline static QString fixPathToTargetOS(const QString &in, bool fix_env=true, bool canonical=true)
|
---|
| 133 | {
|
---|
| 134 | uchar flags = FixPathToTargetSeparators;
|
---|
| 135 | if(fix_env)
|
---|
| 136 | flags |= FixEnvVars;
|
---|
| 137 | if(canonical)
|
---|
| 138 | flags |= FixPathCanonicalize;
|
---|
| 139 | return fixString(in, flags);
|
---|
| 140 | }
|
---|
| 141 |
|
---|
| 142 | //global qmake mode, can only be in one mode per invocation!
|
---|
| 143 | enum QMAKE_MODE { QMAKE_GENERATE_NOTHING, QMAKE_GENERATE_PROJECT, QMAKE_GENERATE_MAKEFILE,
|
---|
| 144 | QMAKE_GENERATE_PRL, QMAKE_SET_PROPERTY, QMAKE_QUERY_PROPERTY };
|
---|
| 145 | static QMAKE_MODE qmake_mode;
|
---|
| 146 |
|
---|
| 147 | //all modes
|
---|
| 148 | static QString qmake_abslocation;
|
---|
| 149 | static QFile output;
|
---|
| 150 | static QString output_dir;
|
---|
| 151 | static int debug_level;
|
---|
| 152 | static int warn_level;
|
---|
[846] | 153 | enum QMAKE_RECURSIVE { QMAKE_RECURSIVE_DEFAULT, QMAKE_RECURSIVE_YES, QMAKE_RECURSIVE_NO };
|
---|
| 154 | static QMAKE_RECURSIVE recursive;
|
---|
[2] | 155 | static QStringList before_user_vars, after_user_vars, user_configs, after_user_configs;
|
---|
[846] | 156 | enum HOST_MODE { HOST_UNKNOWN_MODE, HOST_UNIX_MODE, HOST_WIN_MODE, HOST_MACX_MODE,
|
---|
| 157 | HOST_OS2_MODE };
|
---|
| 158 | static HOST_MODE host_mode;
|
---|
| 159 | enum TARG_MODE { TARG_UNKNOWN_MODE, TARG_UNIX_MODE, TARG_WIN_MODE, TARG_MACX_MODE,
|
---|
| 160 | TARG_SYMBIAN_MODE, TARG_OS2_MODE };
|
---|
[2] | 161 | static TARG_MODE target_mode;
|
---|
[846] | 162 | static bool target_mode_overridden;
|
---|
[2] | 163 | static QString user_template, user_template_prefix;
|
---|
| 164 | static QStringList shellPath;
|
---|
| 165 |
|
---|
| 166 | //QMAKE_*_PROPERTY options
|
---|
| 167 | struct prop {
|
---|
| 168 | static QStringList properties;
|
---|
| 169 | };
|
---|
| 170 |
|
---|
| 171 | //QMAKE_GENERATE_PROJECT options
|
---|
| 172 | struct projfile {
|
---|
| 173 | static bool do_pwd;
|
---|
| 174 | static QStringList project_dirs;
|
---|
| 175 | };
|
---|
| 176 |
|
---|
| 177 | //QMAKE_GENERATE_MAKEFILE options
|
---|
| 178 | struct mkfile {
|
---|
| 179 | static QString qmakespec;
|
---|
| 180 | static bool do_cache;
|
---|
| 181 | static bool do_deps;
|
---|
| 182 | static bool do_mocs;
|
---|
| 183 | static bool do_dep_heuristics;
|
---|
| 184 | static bool do_preprocess;
|
---|
| 185 | static bool do_stub_makefile;
|
---|
| 186 | static QString cachefile;
|
---|
| 187 | static int cachefile_depth;
|
---|
| 188 | static QStringList project_files;
|
---|
| 189 | static QString qmakespec_commandline;
|
---|
| 190 | };
|
---|
| 191 |
|
---|
| 192 | private:
|
---|
| 193 | static int parseCommandLine(int, char **, int=0);
|
---|
| 194 | };
|
---|
| 195 |
|
---|
| 196 | inline QString fixEnvVariables(const QString &x) { return Option::fixString(x, Option::FixEnvVars); }
|
---|
| 197 | inline QStringList splitPathList(const QString &paths) { return paths.split(Option::dirlist_sep); }
|
---|
| 198 |
|
---|
| 199 |
|
---|
| 200 | // this is a stripped down version of the one found in QtCore
|
---|
| 201 | class QLibraryInfo
|
---|
| 202 | {
|
---|
| 203 | public:
|
---|
| 204 | enum LibraryLocation
|
---|
| 205 | {
|
---|
| 206 | PrefixPath,
|
---|
| 207 | DocumentationPath,
|
---|
| 208 | HeadersPath,
|
---|
| 209 | LibrariesPath,
|
---|
| 210 | BinariesPath,
|
---|
| 211 | PluginsPath,
|
---|
| 212 | DataPath,
|
---|
| 213 | TranslationsPath,
|
---|
| 214 | SettingsPath,
|
---|
| 215 | DemosPath,
|
---|
[846] | 216 | ExamplesPath,
|
---|
| 217 | ImportsPath
|
---|
[2] | 218 | };
|
---|
| 219 | static QString location(LibraryLocation);
|
---|
| 220 | };
|
---|
| 221 |
|
---|
| 222 | QT_END_NAMESPACE
|
---|
| 223 |
|
---|
| 224 | #endif // OPTION_H
|
---|