qmake/option.h
changeset 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
-1:000000000000 0:1918ee327afb
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the qmake application of the Qt Toolkit.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    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 **
       
    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.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    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 
       
    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,
       
    66     WarnAll     = 0xFF
       
    67 };
       
    68 void warn_msg(QMakeWarn t, const char *fmt, ...);
       
    69 
       
    70 struct Option
       
    71 {
       
    72     //simply global convenience
       
    73     static QString js_ext;
       
    74     static QString libtool_ext;
       
    75     static QString pkgcfg_ext;
       
    76     static QString prf_ext;
       
    77     static QString prl_ext;
       
    78     static QString ui_ext;
       
    79     static QStringList h_ext;
       
    80     static QStringList cpp_ext;
       
    81     static QStringList c_ext;
       
    82     static QString h_moc_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 cpp_moc_mod;
       
    89     static QString lex_mod;
       
    90     static QString yacc_mod;
       
    91     static QString dir_sep;
       
    92     static QString dirlist_sep;
       
    93     static QString sysenv_mod;
       
    94     static QString pro_ext;
       
    95     static QString mmp_ext;
       
    96     static QString res_ext;
       
    97     static char field_sep;
       
    98     static const char *application_argv0;
       
    99 
       
   100     enum CmdLineFlags {
       
   101         QMAKE_CMDLINE_SUCCESS       = 0x00,
       
   102         QMAKE_CMDLINE_SHOW_USAGE    = 0x01,
       
   103         QMAKE_CMDLINE_BAIL          = 0x02,
       
   104         QMAKE_CMDLINE_ERROR         = 0x04
       
   105     };
       
   106 
       
   107     //both of these must be called..
       
   108     static int init(int argc=0, char **argv=0); //parse cmdline
       
   109     static bool postProcessProject(QMakeProject *);
       
   110 
       
   111     enum StringFixFlags {
       
   112         FixNone                 = 0x00,
       
   113         FixEnvVars              = 0x01,
       
   114         FixPathCanonicalize     = 0x02,
       
   115         FixPathToLocalSeparators  = 0x04,
       
   116         FixPathToTargetSeparators = 0x08
       
   117     };
       
   118     static QString fixString(QString string, uchar flags);
       
   119 
       
   120     //and convenience functions
       
   121     inline static QString fixPathToLocalOS(const QString &in, bool fix_env=true, bool canonical=true)
       
   122     {
       
   123         uchar flags = FixPathToLocalSeparators;
       
   124         if(fix_env)
       
   125             flags |= FixEnvVars;
       
   126         if(canonical)
       
   127             flags |= FixPathCanonicalize;
       
   128         return fixString(in, flags);
       
   129     }
       
   130     inline static QString fixPathToTargetOS(const QString &in, bool fix_env=true, bool canonical=true)
       
   131     {
       
   132         uchar flags = FixPathToTargetSeparators;
       
   133         if(fix_env)
       
   134             flags |= FixEnvVars;
       
   135         if(canonical)
       
   136             flags |= FixPathCanonicalize;
       
   137         return fixString(in, flags);
       
   138     }
       
   139 
       
   140     //global qmake mode, can only be in one mode per invocation!
       
   141     enum QMAKE_MODE { QMAKE_GENERATE_NOTHING, QMAKE_GENERATE_PROJECT, QMAKE_GENERATE_MAKEFILE,
       
   142                       QMAKE_GENERATE_PRL, QMAKE_SET_PROPERTY, QMAKE_QUERY_PROPERTY };
       
   143     static QMAKE_MODE qmake_mode;
       
   144 
       
   145     //all modes
       
   146     static QString qmake_abslocation;
       
   147     static QFile output;
       
   148     static QString output_dir;
       
   149     static int debug_level;
       
   150     static int warn_level;
       
   151     static bool recursive;
       
   152     static QStringList before_user_vars, after_user_vars, user_configs, after_user_configs;
       
   153     enum TARG_MODE { TARG_UNIX_MODE, TARG_WIN_MODE, TARG_MACX_MODE, TARG_MAC9_MODE };
       
   154     static TARG_MODE target_mode;
       
   155     static QString user_template, user_template_prefix;
       
   156     static QStringList shellPath;
       
   157 
       
   158     //QMAKE_*_PROPERTY options
       
   159     struct prop {
       
   160         static QStringList properties;
       
   161     };
       
   162 
       
   163     //QMAKE_GENERATE_PROJECT options
       
   164     struct projfile {
       
   165         static bool do_pwd;
       
   166         static QStringList project_dirs;
       
   167     };
       
   168 
       
   169     //QMAKE_GENERATE_MAKEFILE options
       
   170     struct mkfile {
       
   171         static QString qmakespec;
       
   172         static bool do_cache;
       
   173         static bool do_deps;
       
   174         static bool do_mocs;
       
   175         static bool listgen;
       
   176         static bool do_dep_heuristics;
       
   177         static bool do_preprocess;
       
   178         static bool do_stub_makefile;
       
   179         static QString cachefile;
       
   180         static int cachefile_depth;
       
   181         static QStringList project_files;
       
   182         static QString qmakespec_commandline;
       
   183     };
       
   184 
       
   185 private:
       
   186     static int parseCommandLine(int, char **, int=0);
       
   187 };
       
   188 
       
   189 inline QString fixEnvVariables(const QString &x) { return Option::fixString(x, Option::FixEnvVars); }
       
   190 inline QStringList splitPathList(const QString &paths) { return paths.split(Option::dirlist_sep); }
       
   191 
       
   192 
       
   193 // this is a stripped down version of the one found in QtCore
       
   194 class QLibraryInfo
       
   195 {
       
   196 public:
       
   197     enum LibraryLocation
       
   198     {
       
   199         PrefixPath,
       
   200         DocumentationPath,
       
   201         HeadersPath,
       
   202         LibrariesPath,
       
   203         BinariesPath,
       
   204         PluginsPath,
       
   205         DataPath,
       
   206         TranslationsPath,
       
   207         SettingsPath,
       
   208         DemosPath,
       
   209         ExamplesPath
       
   210     };
       
   211     static QString location(LibraryLocation);
       
   212 };
       
   213 
       
   214 QT_END_NAMESPACE
       
   215 
       
   216 #endif // OPTION_H