| 1 | /**************************************************************************** | 
|---|
| 2 | ** | 
|---|
| 3 | ** Copyright (C) 2011 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 tools applications 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 | ** | 
|---|
| 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 | ** 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 | ** | 
|---|
| 36 | ** If you have questions regarding the use of this file, please contact | 
|---|
| 37 | ** Nokia at qt-info@nokia.com. | 
|---|
| 38 | ** $QT_END_LICENSE$ | 
|---|
| 39 | ** | 
|---|
| 40 | ****************************************************************************/ | 
|---|
| 41 |  | 
|---|
| 42 | #include <qmap.h> | 
|---|
| 43 | #include <qstring.h> | 
|---|
| 44 | #include <qstringlist.h> | 
|---|
| 45 | #include <qlist.h> | 
|---|
| 46 | #include <qtextstream.h> | 
|---|
| 47 | #include <qdir.h> | 
|---|
| 48 |  | 
|---|
| 49 | QT_BEGIN_NAMESPACE | 
|---|
| 50 |  | 
|---|
| 51 | class MakeItem; | 
|---|
| 52 |  | 
|---|
| 53 | class Configure | 
|---|
| 54 | { | 
|---|
| 55 | public: | 
|---|
| 56 | Configure( int& argc, char** argv ); | 
|---|
| 57 | ~Configure(); | 
|---|
| 58 |  | 
|---|
| 59 | void parseCmdLine(); | 
|---|
| 60 | #if !defined(EVAL) | 
|---|
| 61 | void validateArgs(); | 
|---|
| 62 | #endif | 
|---|
| 63 | bool displayHelp(); | 
|---|
| 64 |  | 
|---|
| 65 | QString defaultTo(const QString &option); | 
|---|
| 66 | bool checkAvailability(const QString &part); | 
|---|
| 67 | void autoDetection(); | 
|---|
| 68 | bool verifyConfiguration(); | 
|---|
| 69 |  | 
|---|
| 70 | void generateOutputVars(); | 
|---|
| 71 | #if !defined(EVAL) | 
|---|
| 72 | void generateHeaders(); | 
|---|
| 73 | void generateBuildKey(); | 
|---|
| 74 | void generateCachefile(); | 
|---|
| 75 | void displayConfig(); | 
|---|
| 76 | void buildQmake(); | 
|---|
| 77 | void buildHostTools(); | 
|---|
| 78 | #endif | 
|---|
| 79 | void generateMakefiles(); | 
|---|
| 80 | void appendMakeItem(int inList, const QString &item); | 
|---|
| 81 | #if !defined(EVAL) | 
|---|
| 82 | void generateConfigfiles(); | 
|---|
| 83 | #endif | 
|---|
| 84 | void showSummary(); | 
|---|
| 85 | void findProjects( const QString& dirName ); | 
|---|
| 86 | QString firstLicensePath(); | 
|---|
| 87 |  | 
|---|
| 88 | #if !defined(EVAL) | 
|---|
| 89 | bool showLicense(QString licenseFile); | 
|---|
| 90 | void readLicense(); | 
|---|
| 91 | #endif | 
|---|
| 92 |  | 
|---|
| 93 | QString addDefine(QString def); | 
|---|
| 94 |  | 
|---|
| 95 | enum ProjectType { | 
|---|
| 96 | App, | 
|---|
| 97 | Lib, | 
|---|
| 98 | Subdirs | 
|---|
| 99 | }; | 
|---|
| 100 |  | 
|---|
| 101 | ProjectType projectType( const QString& proFileName ); | 
|---|
| 102 | bool isDone(); | 
|---|
| 103 | bool isOk(); | 
|---|
| 104 | private: | 
|---|
| 105 | // Our variable dictionaries | 
|---|
| 106 | QMap<QString,QString> dictionary; | 
|---|
| 107 | QStringList licensedModules; | 
|---|
| 108 | QStringList allSqlDrivers; | 
|---|
| 109 | QStringList allConfigs; | 
|---|
| 110 | QStringList disabledModules; | 
|---|
| 111 | QStringList enabledModules; | 
|---|
| 112 | QStringList modules; | 
|---|
| 113 | QStringList disabledBuildParts; | 
|---|
| 114 | //    QStringList sqlDrivers; | 
|---|
| 115 | QStringList configCmdLine; | 
|---|
| 116 | QStringList qmakeConfig; | 
|---|
| 117 | QStringList qtConfig; | 
|---|
| 118 |  | 
|---|
| 119 | QStringList qmakeSql; | 
|---|
| 120 | QStringList qmakeSqlPlugins; | 
|---|
| 121 |  | 
|---|
| 122 | QStringList qmakeStyles; | 
|---|
| 123 | QStringList qmakeStylePlugins; | 
|---|
| 124 |  | 
|---|
| 125 | QStringList qmakeVars; | 
|---|
| 126 | QStringList qmakeDefines; | 
|---|
| 127 | //  makeList[0] for qt and qtmain | 
|---|
| 128 | //  makeList[1] for subdirs and libs | 
|---|
| 129 | //  makeList[2] for the rest | 
|---|
| 130 | QList<MakeItem*> makeList[3]; | 
|---|
| 131 | QStringList qmakeIncludes; | 
|---|
| 132 | QStringList qmakeLibs; | 
|---|
| 133 | QString opensslLibs; | 
|---|
| 134 | QString psqlLibs; | 
|---|
| 135 | QString sybase; | 
|---|
| 136 | QString sybaseLibs; | 
|---|
| 137 |  | 
|---|
| 138 | QMap<QString,QString> licenseInfo; | 
|---|
| 139 | QString outputLine; | 
|---|
| 140 |  | 
|---|
| 141 | QTextStream outStream; | 
|---|
| 142 | QString sourcePath, buildPath; | 
|---|
| 143 | QDir sourceDir, buildDir; | 
|---|
| 144 |  | 
|---|
| 145 | // Variables for usage output | 
|---|
| 146 | int optionIndent; | 
|---|
| 147 | int descIndent; | 
|---|
| 148 | int outputWidth; | 
|---|
| 149 |  | 
|---|
| 150 | bool useUnixSeparators; | 
|---|
| 151 | QString fixSeparators(const QString &somePath, bool escape = false); | 
|---|
| 152 | QString escapeSeparators(const QString &somePath); | 
|---|
| 153 | bool filesDiffer(const QString &file1, const QString &file2); | 
|---|
| 154 |  | 
|---|
| 155 | bool findFile(const QString &fileName); | 
|---|
| 156 | static QString findFileInPaths(const QString &fileName, const QString &paths); | 
|---|
| 157 | #if !defined(EVAL) | 
|---|
| 158 | void reloadCmdLine(); | 
|---|
| 159 | void saveCmdLine(); | 
|---|
| 160 | #endif | 
|---|
| 161 |  | 
|---|
| 162 | void desc(const char *description, int startingAt = 0, int wrapIndent = 0); | 
|---|
| 163 | void desc(const char *option, const char *description, bool skipIndent = false, char fillChar = '.'); | 
|---|
| 164 | void desc(const char *mark_option, const char *mark, const char *option, const char *description, char fillChar = '.'); | 
|---|
| 165 | void applySpecSpecifics(); | 
|---|
| 166 | static QString locateFile(const QString &fileName); | 
|---|
| 167 | static QString locateFileInPaths(const QString &fileName, const QStringList &paths); | 
|---|
| 168 | }; | 
|---|
| 169 |  | 
|---|
| 170 | class MakeItem | 
|---|
| 171 | { | 
|---|
| 172 | public: | 
|---|
| 173 | MakeItem( const QString &d, const QString &p, const QString &t, Configure::ProjectType qt ) | 
|---|
| 174 | : directory( d ), | 
|---|
| 175 | proFile( p ), | 
|---|
| 176 | target( t ), | 
|---|
| 177 | qmakeTemplate( qt ) | 
|---|
| 178 | { } | 
|---|
| 179 |  | 
|---|
| 180 | QString directory; | 
|---|
| 181 | QString proFile; | 
|---|
| 182 | QString target; | 
|---|
| 183 | Configure::ProjectType qmakeTemplate; | 
|---|
| 184 | }; | 
|---|
| 185 |  | 
|---|
| 186 |  | 
|---|
| 187 | QT_END_NAMESPACE | 
|---|