Newer
Older
m_hasDocumentation = true;
}
if (m_versionInfo.contains("QT_INSTALL_EXAMPLES")){
QFileInfo fi(m_versionInfo.value("QT_INSTALL_EXAMPLES"));
if (fi.exists())
m_hasExamples = true;
}
if (m_versionInfo.contains("QT_INSTALL_DEMOS")){
QFileInfo fi(m_versionInfo.value("QT_INSTALL_DEMOS"));
if (fi.exists())
m_hasDemos = true;
}
QString QtVersion::findQtBinary(const QStringList &possibleCommands) const
{
const QString qtdirbin = versionInfo().value(QLatin1String("QT_INSTALL_BINS")) + QLatin1Char('/');
foreach (const QString &possibleCommand, possibleCommands) {
const QString fullPath = qtdirbin + possibleCommand;
if (QFileInfo(fullPath).isFile())
return QDir::cleanPath(fullPath);
}
QString QtVersion::uicCommand() const
{
if (!isValid())
if (!m_uicCommand.isNull())
return m_uicCommand;
#ifdef Q_OS_WIN
const QStringList possibleCommands(QLatin1String("uic.exe"));
#else
possibleCommands << QLatin1String("uic-qt4") << QLatin1String("uic4") << QLatin1String("uic");
#endif
m_uicCommand = findQtBinary(possibleCommands);
return m_uicCommand;
}
// Return a list of GUI binary names
// 'foo', 'foo.exe', 'Foo.app/Contents/MacOS/Foo'
static inline QStringList possibleGuiBinaries(const QString &name)
{
return QStringList(name + QLatin1String(".exe"));
#elif defined(Q_OS_MAC) // 'Foo.app/Contents/MacOS/Foo'
QString upCaseName = name;
upCaseName[0] = upCaseName.at(0).toUpper();
QString macBinary = upCaseName;
macBinary += QLatin1String(".app/Contents/MacOS/");
macBinary += upCaseName;
return QStringList(macBinary);
return QStringList(name);
}
QString QtVersion::designerCommand() const
{
if (!isValid())
if (m_designerCommand.isNull())
m_designerCommand = findQtBinary(possibleGuiBinaries(QLatin1String("designer")));
return m_designerCommand;
}
QString QtVersion::linguistCommand() const
{
if (!isValid())
if (m_linguistCommand.isNull())
m_linguistCommand = findQtBinary(possibleGuiBinaries(QLatin1String("linguist")));
return m_linguistCommand;
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
bool QtVersion::supportsTargetId(const QString &id) const
{
return supportedTargetIds().contains(id);
}
QSet<QString> QtVersion::supportedTargetIds() const
{
QSet<QString> result;
QList<ProjectExplorer::ToolChain::ToolChainType> tcs(possibleToolChainTypes());
if (tcs.contains(ProjectExplorer::ToolChain::WINSCW))
result.insert(QLatin1String(S60_EMULATOR_TARGET_ID));
if (tcs.contains(ProjectExplorer::ToolChain::RVCT_ARMV5) ||
tcs.contains(ProjectExplorer::ToolChain::RVCT_ARMV6) ||
tcs.contains(ProjectExplorer::ToolChain::GCCE) ||
tcs.contains(ProjectExplorer::ToolChain::GCCE_GNUPOC))
result.insert(QLatin1String(S60_DEVICE_TARGET_ID));
if (tcs.contains(ToolChain::GCC_MAEMO)) {
result.insert(QLatin1String(MAEMO_EMULATOR_TARGET_ID));
result.insert(QLatin1String(MAEMO_DEVICE_TARGET_ID));
}
// If the version is not for a specific device, then assume desktop
if (result.isEmpty() && !tcs.isEmpty())
result.insert(QLatin1String(DESKTOP_TARGET_ID));
return result;
}
QList<QSharedPointer<ProjectExplorer::ToolChain> > QtVersion::toolChains() const
return m_toolChains;
}
ProjectExplorer::ToolChain *QtVersion::toolChain(ProjectExplorer::ToolChain::ToolChainType type) const
{
foreach(const QSharedPointer<ProjectExplorer::ToolChain> &tcptr, toolChains())
if (tcptr->type() == type)
return tcptr.data();
return 0;
}
QList<ProjectExplorer::ToolChain::ToolChainType> QtVersion::possibleToolChainTypes() const
QList<ProjectExplorer::ToolChain::ToolChainType> types;
foreach(const QSharedPointer<ProjectExplorer::ToolChain> &tc, toolChains())
types << tc->type();
return types;
}
// if none, then it's INVALID everywhere this function is called
typedef QSharedPointer<ProjectExplorer::ToolChain> ToolChainPtr;
if (m_toolChainUpToDate)
return;
// no .qmake.cache so look at the default mkspec
QString baseMkspecDir = versionInfo().value("QMAKE_MKSPECS");
if (baseMkspecDir.isEmpty())
baseMkspecDir = versionInfo().value("QT_INSTALL_DATA") + "/mkspecs";
#ifdef Q_OS_WIN
baseMkspecDir = baseMkspecDir.toLower();
#endif
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
QString mkspecFullPath = baseMkspecDir + "/default";
// qDebug() << "default mkspec is located at" << mkspecFullPath;
#ifdef Q_OS_WIN
QFile f2(mkspecFullPath + "/qmake.conf");
if (f2.exists() && f2.open(QIODevice::ReadOnly)) {
while (!f2.atEnd()) {
QByteArray line = f2.readLine();
if (line.startsWith("QMAKESPEC_ORIGINAL")) {
const QList<QByteArray> &temp = line.split('=');
if (temp.size() == 2) {
mkspecFullPath = temp.at(1).trimmed();
}
break;
}
}
f2.close();
}
#elif defined(Q_OS_MAC)
QFile f2(mkspecFullPath + "/qmake.conf");
if (f2.exists() && f2.open(QIODevice::ReadOnly)) {
while (!f2.atEnd()) {
QByteArray line = f2.readLine();
if (line.startsWith("MAKEFILE_GENERATOR")) {
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++";
mkspecFullPath = baseMkspecDir + "/macx-g++";
}
//resolve mkspec link
QFileInfo f3(mkspecFullPath);
while (f3.isSymLink()) {
mkspecFullPath = f3.symLinkTarget();
f3.setFile(mkspecFullPath);
}
}
break;
}
}
f2.close();
}
#else
QFileInfo f2(mkspecFullPath);
while (f2.isSymLink()) {
mkspecFullPath = f2.symLinkTarget();
f2.setFile(mkspecFullPath);
}
#endif
#ifdef Q_OS_WIN
#endif
m_mkspecFullPath = mkspecFullPath;
QString mkspec = m_mkspecFullPath;
if (mkspec.startsWith(baseMkspecDir)) {
mkspec = mkspec.mid(baseMkspecDir.length() + 1);
} else {
QString sourceMkSpecPath = sourcePath() + "/mkspecs";
if (mkspec.startsWith(sourceMkSpecPath)) {
mkspec = mkspec.mid(sourceMkSpecPath.length() + 1);
} else {
// Do nothing
}
}
m_mkspec = mkspec;
// qDebug()<<"mkspec for "<<qmakeCommand()<<" is "<<m_mkspec<<m_mkspecFullPath;
ProFileOption option;
option.properties = versionInfo();
option.cache = ProFileCacheManager::instance()->cache();
ProFileReader *reader = new ProFileReader(&option);
reader->setCumulative(false);
reader->setParsePreAndPostFiles(false);
QString qmakeCXX = reader->value("QMAKE_CXX");
QString makefileGenerator = reader->value("MAKEFILE_GENERATOR");
QString ce_sdk = reader->values("CE_SDK").join(QLatin1String(" "));
QString ce_arch = reader->value("CE_ARCH");
QString qt_arch = reader->value("QT_ARCH");
if (!ce_sdk.isEmpty() && !ce_arch.isEmpty()) {
QString wincePlatformName = ce_sdk + " (" + ce_arch + QLatin1Char(')');
m_toolChains << ToolChainPtr(ProjectExplorer::ToolChain::createWinCEToolChain(msvcVersion(), wincePlatformName));
} else if (makefileGenerator == QLatin1String("SYMBIAN_ABLD") ||
makefileGenerator == QLatin1String("SYMBIAN_SBSV2")) {
if (S60Manager *s60mgr = S60Manager::instance()) {
m_toolChains << ToolChainPtr(s60mgr->createGCCEToolChain(this));
if (!qgetenv("RVCT22BIN").isEmpty())
m_toolChains << ToolChainPtr(s60mgr->createRVCTToolChain(this, ProjectExplorer::ToolChain::RVCT_ARMV5))
<< ToolChainPtr(s60mgr->createRVCTToolChain(this, ProjectExplorer::ToolChain::RVCT_ARMV6));
if (!mwcDirectory().isEmpty())
m_toolChains << ToolChainPtr(s60mgr->createWINSCWToolChain(this));
# else
m_toolChains << ToolChainPtr(s60mgr->createGCCE_GnuPocToolChain(this))
<< ToolChainPtr(s60mgr->createRVCTToolChain(this, ProjectExplorer::ToolChain::RVCT_ARMV6_GNUPOC));
# endif
}
} else if (qt_arch == "arm"
&& MaemoManager::instance()->isValidMaemoQtVersion(this)) {
m_toolChains << ToolChainPtr(MaemoManager::instance()->maemoToolChain(this));
} else if (qmakeCXX == "cl" || qmakeCXX == "icl") {
// TODO proper support for intel cl
ProjectExplorer::ToolChain::createMSVCToolChain(msvcVersion(), isQt64Bit()));
} else if (qmakeCXX == "g++" && makefileGenerator == "MINGW") {
ProjectExplorer::Environment env = ProjectExplorer::Environment::systemEnvironment();
//addToEnvironment(env);
env.prependOrSetPath(mingwDirectory() + "/bin");
qmakeCXX = env.searchInPath(qmakeCXX);
ProjectExplorer::ToolChain::createMinGWToolChain(qmakeCXX, mingwDirectory()));
} else if (qmakeCXX == "g++" || qmakeCXX == "icc") {
ProjectExplorer::Environment env = ProjectExplorer::Environment::systemEnvironment();
//addToEnvironment(env);
qmakeCXX = env.searchInPath(qmakeCXX);
if (qmakeCXX.isEmpty()) {
// macx-xcode mkspec resets the value of QMAKE_CXX.
// Unfortunately, we need a valid QMAKE_CXX to configure the parser.
qmakeCXX = QLatin1String("cc");
}
m_toolChains << ToolChainPtr(ProjectExplorer::ToolChain::createGccToolChain(qmakeCXX));
if (m_toolChains.isEmpty()) {
qDebug()<<"Could not create ToolChain for"<<m_mkspecFullPath<<qmakeCXX;
qDebug()<<"Qt Creator doesn't know about the system includes, nor the systems defines.";
}
QStringList configValues = reader->values("CONFIG");
m_defaultConfigIsDebugAndRelease = false;
foreach(const QString &value, configValues) {
if (value == "debug")
m_defaultConfigIsDebug = true;
else if (value == "release")
m_defaultConfigIsDebug = false;
else if (value == "build_all")
m_defaultConfigIsDebugAndRelease = true;
}
delete reader;
m_toolChainUpToDate = true;
QString QtVersion::mwcDirectory() const
{
return m_mwcDirectory;
}
void QtVersion::setMwcDirectory(const QString &directory)
{
m_mwcDirectory = directory;
QString QtVersion::s60SDKDirectory() const
{
return m_s60SDKDirectory;
}
void QtVersion::setS60SDKDirectory(const QString &directory)
{
m_s60SDKDirectory = directory;
QString QtVersion::gcceDirectory() const
{
return m_gcceDirectory;
}
void QtVersion::setGcceDirectory(const QString &directory)
{
m_gcceDirectory = directory;
QString QtVersion::mingwDirectory() const
{
return m_mingwDirectory;
}
void QtVersion::setMingwDirectory(const QString &directory)
{
m_mingwDirectory = directory;
m_toolChainUpToDate = false;
}
QString QtVersion::msvcVersion() const
{
return m_msvcVersion;
}
void QtVersion::setMsvcVersion(const QString &version)
{
m_msvcVersion = version;
m_toolChainUpToDate = false;
void QtVersion::addToEnvironment(ProjectExplorer::Environment &env) const
env.set("QTDIR", QDir::toNativeSeparators(versionInfo().value("QT_INSTALL_DATA")));
env.prependOrSetPath(versionInfo().value("QT_INSTALL_BINS"));
}
int QtVersion::uniqueId() const
{
return m_id;
}
int QtVersion::getUniqueId()
{
return QtVersionManager::instance()->getUniqueId();
&& !qmakeCommand().isEmpty()
&& !displayName().isEmpty()
&& !m_notInstalled
&& m_versionInfo.contains("QT_INSTALL_BINS");
}
QString QtVersion::invalidReason() const
{
if (isValid())
return QString();
return QApplication::translate("QtVersion", "No QMake path set");
return QApplication::translate("QtVersion", "Qt Version has no name");
if (m_notInstalled)
return QApplication::translate("QtVersion", "Qt Version is not installed, please run make install");
if (!m_versionInfo.contains("QT_INSTALL_BINS"))
return QApplication::translate("QtVersion", "Could not determine qt install binary, maybe the qmake path is wrong?");
return QString();
QtVersion::QmakeBuildConfigs QtVersion::defaultBuildConfig() const
QtVersion::QmakeBuildConfigs result = QtVersion::QmakeBuildConfig(0);
if (m_defaultConfigIsDebugAndRelease)
result = QtVersion::BuildAll;
if (m_defaultConfigIsDebug)
result = result | QtVersion::DebugBuild;
bool QtVersion::hasDebuggingHelper() const
{
return m_hasDebuggingHelper;
}
QString QtVersion::debuggingHelperLibrary() const
{
QString qtInstallData = versionInfo().value("QT_INSTALL_DATA");
if (qtInstallData.isEmpty())
return DebuggingHelperLibrary::debuggingHelperLibraryByInstallData(qtInstallData);
QStringList QtVersion::debuggingHelperLibraryLocations() const
{
QString qtInstallData = versionInfo().value("QT_INSTALL_DATA");
if (qtInstallData.isEmpty())
return DebuggingHelperLibrary::debuggingHelperLibraryLocationsByInstallData(qtInstallData);
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
bool QtVersion::hasDocumentation() const
{
updateVersionInfo();
return m_hasDocumentation;
}
QString QtVersion::documentationPath() const
{
updateVersionInfo();
return m_versionInfo["QT_INSTALL_DOCS"];
}
bool QtVersion::hasDemos() const
{
updateVersionInfo();
return m_hasDemos;
}
QString QtVersion::demosPath() const
{
updateVersionInfo();
return m_versionInfo["QT_INSTALL_DEMOS"];
}
bool QtVersion::hasExamples() const
{
updateVersionInfo();
return m_hasExamples;
}
QString QtVersion::examplesPath() const
{
updateVersionInfo();
return m_versionInfo["QT_INSTALL_EXAMPLES"];
}
{
const QString make = qmakeCommand();
bool isAmd64 = false;
#ifdef Q_OS_WIN32
# ifdef __GNUC__ // MinGW lacking some definitions/winbase.h
# define SCS_64BIT_BINARY 6
# endif
bool success = GetBinaryTypeW(reinterpret_cast<const TCHAR*>(make.utf16()), &binaryType) != 0;
if (success && binaryType == SCS_64BIT_BINARY)
isAmd64=true;
// qDebug() << "isAmd64:" << isAmd64 << binaryType;
return isAmd64;
#else
Q_UNUSED(isAmd64)
return false;
QString QtVersion::buildDebuggingHelperLibrary()
{
QString qtInstallData = versionInfo().value("QT_INSTALL_DATA");
if (qtInstallData.isEmpty())
ProjectExplorer::Environment env = ProjectExplorer::Environment::systemEnvironment();
addToEnvironment(env);
// TODO: the debugging helper doesn't comply to actual tool chain yet
QList<QSharedPointer<ProjectExplorer::ToolChain> > alltc = toolChains();
ProjectExplorer::ToolChain *tc = alltc.isEmpty() ? 0 : alltc.first().data();
return QApplication::tr("The Qt Version has no toolchain.");
QString output;
QString directory = DebuggingHelperLibrary::copyDebuggingHelperLibrary(qtInstallData, &output);
if (!directory.isEmpty())
output += DebuggingHelperLibrary::buildDebuggingHelperLibrary(directory, tc->makeCommand(), qmakeCommand(), mkspec(), env);