2011-04-27 10:05:43 +00:00
|
|
|
/****************************************************************************
|
|
|
|
**
|
2016-01-15 12:36:27 +00:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
2016-01-21 01:24:57 +00:00
|
|
|
** Copyright (C) 2016 Intel Corporation.
|
2016-01-15 12:36:27 +00:00
|
|
|
** Contact: https://www.qt.io/licensing/
|
2011-04-27 10:05:43 +00:00
|
|
|
**
|
|
|
|
** This file is part of the tools applications of the Qt Toolkit.
|
|
|
|
**
|
2016-01-15 12:36:27 +00:00
|
|
|
** $QT_BEGIN_LICENSE:GPL-EXCEPT$
|
2012-09-19 12:28:29 +00:00
|
|
|
** Commercial License Usage
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2015-01-28 08:44:43 +00:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
2016-01-15 12:36:27 +00:00
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2012-09-19 12:28:29 +00:00
|
|
|
**
|
2016-01-15 12:36:27 +00:00
|
|
|
** GNU General Public License Usage
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2011-04-27 10:05:43 +00:00
|
|
|
**
|
|
|
|
** $QT_END_LICENSE$
|
|
|
|
**
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include "configureapp.h"
|
|
|
|
#include "environment.h"
|
|
|
|
|
|
|
|
#include <qdir.h>
|
2012-05-02 09:42:20 +00:00
|
|
|
#include <qdiriterator.h>
|
2011-04-27 10:05:43 +00:00
|
|
|
#include <qtemporaryfile.h>
|
2012-11-01 13:31:16 +00:00
|
|
|
#include <qstandardpaths.h>
|
2011-04-27 10:05:43 +00:00
|
|
|
#include <qstack.h>
|
|
|
|
#include <qdebug.h>
|
|
|
|
#include <qfileinfo.h>
|
|
|
|
#include <qtextstream.h>
|
|
|
|
#include <qregexp.h>
|
|
|
|
#include <qhash.h>
|
|
|
|
|
|
|
|
#include <iostream>
|
2012-05-18 05:23:50 +00:00
|
|
|
#include <string>
|
|
|
|
#include <fstream>
|
2011-04-27 10:05:43 +00:00
|
|
|
#include <windows.h>
|
|
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
2012-06-08 13:20:35 +00:00
|
|
|
enum Platforms {
|
|
|
|
WINDOWS,
|
2013-09-02 08:55:55 +00:00
|
|
|
WINDOWS_RT,
|
2012-06-08 13:20:35 +00:00
|
|
|
QNX,
|
2015-01-19 10:49:06 +00:00
|
|
|
ANDROID,
|
|
|
|
OTHER
|
2012-06-08 13:20:35 +00:00
|
|
|
};
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
std::ostream &operator<<(std::ostream &s, const QString &val) {
|
|
|
|
s << val.toLocal8Bit().data();
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
2016-08-14 07:48:55 +00:00
|
|
|
Configure::Configure(int& argc, char** argv)
|
2011-04-27 10:05:43 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 1; i < argc; i++)
|
|
|
|
configCmdLine += argv[ i ];
|
|
|
|
|
2012-02-08 10:38:07 +00:00
|
|
|
if (configCmdLine.size() >= 2 && configCmdLine.at(0) == "-srcdir") {
|
|
|
|
sourcePath = QDir::cleanPath(configCmdLine.at(1));
|
|
|
|
sourceDir = QDir(sourcePath);
|
|
|
|
configCmdLine.erase(configCmdLine.begin(), configCmdLine.begin() + 2);
|
|
|
|
} else {
|
|
|
|
// Get the path to the executable
|
|
|
|
wchar_t module_name[MAX_PATH];
|
|
|
|
GetModuleFileName(0, module_name, sizeof(module_name) / sizeof(wchar_t));
|
|
|
|
QFileInfo sourcePathInfo = QString::fromWCharArray(module_name);
|
|
|
|
sourcePath = sourcePathInfo.absolutePath();
|
|
|
|
sourceDir = sourcePathInfo.dir();
|
|
|
|
}
|
2011-04-27 10:05:43 +00:00
|
|
|
buildPath = QDir::currentPath();
|
|
|
|
#if 0
|
|
|
|
const QString installPath = QString("C:\\Qt\\%1").arg(QT_VERSION_STR);
|
|
|
|
#else
|
|
|
|
const QString installPath = buildPath;
|
|
|
|
#endif
|
|
|
|
if (sourceDir != buildDir) { //shadow builds!
|
|
|
|
QDir(buildPath).mkpath("bin");
|
|
|
|
|
|
|
|
buildDir.mkpath("mkspecs");
|
|
|
|
}
|
|
|
|
|
2012-03-28 14:00:06 +00:00
|
|
|
dictionary[ "QT_INSTALL_PREFIX" ] = installPath;
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
if (dictionary[ "QMAKESPEC" ].size() == 0) {
|
|
|
|
dictionary[ "QMAKESPEC" ] = Environment::detectQMakeSpec();
|
|
|
|
dictionary[ "QMAKESPEC_FROM" ] = "detected";
|
|
|
|
}
|
|
|
|
|
|
|
|
dictionary[ "SYNCQT" ] = "auto";
|
2012-06-20 14:00:34 +00:00
|
|
|
|
|
|
|
//Only used when cross compiling.
|
|
|
|
dictionary[ "QT_INSTALL_SETTINGS" ] = "/etc/xdg";
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
dictionary[ "REDO" ] = "no";
|
|
|
|
|
|
|
|
dictionary[ "BUILDTYPE" ] = "none";
|
|
|
|
|
|
|
|
QString tmp = dictionary[ "QMAKESPEC" ];
|
|
|
|
if (tmp.contains("\\")) {
|
|
|
|
tmp = tmp.mid(tmp.lastIndexOf("\\") + 1);
|
|
|
|
} else {
|
|
|
|
tmp = tmp.mid(tmp.lastIndexOf("/") + 1);
|
|
|
|
}
|
|
|
|
dictionary[ "QMAKESPEC" ] = tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
Configure::~Configure()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-03-28 14:00:06 +00:00
|
|
|
QString Configure::formatPath(const QString &path)
|
2011-04-27 10:05:43 +00:00
|
|
|
{
|
2012-03-28 14:00:06 +00:00
|
|
|
QString ret = QDir::cleanPath(path);
|
2012-06-25 15:18:37 +00:00
|
|
|
// This amount of quoting is deemed sufficient.
|
2012-03-28 14:00:06 +00:00
|
|
|
if (ret.contains(QLatin1Char(' '))) {
|
|
|
|
ret.prepend(QLatin1Char('"'));
|
|
|
|
ret.append(QLatin1Char('"'));
|
|
|
|
}
|
|
|
|
return ret;
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Configure::parseCmdLine()
|
|
|
|
{
|
2016-08-23 18:03:50 +00:00
|
|
|
sourcePathMangled = sourcePath;
|
|
|
|
buildPathMangled = buildPath;
|
2013-06-18 13:11:11 +00:00
|
|
|
if (configCmdLine.size() && configCmdLine.at(0) == "-top-level") {
|
|
|
|
dictionary[ "TOPLEVEL" ] = "yes";
|
|
|
|
configCmdLine.removeAt(0);
|
2016-08-23 18:03:50 +00:00
|
|
|
sourcePathMangled = QFileInfo(sourcePath).path();
|
|
|
|
buildPathMangled = QFileInfo(buildPath).path();
|
2013-06-18 13:11:11 +00:00
|
|
|
}
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
int argCount = configCmdLine.size();
|
|
|
|
int i = 0;
|
|
|
|
|
2016-07-06 10:47:12 +00:00
|
|
|
// Look first for -redo
|
|
|
|
for (int k = 0 ; k < argCount; ++k) {
|
|
|
|
if (configCmdLine.at(k) == "-redo") {
|
|
|
|
dictionary["REDO"] = "yes";
|
|
|
|
configCmdLine.removeAt(k);
|
2016-08-24 12:24:15 +00:00
|
|
|
if (!reloadCmdLine(k)) {
|
|
|
|
dictionary["DONE"] = "error";
|
|
|
|
return;
|
|
|
|
}
|
2016-07-06 10:47:12 +00:00
|
|
|
argCount = configCmdLine.size();
|
|
|
|
break;
|
|
|
|
}
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
2015-10-01 14:39:57 +00:00
|
|
|
|
2016-07-06 10:47:12 +00:00
|
|
|
// Then look for XQMAKESPEC
|
2012-10-17 20:06:41 +00:00
|
|
|
bool isDeviceMkspec = false;
|
2011-04-27 10:05:43 +00:00
|
|
|
for (int j = 0 ; j < argCount; ++j)
|
|
|
|
{
|
2012-10-17 20:06:41 +00:00
|
|
|
if ((configCmdLine.at(j) == "-xplatform") || (configCmdLine.at(j) == "-device")) {
|
|
|
|
isDeviceMkspec = (configCmdLine.at(j) == "-device");
|
2011-04-27 10:05:43 +00:00
|
|
|
++j;
|
|
|
|
if (j == argCount)
|
|
|
|
break;
|
|
|
|
dictionary["XQMAKESPEC"] = configCmdLine.at(j);
|
2012-10-17 20:06:41 +00:00
|
|
|
break;
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (; i<configCmdLine.size(); ++i) {
|
2016-08-14 07:48:55 +00:00
|
|
|
if (configCmdLine.at(i) == "-opensource") {
|
2011-04-27 10:05:43 +00:00
|
|
|
dictionary[ "BUILDTYPE" ] = "opensource";
|
|
|
|
}
|
|
|
|
else if (configCmdLine.at(i) == "-commercial") {
|
|
|
|
dictionary[ "BUILDTYPE" ] = "commercial";
|
|
|
|
}
|
|
|
|
else if (configCmdLine.at(i) == "-platform") {
|
|
|
|
++i;
|
|
|
|
if (i == argCount)
|
|
|
|
break;
|
|
|
|
dictionary[ "QMAKESPEC" ] = configCmdLine.at(i);
|
|
|
|
dictionary[ "QMAKESPEC_FROM" ] = "commandline";
|
2012-10-17 20:06:41 +00:00
|
|
|
} else if (configCmdLine.at(i) == "-xplatform"
|
|
|
|
|| configCmdLine.at(i) == "-device") {
|
2011-04-27 10:05:43 +00:00
|
|
|
++i;
|
|
|
|
// do nothing
|
2013-08-09 12:10:15 +00:00
|
|
|
} else if (configCmdLine.at(i) == "-device-option") {
|
|
|
|
++i;
|
|
|
|
const QString option = configCmdLine.at(i);
|
|
|
|
QString &devOpt = dictionary["DEVICE_OPTION"];
|
|
|
|
if (!devOpt.isEmpty())
|
|
|
|
devOpt.append("\n").append(option);
|
|
|
|
else
|
|
|
|
devOpt = option;
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
2012-02-08 10:38:07 +00:00
|
|
|
else if (configCmdLine.at(i) == "-no-syncqt")
|
|
|
|
dictionary[ "SYNCQT" ] = "no";
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
else if (configCmdLine.at(i) == "-confirm-license") {
|
|
|
|
dictionary["LICENSE_CONFIRMED"] = "yes";
|
|
|
|
}
|
|
|
|
|
|
|
|
// Directories ----------------------------------------------
|
|
|
|
else if (configCmdLine.at(i) == "-prefix") {
|
|
|
|
++i;
|
|
|
|
if (i == argCount)
|
|
|
|
break;
|
|
|
|
dictionary[ "QT_INSTALL_PREFIX" ] = configCmdLine.at(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (configCmdLine.at(i) == "-bindir") {
|
|
|
|
++i;
|
|
|
|
if (i == argCount)
|
|
|
|
break;
|
|
|
|
dictionary[ "QT_INSTALL_BINS" ] = configCmdLine.at(i);
|
|
|
|
}
|
|
|
|
|
2012-10-25 21:32:09 +00:00
|
|
|
else if (configCmdLine.at(i) == "-libexecdir") {
|
|
|
|
++i;
|
|
|
|
if (i == argCount)
|
|
|
|
break;
|
|
|
|
dictionary[ "QT_INSTALL_LIBEXECS" ] = configCmdLine.at(i);
|
|
|
|
}
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
else if (configCmdLine.at(i) == "-libdir") {
|
|
|
|
++i;
|
|
|
|
if (i == argCount)
|
|
|
|
break;
|
|
|
|
dictionary[ "QT_INSTALL_LIBS" ] = configCmdLine.at(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (configCmdLine.at(i) == "-docdir") {
|
|
|
|
++i;
|
|
|
|
if (i == argCount)
|
|
|
|
break;
|
|
|
|
dictionary[ "QT_INSTALL_DOCS" ] = configCmdLine.at(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (configCmdLine.at(i) == "-headerdir") {
|
|
|
|
++i;
|
|
|
|
if (i == argCount)
|
|
|
|
break;
|
|
|
|
dictionary[ "QT_INSTALL_HEADERS" ] = configCmdLine.at(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (configCmdLine.at(i) == "-plugindir") {
|
|
|
|
++i;
|
|
|
|
if (i == argCount)
|
|
|
|
break;
|
|
|
|
dictionary[ "QT_INSTALL_PLUGINS" ] = configCmdLine.at(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (configCmdLine.at(i) == "-importdir") {
|
|
|
|
++i;
|
|
|
|
if (i == argCount)
|
|
|
|
break;
|
|
|
|
dictionary[ "QT_INSTALL_IMPORTS" ] = configCmdLine.at(i);
|
|
|
|
}
|
2012-10-15 20:23:13 +00:00
|
|
|
|
|
|
|
else if (configCmdLine.at(i) == "-qmldir") {
|
|
|
|
++i;
|
|
|
|
if (i == argCount)
|
|
|
|
break;
|
|
|
|
dictionary[ "QT_INSTALL_QML" ] = configCmdLine.at(i);
|
|
|
|
}
|
|
|
|
|
2012-09-24 12:30:45 +00:00
|
|
|
else if (configCmdLine.at(i) == "-archdatadir") {
|
|
|
|
++i;
|
|
|
|
if (i == argCount)
|
|
|
|
break;
|
|
|
|
dictionary[ "QT_INSTALL_ARCHDATA" ] = configCmdLine.at(i);
|
|
|
|
}
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
else if (configCmdLine.at(i) == "-datadir") {
|
|
|
|
++i;
|
|
|
|
if (i == argCount)
|
|
|
|
break;
|
|
|
|
dictionary[ "QT_INSTALL_DATA" ] = configCmdLine.at(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (configCmdLine.at(i) == "-translationdir") {
|
|
|
|
++i;
|
|
|
|
if (i == argCount)
|
|
|
|
break;
|
|
|
|
dictionary[ "QT_INSTALL_TRANSLATIONS" ] = configCmdLine.at(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (configCmdLine.at(i) == "-examplesdir") {
|
|
|
|
++i;
|
|
|
|
if (i == argCount)
|
|
|
|
break;
|
|
|
|
dictionary[ "QT_INSTALL_EXAMPLES" ] = configCmdLine.at(i);
|
|
|
|
}
|
|
|
|
|
2011-11-17 05:39:19 +00:00
|
|
|
else if (configCmdLine.at(i) == "-testsdir") {
|
|
|
|
++i;
|
|
|
|
if (i == argCount)
|
|
|
|
break;
|
|
|
|
dictionary[ "QT_INSTALL_TESTS" ] = configCmdLine.at(i);
|
|
|
|
}
|
|
|
|
|
2012-02-28 19:57:38 +00:00
|
|
|
else if (configCmdLine.at(i) == "-sysroot") {
|
|
|
|
++i;
|
|
|
|
if (i == argCount)
|
|
|
|
break;
|
|
|
|
dictionary[ "CFG_SYSROOT" ] = configCmdLine.at(i);
|
|
|
|
}
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
else if (configCmdLine.at(i) == "-hostprefix") {
|
2012-02-28 19:57:38 +00:00
|
|
|
++i;
|
|
|
|
if (i == argCount || configCmdLine.at(i).startsWith('-'))
|
2013-07-24 11:48:36 +00:00
|
|
|
dictionary[ "QT_HOST_PREFIX" ] = buildPath;
|
2012-02-28 19:57:38 +00:00
|
|
|
else
|
|
|
|
dictionary[ "QT_HOST_PREFIX" ] = configCmdLine.at(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (configCmdLine.at(i) == "-hostbindir") {
|
2011-04-27 10:05:43 +00:00
|
|
|
++i;
|
|
|
|
if (i == argCount)
|
|
|
|
break;
|
2012-02-28 19:57:38 +00:00
|
|
|
dictionary[ "QT_HOST_BINS" ] = configCmdLine.at(i);
|
|
|
|
}
|
|
|
|
|
2013-05-08 13:30:56 +00:00
|
|
|
else if (configCmdLine.at(i) == "-hostlibdir") {
|
|
|
|
++i;
|
|
|
|
if (i == argCount)
|
|
|
|
break;
|
|
|
|
dictionary[ "QT_HOST_LIBS" ] = configCmdLine.at(i);
|
|
|
|
}
|
|
|
|
|
2012-02-28 19:57:38 +00:00
|
|
|
else if (configCmdLine.at(i) == "-hostdatadir") {
|
2011-04-27 10:05:43 +00:00
|
|
|
++i;
|
|
|
|
if (i == argCount)
|
|
|
|
break;
|
2012-02-28 19:57:38 +00:00
|
|
|
dictionary[ "QT_HOST_DATA" ] = configCmdLine.at(i);
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
2013-08-09 11:34:04 +00:00
|
|
|
else if (configCmdLine.at(i) == "-extprefix") {
|
|
|
|
++i;
|
|
|
|
if (i == argCount)
|
|
|
|
break;
|
|
|
|
dictionary[ "QT_EXT_PREFIX" ] = configCmdLine.at(i);
|
|
|
|
}
|
|
|
|
|
2012-03-21 10:09:59 +00:00
|
|
|
else if (configCmdLine.at(i) == "-make-tool") {
|
2011-04-27 10:05:43 +00:00
|
|
|
++i;
|
|
|
|
if (i == argCount)
|
|
|
|
break;
|
|
|
|
dictionary[ "MAKE" ] = configCmdLine.at(i);
|
|
|
|
}
|
|
|
|
|
2016-08-14 07:48:55 +00:00
|
|
|
else if (configCmdLine.at(i) == "-sysconfdir") {
|
|
|
|
++i;
|
|
|
|
if (i == argCount)
|
|
|
|
break;
|
|
|
|
dictionary["QT_INSTALL_SETTINGS"] = configCmdLine.at(i);
|
|
|
|
}
|
2012-02-14 09:01:17 +00:00
|
|
|
|
2016-08-14 07:48:55 +00:00
|
|
|
else if (configCmdLine.at(i) == "-android-ndk") {
|
|
|
|
++i;
|
|
|
|
if (i == argCount)
|
|
|
|
break;
|
|
|
|
dictionary[ "ANDROID_NDK_ROOT" ] = configCmdLine.at(i);
|
2014-07-02 12:42:58 +00:00
|
|
|
}
|
2013-11-05 19:36:01 +00:00
|
|
|
|
2016-08-14 07:48:55 +00:00
|
|
|
else if (configCmdLine.at(i) == "-android-sdk") {
|
|
|
|
++i;
|
|
|
|
if (i == argCount)
|
|
|
|
break;
|
|
|
|
dictionary[ "ANDROID_SDK_ROOT" ] = configCmdLine.at(i);
|
2012-09-20 19:40:39 +00:00
|
|
|
}
|
2012-03-27 17:43:45 +00:00
|
|
|
|
2016-08-14 07:48:55 +00:00
|
|
|
else if (configCmdLine.at(i) == "-android-ndk-platform") {
|
|
|
|
++i;
|
|
|
|
if (i == argCount)
|
|
|
|
break;
|
|
|
|
dictionary[ "ANDROID_PLATFORM" ] = configCmdLine.at(i);
|
2013-03-27 20:34:42 +00:00
|
|
|
}
|
2016-08-14 07:48:55 +00:00
|
|
|
|
|
|
|
else if (configCmdLine.at(i) == "-android-ndk-host") {
|
|
|
|
++i;
|
|
|
|
if (i == argCount)
|
|
|
|
break;
|
|
|
|
dictionary[ "ANDROID_HOST" ] = configCmdLine.at(i);
|
2012-03-27 17:43:45 +00:00
|
|
|
}
|
2016-08-14 07:48:55 +00:00
|
|
|
|
|
|
|
else if (configCmdLine.at(i) == "-android-arch") {
|
|
|
|
++i;
|
|
|
|
if (i == argCount)
|
|
|
|
break;
|
|
|
|
dictionary[ "ANDROID_TARGET_ARCH" ] = configCmdLine.at(i);
|
2012-03-27 17:43:45 +00:00
|
|
|
}
|
2016-08-14 07:48:55 +00:00
|
|
|
|
|
|
|
else if (configCmdLine.at(i) == "-android-toolchain-version") {
|
|
|
|
++i;
|
|
|
|
if (i == argCount)
|
|
|
|
break;
|
|
|
|
dictionary[ "ANDROID_NDK_TOOLCHAIN_VERSION" ] = configCmdLine.at(i);
|
2011-12-31 22:40:49 +00:00
|
|
|
}
|
2016-08-14 07:48:55 +00:00
|
|
|
}
|
2011-12-31 22:40:49 +00:00
|
|
|
|
2016-08-14 07:48:55 +00:00
|
|
|
// Ensure that QMAKESPEC exists in the mkspecs folder
|
|
|
|
const QString mkspecPath(sourcePath + "/mkspecs");
|
|
|
|
QDirIterator itMkspecs(mkspecPath, QDir::AllDirs | QDir::NoDotAndDotDot, QDirIterator::Subdirectories);
|
|
|
|
QStringList mkspecs;
|
2012-02-14 09:01:17 +00:00
|
|
|
|
2016-08-14 07:48:55 +00:00
|
|
|
while (itMkspecs.hasNext()) {
|
|
|
|
QString mkspec = itMkspecs.next();
|
|
|
|
// Remove base PATH
|
|
|
|
mkspec.remove(0, mkspecPath.length() + 1);
|
|
|
|
mkspecs << mkspec;
|
2012-02-14 09:01:17 +00:00
|
|
|
}
|
|
|
|
|
2016-08-14 07:48:55 +00:00
|
|
|
if (dictionary["QMAKESPEC"].toLower() == "features"
|
|
|
|
|| !mkspecs.contains(dictionary["QMAKESPEC"], Qt::CaseInsensitive)) {
|
|
|
|
dictionary[ "DONE" ] = "error";
|
|
|
|
if (dictionary ["QMAKESPEC_FROM"] == "commandline") {
|
|
|
|
cout << "Invalid option \"" << dictionary["QMAKESPEC"] << "\" for -platform." << endl;
|
|
|
|
} else { // was autodetected from environment
|
|
|
|
cout << "Unable to detect the platform from environment. Use -platform command line" << endl
|
2016-11-17 18:24:49 +00:00
|
|
|
<< "argument and run configure again." << endl;
|
2016-08-14 07:48:55 +00:00
|
|
|
}
|
|
|
|
cout << "See the README file for a list of supported operating systems and compilers." << endl;
|
|
|
|
} else {
|
|
|
|
if (dictionary[ "QMAKESPEC" ].endsWith("-icc") ||
|
|
|
|
dictionary[ "QMAKESPEC" ].endsWith("-msvc2012") ||
|
|
|
|
dictionary[ "QMAKESPEC" ].endsWith("-msvc2013") ||
|
2016-11-24 08:09:01 +00:00
|
|
|
dictionary[ "QMAKESPEC" ].endsWith("-msvc2015") ||
|
|
|
|
dictionary[ "QMAKESPEC" ].endsWith("-msvc2017")) {
|
2016-08-14 07:48:55 +00:00
|
|
|
if (dictionary[ "MAKE" ].isEmpty()) dictionary[ "MAKE" ] = "nmake";
|
|
|
|
dictionary[ "QMAKEMAKEFILE" ] = "Makefile.win32";
|
|
|
|
} else if (dictionary[ "QMAKESPEC" ].startsWith(QLatin1String("win32-g++"))) {
|
|
|
|
if (dictionary[ "MAKE" ].isEmpty()) dictionary[ "MAKE" ] = "mingw32-make";
|
|
|
|
dictionary[ "QMAKEMAKEFILE" ] = "Makefile.unix";
|
|
|
|
} else {
|
|
|
|
if (dictionary[ "MAKE" ].isEmpty()) dictionary[ "MAKE" ] = "make";
|
|
|
|
dictionary[ "QMAKEMAKEFILE" ] = "Makefile.win32";
|
|
|
|
}
|
2011-12-31 22:40:49 +00:00
|
|
|
}
|
2012-02-14 09:01:17 +00:00
|
|
|
|
2016-08-14 07:48:55 +00:00
|
|
|
if (isDeviceMkspec) {
|
|
|
|
const QStringList devices = mkspecs.filter("devices/", Qt::CaseInsensitive);
|
|
|
|
const QStringList family = devices.filter(dictionary["XQMAKESPEC"], Qt::CaseInsensitive);
|
2011-12-30 00:44:16 +00:00
|
|
|
|
2016-08-14 07:48:55 +00:00
|
|
|
if (family.isEmpty()) {
|
|
|
|
dictionary[ "DONE" ] = "error";
|
|
|
|
cout << "Error: No device matching '" << dictionary["XQMAKESPEC"] << "'." << endl;
|
|
|
|
} else if (family.size() > 1) {
|
|
|
|
dictionary[ "DONE" ] = "error";
|
2011-12-30 00:44:16 +00:00
|
|
|
|
2016-08-14 07:48:55 +00:00
|
|
|
cout << "Error: Multiple matches for device '" << dictionary["XQMAKESPEC"] << "'. Candidates are:" << endl;
|
2013-11-05 19:36:01 +00:00
|
|
|
|
2016-08-14 07:48:55 +00:00
|
|
|
foreach (const QString &device, family)
|
|
|
|
cout << "\t* " << device << endl;
|
|
|
|
} else {
|
|
|
|
Q_ASSERT(family.size() == 1);
|
|
|
|
dictionary["XQMAKESPEC"] = family.at(0);
|
|
|
|
}
|
2011-12-30 00:44:16 +00:00
|
|
|
|
2016-08-14 07:48:55 +00:00
|
|
|
} else {
|
|
|
|
// Ensure that -spec (XQMAKESPEC) exists in the mkspecs folder as well
|
|
|
|
if (dictionary.contains("XQMAKESPEC") &&
|
|
|
|
!mkspecs.contains(dictionary["XQMAKESPEC"], Qt::CaseInsensitive)) {
|
|
|
|
dictionary[ "DONE" ] = "error";
|
|
|
|
cout << "Invalid option \"" << dictionary["XQMAKESPEC"] << "\" for -xplatform." << endl;
|
|
|
|
}
|
2011-12-30 00:44:16 +00:00
|
|
|
}
|
2016-08-14 07:48:55 +00:00
|
|
|
}
|
|
|
|
|
2013-08-09 12:10:15 +00:00
|
|
|
void Configure::generateQDevicePri()
|
|
|
|
{
|
|
|
|
FileWriter deviceStream(buildPath + "/mkspecs/qdevice.pri");
|
|
|
|
if (dictionary.contains("DEVICE_OPTION")) {
|
|
|
|
const QString devoptionlist = dictionary["DEVICE_OPTION"];
|
|
|
|
const QStringList optionlist = devoptionlist.split(QStringLiteral("\n"));
|
|
|
|
foreach (const QString &entry, optionlist)
|
|
|
|
deviceStream << entry << "\n";
|
|
|
|
}
|
|
|
|
if (dictionary.contains("ANDROID_SDK_ROOT") && dictionary.contains("ANDROID_NDK_ROOT")) {
|
|
|
|
deviceStream << "android_install {" << endl;
|
|
|
|
deviceStream << " DEFAULT_ANDROID_SDK_ROOT = " << formatPath(dictionary["ANDROID_SDK_ROOT"]) << endl;
|
|
|
|
deviceStream << " DEFAULT_ANDROID_NDK_ROOT = " << formatPath(dictionary["ANDROID_NDK_ROOT"]) << endl;
|
2016-03-09 17:27:50 +00:00
|
|
|
if (dictionary.contains("ANDROID_HOST"))
|
|
|
|
deviceStream << " DEFAULT_ANDROID_NDK_HOST = " << dictionary["ANDROID_HOST"] << endl;
|
|
|
|
else if (QSysInfo::WordSize == 64)
|
2013-08-09 12:10:15 +00:00
|
|
|
deviceStream << " DEFAULT_ANDROID_NDK_HOST = windows-x86_64" << endl;
|
|
|
|
else
|
|
|
|
deviceStream << " DEFAULT_ANDROID_NDK_HOST = windows" << endl;
|
|
|
|
QString android_arch(dictionary.contains("ANDROID_TARGET_ARCH")
|
|
|
|
? dictionary["ANDROID_TARGET_ARCH"]
|
|
|
|
: QString("armeabi-v7a"));
|
|
|
|
QString android_tc_vers(dictionary.contains("ANDROID_NDK_TOOLCHAIN_VERSION")
|
|
|
|
? dictionary["ANDROID_NDK_TOOLCHAIN_VERSION"]
|
2014-10-31 08:52:36 +00:00
|
|
|
: QString("4.9"));
|
2014-10-30 15:16:01 +00:00
|
|
|
|
|
|
|
bool targetIs64Bit = android_arch == QString("arm64-v8a")
|
|
|
|
|| android_arch == QString("x86_64")
|
|
|
|
|| android_arch == QString("mips64");
|
|
|
|
QString android_platform(dictionary.contains("ANDROID_PLATFORM")
|
|
|
|
? dictionary["ANDROID_PLATFORM"]
|
|
|
|
: (targetIs64Bit ? QString("android-21") : QString("android-9")));
|
|
|
|
|
|
|
|
deviceStream << " DEFAULT_ANDROID_PLATFORM = " << android_platform << endl;
|
2013-08-09 12:10:15 +00:00
|
|
|
deviceStream << " DEFAULT_ANDROID_TARGET_ARCH = " << android_arch << endl;
|
|
|
|
deviceStream << " DEFAULT_ANDROID_NDK_TOOLCHAIN_VERSION = " << android_tc_vers << endl;
|
|
|
|
deviceStream << "}" << endl;
|
|
|
|
}
|
|
|
|
if (!deviceStream.flush())
|
|
|
|
dictionary[ "DONE" ] = "error";
|
|
|
|
}
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
void Configure::generateHeaders()
|
|
|
|
{
|
2012-09-11 13:08:48 +00:00
|
|
|
if (dictionary["SYNCQT"] == "auto")
|
2016-08-14 07:48:55 +00:00
|
|
|
dictionary["SYNCQT"] = QFile::exists(sourcePath + "/.git") ? "yes" : "no";
|
2012-09-11 13:08:48 +00:00
|
|
|
|
2011-09-07 18:08:34 +00:00
|
|
|
if (dictionary["SYNCQT"] == "yes") {
|
2012-11-01 13:31:16 +00:00
|
|
|
if (!QStandardPaths::findExecutable(QStringLiteral("perl.exe")).isEmpty()) {
|
2011-09-07 18:08:34 +00:00
|
|
|
cout << "Running syncqt..." << endl;
|
|
|
|
QStringList args;
|
2013-05-10 16:21:27 +00:00
|
|
|
args << "perl" << "-w";
|
|
|
|
args += sourcePath + "/bin/syncqt.pl";
|
2016-11-16 14:57:36 +00:00
|
|
|
args << "-version" << QT_VERSION_STR << "-minimal" << "-module" << "QtCore";
|
2012-01-23 07:27:06 +00:00
|
|
|
args += sourcePath;
|
2012-08-31 13:43:40 +00:00
|
|
|
int retc = Environment::execute(args, QStringList(), QStringList());
|
2011-09-07 18:08:34 +00:00
|
|
|
if (retc) {
|
|
|
|
cout << "syncqt failed, return code " << retc << endl << endl;
|
|
|
|
dictionary["DONE"] = "error";
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
cout << "Perl not found in environment - cannot run syncqt." << endl;
|
2011-04-27 10:05:43 +00:00
|
|
|
dictionary["DONE"] = "error";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-04 15:03:13 +00:00
|
|
|
void Configure::addConfStr(int group, const QString &val)
|
2013-08-09 11:34:04 +00:00
|
|
|
{
|
2014-12-04 15:03:13 +00:00
|
|
|
confStrOffsets[group] += ' ' + QString::number(confStringOff) + ',';
|
|
|
|
confStrings[group] += " \"" + val + "\\0\"\n";
|
|
|
|
confStringOff += val.length() + 1;
|
2013-08-09 11:34:04 +00:00
|
|
|
}
|
|
|
|
|
2012-06-14 14:17:11 +00:00
|
|
|
void Configure::generateQConfigCpp()
|
|
|
|
{
|
2014-12-03 09:13:41 +00:00
|
|
|
QString hostSpec = dictionary["QMAKESPEC"];
|
|
|
|
QString targSpec = dictionary.contains("XQMAKESPEC") ? dictionary["XQMAKESPEC"] : hostSpec;
|
|
|
|
|
2014-12-04 15:03:13 +00:00
|
|
|
dictionary["CFG_SYSROOT"] = QDir::cleanPath(dictionary["CFG_SYSROOT"]);
|
|
|
|
|
2012-06-14 14:17:11 +00:00
|
|
|
bool qipempty = false;
|
|
|
|
if (dictionary["QT_INSTALL_PREFIX"].isEmpty())
|
|
|
|
qipempty = true;
|
|
|
|
else
|
2014-12-04 15:03:13 +00:00
|
|
|
dictionary["QT_INSTALL_PREFIX"] = QDir::cleanPath(dictionary["QT_INSTALL_PREFIX"]);
|
|
|
|
|
|
|
|
bool sysrootifyPrefix;
|
|
|
|
if (dictionary["QT_EXT_PREFIX"].isEmpty()) {
|
|
|
|
dictionary["QT_EXT_PREFIX"] = dictionary["QT_INSTALL_PREFIX"];
|
|
|
|
sysrootifyPrefix = !dictionary["CFG_SYSROOT"].isEmpty();
|
|
|
|
} else {
|
|
|
|
dictionary["QT_EXT_PREFIX"] = QDir::cleanPath(dictionary["QT_EXT_PREFIX"]);
|
|
|
|
sysrootifyPrefix = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool haveHpx;
|
|
|
|
if (dictionary["QT_HOST_PREFIX"].isEmpty()) {
|
|
|
|
dictionary["QT_HOST_PREFIX"] = (sysrootifyPrefix ? dictionary["CFG_SYSROOT"] : QString())
|
|
|
|
+ dictionary["QT_INSTALL_PREFIX"];
|
|
|
|
haveHpx = false;
|
|
|
|
} else {
|
|
|
|
dictionary["QT_HOST_PREFIX"] = QDir::cleanPath(dictionary["QT_HOST_PREFIX"]);
|
2012-06-14 14:17:11 +00:00
|
|
|
haveHpx = true;
|
2014-12-04 15:03:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct {
|
|
|
|
const char *basevar, *baseoption, *var, *option;
|
|
|
|
} varmod[] = {
|
|
|
|
{ "INSTALL_", "-prefix", "DOCS", "-docdir" },
|
|
|
|
{ "INSTALL_", "-prefix", "HEADERS", "-headerdir" },
|
|
|
|
{ "INSTALL_", "-prefix", "LIBS", "-libdir" },
|
|
|
|
{ "INSTALL_", "-prefix", "LIBEXECS", "-libexecdir" },
|
|
|
|
{ "INSTALL_", "-prefix", "BINS", "-bindir" },
|
|
|
|
{ "INSTALL_", "-prefix", "PLUGINS", "-plugindir" },
|
|
|
|
{ "INSTALL_", "-prefix", "IMPORTS", "-importdir" },
|
|
|
|
{ "INSTALL_", "-prefix", "QML", "-qmldir" },
|
|
|
|
{ "INSTALL_", "-prefix", "ARCHDATA", "-archdatadir" },
|
|
|
|
{ "INSTALL_", "-prefix", "DATA", "-datadir" },
|
|
|
|
{ "INSTALL_", "-prefix", "TRANSLATIONS", "-translationdir" },
|
|
|
|
{ "INSTALL_", "-prefix", "EXAMPLES", "-examplesdir" },
|
|
|
|
{ "INSTALL_", "-prefix", "TESTS", "-testsdir" },
|
|
|
|
{ "INSTALL_", "-prefix", "SETTINGS", "-sysconfdir" },
|
|
|
|
{ "HOST_", "-hostprefix", "BINS", "-hostbindir" },
|
|
|
|
{ "HOST_", "-hostprefix", "LIBS", "-hostlibdir" },
|
|
|
|
{ "HOST_", "-hostprefix", "DATA", "-hostdatadir" },
|
|
|
|
};
|
|
|
|
|
|
|
|
bool prefixReminder = false;
|
2015-02-06 13:53:12 +00:00
|
|
|
for (uint i = 0; i < sizeof(varmod) / sizeof(varmod[0]); i++) {
|
2014-12-04 15:03:13 +00:00
|
|
|
QString path = QDir::cleanPath(
|
|
|
|
dictionary[QLatin1String("QT_") + varmod[i].basevar + varmod[i].var]);
|
|
|
|
if (path.isEmpty())
|
|
|
|
continue;
|
|
|
|
QString base = dictionary[QLatin1String("QT_") + varmod[i].basevar + "PREFIX"];
|
|
|
|
if (!path.startsWith(base)) {
|
|
|
|
if (i != 13) {
|
|
|
|
dictionary["PREFIX_COMPLAINTS"] += QLatin1String("\n NOTICE: ")
|
|
|
|
+ varmod[i].option + " is not a subdirectory of " + varmod[i].baseoption + ".";
|
|
|
|
if (i < 13 ? qipempty : !haveHpx)
|
|
|
|
prefixReminder = true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
path.remove(0, base.size());
|
|
|
|
if (path.startsWith('/'))
|
|
|
|
path.remove(0, 1);
|
|
|
|
}
|
|
|
|
dictionary[QLatin1String("QT_REL_") + varmod[i].basevar + varmod[i].var]
|
|
|
|
= path.isEmpty() ? "." : path;
|
|
|
|
}
|
|
|
|
if (prefixReminder) {
|
|
|
|
dictionary["PREFIX_COMPLAINTS"]
|
|
|
|
+= "\n Maybe you forgot to specify -prefix/-hostprefix?";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!qipempty) {
|
|
|
|
// If QT_INSTALL_* have not been specified on the command line,
|
|
|
|
// default them here, unless prefix is empty (WinCE).
|
|
|
|
|
|
|
|
if (dictionary["QT_REL_INSTALL_HEADERS"].isEmpty())
|
|
|
|
dictionary["QT_REL_INSTALL_HEADERS"] = "include";
|
|
|
|
|
|
|
|
if (dictionary["QT_REL_INSTALL_LIBS"].isEmpty())
|
|
|
|
dictionary["QT_REL_INSTALL_LIBS"] = "lib";
|
|
|
|
|
|
|
|
if (dictionary["QT_REL_INSTALL_BINS"].isEmpty())
|
|
|
|
dictionary["QT_REL_INSTALL_BINS"] = "bin";
|
|
|
|
|
|
|
|
if (dictionary["QT_REL_INSTALL_ARCHDATA"].isEmpty())
|
|
|
|
dictionary["QT_REL_INSTALL_ARCHDATA"] = ".";
|
|
|
|
if (dictionary["QT_REL_INSTALL_ARCHDATA"] != ".")
|
|
|
|
dictionary["QT_REL_INSTALL_ARCHDATA_PREFIX"] = dictionary["QT_REL_INSTALL_ARCHDATA"] + '/';
|
|
|
|
|
|
|
|
if (dictionary["QT_REL_INSTALL_LIBEXECS"].isEmpty()) {
|
|
|
|
if (targSpec.startsWith("win"))
|
|
|
|
dictionary["QT_REL_INSTALL_LIBEXECS"] = dictionary["QT_REL_INSTALL_ARCHDATA_PREFIX"] + "bin";
|
|
|
|
else
|
|
|
|
dictionary["QT_REL_INSTALL_LIBEXECS"] = dictionary["QT_REL_INSTALL_ARCHDATA_PREFIX"] + "libexec";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dictionary["QT_REL_INSTALL_PLUGINS"].isEmpty())
|
|
|
|
dictionary["QT_REL_INSTALL_PLUGINS"] = dictionary["QT_REL_INSTALL_ARCHDATA_PREFIX"] + "plugins";
|
|
|
|
|
|
|
|
if (dictionary["QT_REL_INSTALL_IMPORTS"].isEmpty())
|
|
|
|
dictionary["QT_REL_INSTALL_IMPORTS"] = dictionary["QT_REL_INSTALL_ARCHDATA_PREFIX"] + "imports";
|
|
|
|
|
|
|
|
if (dictionary["QT_REL_INSTALL_QML"].isEmpty())
|
|
|
|
dictionary["QT_REL_INSTALL_QML"] = dictionary["QT_REL_INSTALL_ARCHDATA_PREFIX"] + "qml";
|
|
|
|
|
|
|
|
if (dictionary["QT_REL_INSTALL_DATA"].isEmpty())
|
|
|
|
dictionary["QT_REL_INSTALL_DATA"] = ".";
|
|
|
|
if (dictionary["QT_REL_INSTALL_DATA"] != ".")
|
|
|
|
dictionary["QT_REL_INSTALL_DATA_PREFIX"] = dictionary["QT_REL_INSTALL_DATA"] + '/';
|
|
|
|
|
|
|
|
if (dictionary["QT_REL_INSTALL_DOCS"].isEmpty())
|
|
|
|
dictionary["QT_REL_INSTALL_DOCS"] = dictionary["QT_REL_INSTALL_DATA_PREFIX"] + "doc";
|
|
|
|
|
|
|
|
if (dictionary["QT_REL_INSTALL_TRANSLATIONS"].isEmpty())
|
|
|
|
dictionary["QT_REL_INSTALL_TRANSLATIONS"] = dictionary["QT_REL_INSTALL_DATA_PREFIX"] + "translations";
|
|
|
|
|
|
|
|
if (dictionary["QT_REL_INSTALL_EXAMPLES"].isEmpty())
|
|
|
|
dictionary["QT_REL_INSTALL_EXAMPLES"] = "examples";
|
|
|
|
|
|
|
|
if (dictionary["QT_REL_INSTALL_TESTS"].isEmpty())
|
|
|
|
dictionary["QT_REL_INSTALL_TESTS"] = "tests";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dictionary["QT_REL_HOST_BINS"].isEmpty())
|
|
|
|
dictionary["QT_REL_HOST_BINS"] = haveHpx ? "bin" : dictionary["QT_REL_INSTALL_BINS"];
|
|
|
|
|
|
|
|
if (dictionary["QT_REL_HOST_LIBS"].isEmpty())
|
|
|
|
dictionary["QT_REL_HOST_LIBS"] = haveHpx ? "lib" : dictionary["QT_REL_INSTALL_LIBS"];
|
|
|
|
|
|
|
|
if (dictionary["QT_REL_HOST_DATA"].isEmpty())
|
|
|
|
dictionary["QT_REL_HOST_DATA"] = haveHpx ? "." : dictionary["QT_REL_INSTALL_ARCHDATA"];
|
|
|
|
|
|
|
|
confStringOff = 0;
|
|
|
|
addConfStr(0, dictionary["QT_REL_INSTALL_DOCS"]);
|
|
|
|
addConfStr(0, dictionary["QT_REL_INSTALL_HEADERS"]);
|
|
|
|
addConfStr(0, dictionary["QT_REL_INSTALL_LIBS"]);
|
|
|
|
addConfStr(0, dictionary["QT_REL_INSTALL_LIBEXECS"]);
|
|
|
|
addConfStr(0, dictionary["QT_REL_INSTALL_BINS"]);
|
|
|
|
addConfStr(0, dictionary["QT_REL_INSTALL_PLUGINS"]);
|
|
|
|
addConfStr(0, dictionary["QT_REL_INSTALL_IMPORTS"]);
|
|
|
|
addConfStr(0, dictionary["QT_REL_INSTALL_QML"]);
|
|
|
|
addConfStr(0, dictionary["QT_REL_INSTALL_ARCHDATA"]);
|
|
|
|
addConfStr(0, dictionary["QT_REL_INSTALL_DATA"]);
|
|
|
|
addConfStr(0, dictionary["QT_REL_INSTALL_TRANSLATIONS"]);
|
|
|
|
addConfStr(0, dictionary["QT_REL_INSTALL_EXAMPLES"]);
|
|
|
|
addConfStr(0, dictionary["QT_REL_INSTALL_TESTS"]);
|
|
|
|
addConfStr(1, dictionary["CFG_SYSROOT"]);
|
|
|
|
addConfStr(1, dictionary["QT_REL_HOST_BINS"]);
|
|
|
|
addConfStr(1, dictionary["QT_REL_HOST_LIBS"]);
|
|
|
|
addConfStr(1, dictionary["QT_REL_HOST_DATA"]);
|
|
|
|
addConfStr(1, targSpec);
|
|
|
|
addConfStr(1, hostSpec);
|
2012-06-14 14:17:11 +00:00
|
|
|
|
2013-07-15 14:45:44 +00:00
|
|
|
// Generate the new qconfig.cpp file
|
|
|
|
{
|
|
|
|
FileWriter tmpStream(buildPath + "/src/corelib/global/qconfig.cpp");
|
2016-05-11 12:36:13 +00:00
|
|
|
tmpStream << "/* Build date */" << endl
|
2015-02-05 06:37:13 +00:00
|
|
|
<< "static const char qt_configure_installation [11 + 12] = \"qt_instdate=2012-12-20\";" << endl
|
2012-06-14 14:17:11 +00:00
|
|
|
<< endl
|
2014-12-04 15:03:13 +00:00
|
|
|
<< "/* Installation Info */" << endl
|
|
|
|
<< "static const char qt_configure_prefix_path_str [512 + 12] = \"qt_prfxpath=" << dictionary["QT_INSTALL_PREFIX"] << "\";" << endl
|
2014-12-03 21:07:29 +00:00
|
|
|
<< "#ifdef QT_BUILD_QMAKE" << endl
|
|
|
|
<< "static const char qt_configure_ext_prefix_path_str [512 + 12] = \"qt_epfxpath=" << dictionary["QT_EXT_PREFIX"] << "\";" << endl
|
2014-12-04 15:03:13 +00:00
|
|
|
<< "static const char qt_configure_host_prefix_path_str [512 + 12] = \"qt_hpfxpath=" << dictionary["QT_HOST_PREFIX"] << "\";" << endl
|
2012-06-14 14:17:11 +00:00
|
|
|
<< "#endif" << endl
|
2014-12-04 15:03:13 +00:00
|
|
|
<< endl
|
|
|
|
<< "static const short qt_configure_str_offsets[] = {\n"
|
|
|
|
<< " " << confStrOffsets[0] << endl
|
|
|
|
<< "#ifdef QT_BUILD_QMAKE\n"
|
|
|
|
<< " " << confStrOffsets[1] << endl
|
|
|
|
<< "#endif\n"
|
|
|
|
<< "};\n"
|
|
|
|
<< "static const char qt_configure_strs[] =\n"
|
|
|
|
<< confStrings[0] << "#ifdef QT_BUILD_QMAKE\n"
|
|
|
|
<< confStrings[1] << "#endif\n"
|
|
|
|
<< ";\n"
|
|
|
|
<< endl;
|
2016-03-04 16:11:09 +00:00
|
|
|
if ((platform() != WINDOWS) && (platform() != WINDOWS_RT))
|
2015-02-25 11:11:23 +00:00
|
|
|
tmpStream << "#define QT_CONFIGURE_SETTINGS_PATH \"" << dictionary["QT_REL_INSTALL_SETTINGS"] << "\"" << endl;
|
2012-06-14 14:17:11 +00:00
|
|
|
|
|
|
|
tmpStream << endl
|
2013-08-09 11:34:04 +00:00
|
|
|
<< "#ifdef QT_BUILD_QMAKE\n"
|
2014-12-04 15:03:13 +00:00
|
|
|
<< "# define QT_CONFIGURE_SYSROOTIFY_PREFIX " << (sysrootifyPrefix ? "true" : "false") << endl
|
2013-08-09 11:34:04 +00:00
|
|
|
<< "#endif\n\n"
|
2014-12-04 15:03:13 +00:00
|
|
|
<< endl
|
|
|
|
<< "#define QT_CONFIGURE_PREFIX_PATH qt_configure_prefix_path_str + 12\n"
|
|
|
|
<< "#ifdef QT_BUILD_QMAKE\n"
|
2014-12-03 21:07:29 +00:00
|
|
|
<< "# define QT_CONFIGURE_EXT_PREFIX_PATH qt_configure_ext_prefix_path_str + 12\n"
|
2014-12-04 15:03:13 +00:00
|
|
|
<< "# define QT_CONFIGURE_HOST_PREFIX_PATH qt_configure_host_prefix_path_str + 12\n"
|
|
|
|
<< "#endif\n";
|
2012-06-14 14:17:11 +00:00
|
|
|
|
2013-07-15 14:45:44 +00:00
|
|
|
if (!tmpStream.flush())
|
|
|
|
dictionary[ "DONE" ] = "error";
|
2012-06-14 14:17:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
void Configure::buildQmake()
|
|
|
|
{
|
2016-07-07 14:53:13 +00:00
|
|
|
{
|
2011-04-27 10:05:43 +00:00
|
|
|
QStringList args;
|
|
|
|
|
|
|
|
// Build qmake
|
|
|
|
QString pwd = QDir::currentPath();
|
2012-03-09 09:50:23 +00:00
|
|
|
if (!QDir(buildPath).mkpath("qmake")) {
|
|
|
|
cout << "Cannot create qmake build dir." << endl;
|
|
|
|
dictionary[ "DONE" ] = "error";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!QDir::setCurrent(buildPath + "/qmake")) {
|
|
|
|
cout << "Cannot enter qmake build dir." << endl;
|
|
|
|
dictionary[ "DONE" ] = "error";
|
|
|
|
return;
|
|
|
|
}
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
QString makefile = "Makefile";
|
|
|
|
{
|
|
|
|
QFile out(makefile);
|
|
|
|
if (out.open(QFile::WriteOnly | QFile::Text)) {
|
|
|
|
QTextStream stream(&out);
|
|
|
|
stream << "#AutoGenerated by configure.exe" << endl
|
2014-11-20 14:33:54 +00:00
|
|
|
<< "BUILD_PATH = .." << endl
|
2013-05-28 19:34:05 +00:00
|
|
|
<< "SOURCE_PATH = " << QDir::toNativeSeparators(sourcePath) << endl
|
|
|
|
<< "INC_PATH = " << QDir::toNativeSeparators(
|
2014-11-20 14:33:54 +00:00
|
|
|
(QFile::exists(sourcePath + "/.git") ? ".." : sourcePath)
|
2013-05-28 19:34:05 +00:00
|
|
|
+ "/include") << endl;
|
2016-11-16 14:57:36 +00:00
|
|
|
stream << "QT_VERSION = " QT_VERSION_STR << endl
|
|
|
|
<< "QT_MAJOR_VERSION = " QT_STRINGIFY(QT_VERSION_MAJOR) << endl
|
|
|
|
<< "QT_MINOR_VERSION = " QT_STRINGIFY(QT_VERSION_MINOR) << endl
|
|
|
|
<< "QT_PATCH_VERSION = " QT_STRINGIFY(QT_VERSION_PATCH) << endl;
|
2015-09-22 21:58:05 +00:00
|
|
|
if (dictionary[ "QMAKESPEC" ].startsWith("win32-g++")) {
|
|
|
|
stream << "QMAKESPEC = $(SOURCE_PATH)\\mkspecs\\" << dictionary[ "QMAKESPEC" ] << endl
|
2016-11-18 15:27:15 +00:00
|
|
|
<< "CONFIG_CXXFLAGS = -std=c++11 -ffunction-sections" << endl
|
|
|
|
<< "CONFIG_LFLAGS = -Wl,--gc-sections" << endl;
|
|
|
|
|
|
|
|
QFile in(sourcePath + "/qmake/Makefile.unix.win32");
|
|
|
|
if (in.open(QFile::ReadOnly | QFile::Text))
|
|
|
|
stream << in.readAll();
|
|
|
|
QFile in2(sourcePath + "/qmake/Makefile.unix.mingw");
|
|
|
|
if (in2.open(QFile::ReadOnly | QFile::Text))
|
|
|
|
stream << in2.readAll();
|
2013-02-02 12:31:53 +00:00
|
|
|
} else {
|
|
|
|
stream << "QMAKESPEC = " << dictionary["QMAKESPEC"] << endl;
|
|
|
|
}
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
stream << "\n\n";
|
|
|
|
|
|
|
|
QFile in(sourcePath + "/qmake/" + dictionary["QMAKEMAKEFILE"]);
|
|
|
|
if (in.open(QFile::ReadOnly | QFile::Text)) {
|
|
|
|
QString d = in.readAll();
|
|
|
|
//### need replaces (like configure.sh)? --Sam
|
|
|
|
stream << d << endl;
|
|
|
|
}
|
|
|
|
stream.flush();
|
|
|
|
out.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
args += dictionary[ "MAKE" ];
|
|
|
|
args += "-f";
|
|
|
|
args += makefile;
|
|
|
|
|
|
|
|
cout << "Creating qmake..." << endl;
|
|
|
|
int exitCode = Environment::execute(args, QStringList(), QStringList());
|
|
|
|
if (exitCode) {
|
|
|
|
args.clear();
|
|
|
|
args += dictionary[ "MAKE" ];
|
|
|
|
args += "-f";
|
|
|
|
args += makefile;
|
|
|
|
args += "clean";
|
|
|
|
exitCode = Environment::execute(args, QStringList(), QStringList());
|
|
|
|
if (exitCode) {
|
|
|
|
cout << "Cleaning qmake failed, return code " << exitCode << endl << endl;
|
|
|
|
dictionary[ "DONE" ] = "error";
|
|
|
|
} else {
|
|
|
|
args.clear();
|
|
|
|
args += dictionary[ "MAKE" ];
|
|
|
|
args += "-f";
|
|
|
|
args += makefile;
|
|
|
|
exitCode = Environment::execute(args, QStringList(), QStringList());
|
|
|
|
if (exitCode) {
|
|
|
|
cout << "Building qmake failed, return code " << exitCode << endl << endl;
|
|
|
|
dictionary[ "DONE" ] = "error";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
QDir::setCurrent(pwd);
|
|
|
|
}
|
2012-05-03 13:36:03 +00:00
|
|
|
|
|
|
|
// Generate qt.conf
|
|
|
|
QFile confFile(buildPath + "/bin/qt.conf");
|
|
|
|
if (confFile.open(QFile::WriteOnly | QFile::Text)) { // Truncates any existing file.
|
|
|
|
QTextStream confStream(&confFile);
|
|
|
|
confStream << "[EffectivePaths]" << endl
|
|
|
|
<< "Prefix=.." << endl;
|
2013-05-08 14:29:11 +00:00
|
|
|
if (sourcePath != buildPath)
|
|
|
|
confStream << "[EffectiveSourcePaths]" << endl
|
|
|
|
<< "Prefix=" << sourcePath << endl;
|
2012-05-03 13:36:03 +00:00
|
|
|
|
|
|
|
confStream.flush();
|
|
|
|
confFile.close();
|
|
|
|
}
|
2012-07-18 12:01:08 +00:00
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
2016-08-14 07:48:55 +00:00
|
|
|
void Configure::configure()
|
|
|
|
{
|
|
|
|
QStringList args;
|
|
|
|
args << buildPath + "/bin/qmake"
|
Modularize the new configure system (infrastructure part)
This change implements the required infrastructure to modularize the new
configuration system.
This requires a hierarchy of configuration files, both for handling
multiple repositories and for individual modules inside the same
repository.
When configuring, they all need to get loaded first, as command line
processing needs to know about all possible command line options.
When the command line has been processed, the individual configuration
files need to get processed one after the other and independently from
each other.
Configure is now automatically invoked when building the a project
tree's "root" project; this works with both modular and top-level builds
of Qt (the latter with an according change in the super repo). As an
immediate consequence, the -skip option moves to the super repo with a
different implementation, as configuration is now done after the repo
list is determined. The option belongs there anyway.
This commit also adds an optional testDir entry to the json file. Like
this, we can still have all configure tests in qtbase/config.tests and
the configuration file in, e.g., corelib can reference those.
The files section can now be left out as long as a 'module' entry is
present, specifying the module name. The names of the files to generate
can then be deduced from that name. We still need to be able to specify
names directly for the global configuration files.
qtConfig() now also queries features which are module-specific. As it is
sometimes necessary to query the configuration of modules which should
not be actually linked (and cannot in the case of subdirs projects), the
new variable QT_FOR_CONFIG which allows specifying configuration-only
dependencies is introduced.
Done-with: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Change-Id: Id1b518a3aa34044748b87fb8fac14d79653f6b18
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
2016-08-25 13:45:44 +00:00
|
|
|
<< sourcePathMangled
|
2016-08-14 07:48:55 +00:00
|
|
|
<< "--" << configCmdLine;
|
|
|
|
|
Modularize the new configure system (infrastructure part)
This change implements the required infrastructure to modularize the new
configuration system.
This requires a hierarchy of configuration files, both for handling
multiple repositories and for individual modules inside the same
repository.
When configuring, they all need to get loaded first, as command line
processing needs to know about all possible command line options.
When the command line has been processed, the individual configuration
files need to get processed one after the other and independently from
each other.
Configure is now automatically invoked when building the a project
tree's "root" project; this works with both modular and top-level builds
of Qt (the latter with an according change in the super repo). As an
immediate consequence, the -skip option moves to the super repo with a
different implementation, as configuration is now done after the repo
list is determined. The option belongs there anyway.
This commit also adds an optional testDir entry to the json file. Like
this, we can still have all configure tests in qtbase/config.tests and
the configuration file in, e.g., corelib can reference those.
The files section can now be left out as long as a 'module' entry is
present, specifying the module name. The names of the files to generate
can then be deduced from that name. We still need to be able to specify
names directly for the global configuration files.
qtConfig() now also queries features which are module-specific. As it is
sometimes necessary to query the configuration of modules which should
not be actually linked (and cannot in the case of subdirs projects), the
new variable QT_FOR_CONFIG which allows specifying configuration-only
dependencies is introduced.
Done-with: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Change-Id: Id1b518a3aa34044748b87fb8fac14d79653f6b18
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
2016-08-25 13:45:44 +00:00
|
|
|
QString pwd = QDir::currentPath();
|
|
|
|
QDir::setCurrent(buildPathMangled);
|
2016-08-14 07:48:55 +00:00
|
|
|
if (int exitCode = Environment::execute(args, QStringList(), QStringList())) {
|
|
|
|
cout << "Qmake failed, return code " << exitCode << endl << endl;
|
|
|
|
dictionary[ "DONE" ] = "error";
|
|
|
|
}
|
Modularize the new configure system (infrastructure part)
This change implements the required infrastructure to modularize the new
configuration system.
This requires a hierarchy of configuration files, both for handling
multiple repositories and for individual modules inside the same
repository.
When configuring, they all need to get loaded first, as command line
processing needs to know about all possible command line options.
When the command line has been processed, the individual configuration
files need to get processed one after the other and independently from
each other.
Configure is now automatically invoked when building the a project
tree's "root" project; this works with both modular and top-level builds
of Qt (the latter with an according change in the super repo). As an
immediate consequence, the -skip option moves to the super repo with a
different implementation, as configuration is now done after the repo
list is determined. The option belongs there anyway.
This commit also adds an optional testDir entry to the json file. Like
this, we can still have all configure tests in qtbase/config.tests and
the configuration file in, e.g., corelib can reference those.
The files section can now be left out as long as a 'module' entry is
present, specifying the module name. The names of the files to generate
can then be deduced from that name. We still need to be able to specify
names directly for the global configuration files.
qtConfig() now also queries features which are module-specific. As it is
sometimes necessary to query the configuration of modules which should
not be actually linked (and cannot in the case of subdirs projects), the
new variable QT_FOR_CONFIG which allows specifying configuration-only
dependencies is introduced.
Done-with: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Change-Id: Id1b518a3aa34044748b87fb8fac14d79653f6b18
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
2016-08-25 13:45:44 +00:00
|
|
|
QDir::setCurrent(pwd);
|
2016-08-23 17:20:37 +00:00
|
|
|
|
|
|
|
if ((dictionary["REDO"] != "yes") && (dictionary["DONE"] != "error"))
|
|
|
|
saveCmdLine();
|
2016-08-14 07:48:55 +00:00
|
|
|
}
|
|
|
|
|
2016-08-24 12:24:15 +00:00
|
|
|
bool Configure::reloadCmdLine(int idx)
|
2011-04-27 10:05:43 +00:00
|
|
|
{
|
2016-08-23 18:03:50 +00:00
|
|
|
QFile inFile(buildPathMangled + "/config.opt");
|
2016-07-06 10:56:02 +00:00
|
|
|
if (!inFile.open(QFile::ReadOnly)) {
|
2016-08-23 18:03:50 +00:00
|
|
|
inFile.setFileName(buildPath + "/config.opt");
|
|
|
|
if (!inFile.open(QFile::ReadOnly)) {
|
|
|
|
inFile.setFileName(buildPath + "/configure.cache");
|
2016-08-24 12:24:15 +00:00
|
|
|
if (!inFile.open(QFile::ReadOnly)) {
|
|
|
|
cout << "No config.opt present - cannot redo configuration." << endl;
|
|
|
|
return false;
|
|
|
|
}
|
2016-08-23 18:03:50 +00:00
|
|
|
}
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
2016-07-06 10:56:02 +00:00
|
|
|
QTextStream inStream(&inFile);
|
|
|
|
while (!inStream.atEnd())
|
|
|
|
configCmdLine.insert(idx++, inStream.readLine().trimmed());
|
2016-08-24 12:24:15 +00:00
|
|
|
return true;
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Configure::saveCmdLine()
|
|
|
|
{
|
|
|
|
if (dictionary[ "REDO" ] != "yes") {
|
2016-11-18 17:17:49 +00:00
|
|
|
if (dictionary["BUILDTYPE"] == "none") {
|
|
|
|
bool openSource = false;
|
|
|
|
QFile inFile(buildPath + "/mkspecs/qconfig.pri");
|
|
|
|
if (inFile.open(QFile::ReadOnly | QFile::Text)) {
|
|
|
|
QTextStream inStream(&inFile);
|
|
|
|
while (!inStream.atEnd()) {
|
|
|
|
if (inStream.readLine() == "QT_EDITION = OpenSource")
|
|
|
|
openSource = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
configCmdLine.append(openSource ? "-opensource" : "-commercial");
|
|
|
|
}
|
|
|
|
if (dictionary["LICENSE_CONFIRMED"] != "yes")
|
|
|
|
configCmdLine.append("-confirm-license");
|
2016-08-23 18:03:50 +00:00
|
|
|
QFile outFile(buildPathMangled + "/config.opt");
|
2011-04-27 10:05:43 +00:00
|
|
|
if (outFile.open(QFile::WriteOnly | QFile::Text)) {
|
|
|
|
QTextStream outStream(&outFile);
|
|
|
|
for (QStringList::Iterator it = configCmdLine.begin(); it != configCmdLine.end(); ++it) {
|
2014-11-18 19:21:09 +00:00
|
|
|
outStream << (*it) << endl;
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
outStream.flush();
|
|
|
|
outFile.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Configure::isDone()
|
|
|
|
{
|
|
|
|
return !dictionary["DONE"].isEmpty();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Configure::isOk()
|
|
|
|
{
|
|
|
|
return (dictionary[ "DONE" ] != "error");
|
|
|
|
}
|
|
|
|
|
2012-06-08 13:20:35 +00:00
|
|
|
int Configure::platform() const
|
|
|
|
{
|
|
|
|
const QString xQMakeSpec = dictionary.value("XQMAKESPEC");
|
|
|
|
|
2013-09-02 08:55:55 +00:00
|
|
|
if ((xQMakeSpec.startsWith("winphone") || xQMakeSpec.startsWith("winrt")))
|
|
|
|
return WINDOWS_RT;
|
|
|
|
|
2012-06-08 13:20:35 +00:00
|
|
|
if (xQMakeSpec.contains("qnx"))
|
|
|
|
return QNX;
|
|
|
|
|
2013-03-27 20:34:42 +00:00
|
|
|
if (xQMakeSpec.contains("android"))
|
|
|
|
return ANDROID;
|
|
|
|
|
2015-01-19 10:49:06 +00:00
|
|
|
if (!xQMakeSpec.isEmpty())
|
|
|
|
return OTHER;
|
|
|
|
|
2012-06-08 13:20:35 +00:00
|
|
|
return WINDOWS;
|
|
|
|
}
|
|
|
|
|
2013-07-15 14:45:44 +00:00
|
|
|
FileWriter::FileWriter(const QString &name)
|
|
|
|
: QTextStream()
|
|
|
|
, m_name(name)
|
2011-04-27 10:05:43 +00:00
|
|
|
{
|
2013-07-15 14:45:44 +00:00
|
|
|
m_buffer.open(QIODevice::WriteOnly);
|
|
|
|
setDevice(&m_buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool FileWriter::flush()
|
|
|
|
{
|
|
|
|
QTextStream::flush();
|
2013-07-15 14:46:28 +00:00
|
|
|
QFile oldFile(m_name);
|
|
|
|
if (oldFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
|
|
|
if (oldFile.readAll() == m_buffer.data())
|
|
|
|
return true;
|
|
|
|
oldFile.close();
|
|
|
|
}
|
2013-07-15 14:45:44 +00:00
|
|
|
QString dir = QFileInfo(m_name).absolutePath();
|
|
|
|
if (!QDir().mkpath(dir)) {
|
|
|
|
cout << "Cannot create directory " << qPrintable(QDir::toNativeSeparators(dir)) << ".\n";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
QFile file(m_name + ".new");
|
|
|
|
if (file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
|
|
|
if (file.write(m_buffer.data()) == m_buffer.data().size()) {
|
|
|
|
file.close();
|
|
|
|
if (file.error() == QFile::NoError) {
|
|
|
|
::SetFileAttributes((wchar_t*)m_name.utf16(), FILE_ATTRIBUTE_NORMAL);
|
|
|
|
QFile::remove(m_name);
|
|
|
|
if (!file.rename(m_name)) {
|
|
|
|
cout << "Cannot replace file " << qPrintable(QDir::toNativeSeparators(m_name)) << ".\n";
|
|
|
|
return false;
|
|
|
|
}
|
2011-04-27 10:05:43 +00:00
|
|
|
return true;
|
2013-07-15 14:45:44 +00:00
|
|
|
}
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
}
|
2013-07-15 14:45:44 +00:00
|
|
|
cout << "Cannot create file " << qPrintable(QDir::toNativeSeparators(file.fileName()))
|
|
|
|
<< ": " << qPrintable(file.errorString()) << ".\n";
|
|
|
|
file.remove();
|
|
|
|
return false;
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QT_END_NAMESPACE
|