Newer
Older
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
if (m_versionInfo.contains("QT_INSTALL_BINS")) {
QFileInfo fi(m_versionInfo.value("QT_INSTALL_BINS"));
if (!fi.exists())
m_notInstalled = true;
}
if (m_versionInfo.contains("QT_INSTALL_HEADERS")){
QFileInfo fi(m_versionInfo.value("QT_INSTALL_HEADERS"));
if (!fi.exists())
m_notInstalled = true;
}
// Parse qconfigpri
QString baseDir = m_versionInfo.contains("QT_INSTALL_DATA") ?
m_versionInfo.value("QT_INSTALL_DATA") :
m_path;
QFile qconfigpri(baseDir + QLatin1String("/mkspecs/qconfig.pri"));
if (qconfigpri.exists()) {
qconfigpri.open(QIODevice::ReadOnly | QIODevice::Text);
QTextStream stream(&qconfigpri);
while (!stream.atEnd()) {
QString line = stream.readLine().trimmed();
if (line.startsWith(QLatin1String("CONFIG"))) {
m_defaultConfigIsDebugAndRelease = false;
QStringList values = line.split(QLatin1Char('=')).at(1).trimmed().split(" ");
foreach(const QString &value, values) {
if (value == "debug")
m_defaultConfigIsDebug = true;
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
m_defaultConfigIsDebugAndRelease = true;
}
}
}
}
}
m_versionInfoUpToDate = true;
}
bool QtVersion::isInstalled() const
{
updateVersionInfo();
return !m_notInstalled;
}
void QtVersion::updateMkSpec() const
{
if (m_mkspecUpToDate)
return;
//qDebug()<<"Finding mkspec for"<<path();
QString mkspec;
// QFile f(path() + "/.qmake.cache");
// if (f.exists() && f.open(QIODevice::ReadOnly)) {
// const QList<QByteArray> &temp = line.split('=');
// mkspec = temp.at(1).trimmed();
// if (mkspec.startsWith("$$QT_BUILD_TREE/mkspecs/"))
// mkspec = mkspec.mid(QString("$$QT_BUILD_TREE/mkspecs/").length());
// else if (mkspec.startsWith("$$QT_BUILD_TREE\\mkspecs\\"))
// mkspec = mkspec.mid(QString("$$QT_BUILD_TREE\\mkspecs\\").length());

dt
committed
// mkspec = QDir::fromNativeSeparators(mkspec);
// }
// break;
// }
// }
// f.close();
// } else {
// no .qmake.cache so look at the default mkspec
QString mkspecPath = versionInfo().value("QMAKE_MKSPECS");
if (mkspecPath.isEmpty())
mkspecPath = path() + "/mkspecs/default";
else
mkspecPath = mkspecPath + "/default";
// qDebug() << "default mkspec is located at" << mkspecPath;
#ifdef Q_OS_WIN
QFile f2(mkspecPath + "/qmake.conf");
if (f2.exists() && f2.open(QIODevice::ReadOnly)) {
const QList<QByteArray> &temp = line.split('=');
if (temp.size() == 2) {
}
break;
}
}
f2.close();
}
#elif defined(Q_OS_MAC)
QFile f2(mkspecPath + "/qmake.conf");
if (f2.exists() && f2.open(QIODevice::ReadOnly)) {
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
const QList<QByteArray> &temp = line.split('=');
if (temp.size() == 2) {
const QByteArray &value = temp.at(1);
if (value.contains("XCODE")) {
// we don't want to generate xcode projects...
// qDebug() << "default mkspec is xcode, falling back to g++";
mkspec = "macx-g++";
} else {
//resolve mkspec link
QFileInfo f3(mkspecPath);
if (f3.isSymLink()) {
mkspec = f3.symLinkTarget();
}
}
}
break;
}
}
f2.close();
}
#else
QFileInfo f2(mkspecPath);
if (f2.isSymLink()) {
mkspec = f2.symLinkTarget();
}
#endif
m_mkspecFullPath = mkspec;
int index = mkspec.lastIndexOf('/');
QString mkspecDir = QDir(m_path + "/mkspecs/").canonicalPath();
if (index >= 0 && QDir(mkspec.left(index)).canonicalPath() == mkspecDir)
mkspec = mkspec.mid(index+1).trimmed();
m_mkspec = mkspec;
m_mkspecUpToDate = true;
// qDebug()<<"mkspec for "<<m_path<<" is "<<mkspec;
}
QString QtVersion::makeCommand() const
{
#ifdef Q_OS_WIN
const QString &spec = mkspec();
if (spec.contains("win32-msvc") || spec.contains(QLatin1String("win32-icc")))
return "nmake.exe";
else
return "mingw32-make.exe";
#else
return "make";
#endif
}
QString QtVersion::qmakeCommand() const
{
// We can't use versionInfo QT_INSTALL_BINS here
// because that functions calls us to find out the values for versionInfo
if (!m_qmakeCommand.isNull())
return m_qmakeCommand;
QDir qtDir = path() + "/bin/";
foreach (const QString &possibleCommand, QtVersionManager::possibleQMakeCommands()) {
QString s = qtDir.absoluteFilePath(possibleCommand);
QFileInfo qmake(s);
if (qmake.exists() && qmake.isExecutable()) {
QString qtVersion = QtVersionManager::qtVersionForQMake(qmake.absoluteFilePath());
if (!qtVersion.isNull()) {
m_qtVersionString = qtVersion;
m_qmakeCommand = qmake.absoluteFilePath();
return qmake.absoluteFilePath();
}
}
}
return QString::null;
}
QtVersion::ToolchainType QtVersion::toolchainType() const
{
if (!isValid())
return INVALID;
const QString &spec = mkspec();
if (spec.contains("win32-msvc") || spec.contains(QLatin1String("win32-icc")))
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
return WINCE;
else
return OTHER;
}
QString QtVersion::mingwDirectory() const
{
return m_mingwDirectory;
}
void QtVersion::setMingwDirectory(const QString &directory)
{
m_mingwDirectory = directory;
}
QString QtVersion::prependPath() const
{
return m_prependPath;
}
void QtVersion::setPrependPath(const QString &directory)
{
m_prependPath = directory;
}
QString QtVersion::msvcVersion() const
{
return m_msvcVersion;
}
void QtVersion::setMsvcVersion(const QString &version)
{
m_msvcVersion = version;
}
Environment QtVersion::addToEnvironment(const Environment &env)
{
Environment e(env);
e.set("QTDIR", m_path);
QString qtdirbin = versionInfo().value("QT_INSTALL_BINS");
e.prependOrSetPath(qtdirbin);
// add libdir, includedir and bindir
// or add Mingw dirs
// or do nothing on other
QtVersion::ToolchainType t = toolchainType();
QList<MSVCEnvironment> list = MSVCEnvironment::availableVersions();
e = list.at(0).addToEnvironment(e);
} else {
foreach(const MSVCEnvironment &m, list) {
QString msvcPath;
// Find MSVC path
QList<MSVCEnvironment> list = MSVCEnvironment::availableVersions();
msvcPath = list.at(0).path();
e = list.at(0).addToEnvironment(e);
} else {
foreach(const MSVCEnvironment &m, list) {
e = m.addToEnvironment(e);
msvcPath = m.path();
break;
}
}
}
msvcPath += "/";
// qDebug()<<"MSVC path"<<msvcPath;
// qDebug()<<"looking for platform name in"<< path() + "/mkspecs/" + mkspec() +"/qmake.conf";
// Find Platform name
QString platformName = CeSdkHandler::platformName(path() + "/mkspecs/" + mkspec()+ "/qmake.conf");
// qDebug()<<"Platform Name"<<platformName;
CeSdkHandler cesdkhandler;
cesdkhandler.parse(msvcPath);
e = cesdkhandler.find(platformName).addToEnvironment(e);
} else if (t == QtVersion::OTHER) {
if (!m_prependPath.isEmpty())
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
e.prependOrSetPath(m_prependPath);
}
return e;
}
int QtVersion::uniqueId() const
{
return m_id;
}
int QtVersion::getUniqueId()
{
QtVersionManager *vm = ExtensionSystem::PluginManager::instance()->getObject<QtVersionManager>();
return vm->getUniqueId();
}
bool QtVersion::isValid() const
{
return (!(m_id == -1 || m_path == QString::null || m_name == QString::null || mkspec() == QString::null) && !m_notInstalled);
}
QtVersion::QmakeBuildConfig QtVersion::defaultBuildConfig() const
{
updateVersionInfo();
QtVersion::QmakeBuildConfig result = QtVersion::QmakeBuildConfig(0);
if (m_defaultConfigIsDebugAndRelease)
result = QtVersion::BuildAll;
if (m_defaultConfigIsDebug)
result = QtVersion::QmakeBuildConfig(result | QtVersion::DebugBuild);
return result;
}