1 /****************************************************************************
2 **
3 ** Copyright (C) 2015 The Qt Company Ltd.
4 ** Contact: http://www.qt.io/licensing/
5 **
6 ** This file is part of the tools applications of the Qt Toolkit.
7 **
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 The Qt Company. For licensing terms
14 ** and conditions see http://www.qt.io/terms-conditions. For further
15 ** information use the contact form at http://www.qt.io/contact-us.
16 **
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 or version 3 as published by the Free
20 ** Software Foundation and appearing in the file LICENSE.LGPLv21 and
21 ** LICENSE.LGPLv3 included in the packaging of this file. Please review the
22 ** following information to ensure the GNU Lesser General Public License
23 ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
24 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 **
26 ** As a special exception, The Qt Company gives you certain additional
27 ** rights. These rights are described in The Qt Company LGPL Exception
28 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 **
30 ** GNU General Public License Usage
31 ** Alternatively, this file may be used under the terms of the GNU
32 ** General Public License version 3.0 as published by the Free Software
33 ** Foundation and appearing in the file LICENSE.GPL included in the
34 ** packaging of this file.  Please review the following information to
35 ** ensure the GNU General Public License version 3.0 requirements will be
36 ** met: http://www.gnu.org/copyleft/gpl.html.
37 **
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 
105     int platform() const;
106     QString platformName() const;
107     QString qpaPlatformName() const;
108 
109 private:
110     // Our variable dictionaries
111     QMap<QString,QString> dictionary;
112     QStringList licensedModules;
113     QStringList allSqlDrivers;
114     QStringList allConfigs;
115     QStringList disabledModules;
116     QStringList enabledModules;
117     QStringList modules;
118     QStringList disabledBuildParts;
119 //    QStringList sqlDrivers;
120     QStringList configCmdLine;
121     QStringList qmakeConfig;
122     QStringList qtConfig;
123 
124     QStringList qmakeSql;
125     QStringList qmakeSqlPlugins;
126 
127     QStringList qmakeStyles;
128     QStringList qmakeStylePlugins;
129 
130     QStringList qmakeVars;
131     QStringList qmakeDefines;
132     //  makeList[0] for qt and qtmain
133     //  makeList[1] for subdirs and libs
134     //  makeList[2] for the rest
135     QList<MakeItem*> makeList[3];
136     QStringList qmakeIncludes;
137     QStringList qmakeLibs;
138     QString opensslLibs;
139     QString opensslLibsDebug;
140     QString opensslLibsRelease;
141     QString psqlLibs;
142     QString sybase;
143     QString sybaseLibs;
144 
145     QMap<QString,QString> licenseInfo;
146     QString outputLine;
147 
148     QTextStream outStream;
149     QString sourcePath, buildPath;
150     QDir sourceDir, buildDir;
151 
152     // Variables for usage output
153     int optionIndent;
154     int descIndent;
155     int outputWidth;
156 
157     bool useUnixSeparators;
158     QString fixSeparators(const QString &somePath, bool escape = false);
159     QString escapeSeparators(const QString &somePath);
160     bool filesDiffer(const QString &file1, const QString &file2);
161 
162     bool findFile(const QString &fileName);
163     static QString findFileInPaths(const QString &fileName, const QString &paths);
164 #if !defined(EVAL)
165     void reloadCmdLine();
166     void saveCmdLine();
167 #endif
168 
169     bool compilerSupportsFlag(const QStringList &compilerAndArgs);
170 
171     void desc(const char *description, int startingAt = 0, int wrapIndent = 0);
172     void desc(const char *option, const char *description, bool skipIndent = false, char fillChar = '.');
173     void desc(const char *mark_option, const char *mark, const char *option, const char *description, char fillChar = '.');
174     void applySpecSpecifics();
175     static QString locateFile(const QString &fileName);
176     static QString locateFileInPaths(const QString &fileName, const QStringList &paths);
177 };
178 
179 class MakeItem
180 {
181 public:
MakeItem(const QString & d,const QString & p,const QString & t,Configure::ProjectType qt)182     MakeItem( const QString &d, const QString &p, const QString &t, Configure::ProjectType qt )
183 	: directory( d ),
184 	  proFile( p ),
185 	  target( t ),
186 	  qmakeTemplate( qt )
187     { }
188 
189     QString directory;
190     QString proFile;
191     QString target;
192     Configure::ProjectType qmakeTemplate;
193 };
194 
195 
196 QT_END_NAMESPACE
197