Skip to content
Snippets Groups Projects
qtversionmanager.cpp 41.1 KiB
Newer Older
QString QtVersion::linguistCommand() const
{
    if (!isValid())
        return QString::null;
    if (m_linguistCommand.isNull())
        m_linguistCommand = findQtBinary(possibleGuiBinaries(QLatin1String("linguist")));
    return m_linguistCommand;
QList<ProjectExplorer::ToolChain::ToolChainType> QtVersion::possibleToolChainTypes() const
con's avatar
con committed
{
    QList<ProjectExplorer::ToolChain::ToolChainType> toolChains;
con's avatar
con committed
    if (!isValid())
        return toolChains << ProjectExplorer::ToolChain::INVALID;
con's avatar
con committed
    const QString &spec = mkspec();
hjk's avatar
hjk committed
    if (spec.contains("win32-msvc") || spec.contains(QLatin1String("win32-icc")))
        toolChains << ProjectExplorer::ToolChain::MSVC;
    else if (spec.contains("win32-g++"))
        toolChains << ProjectExplorer::ToolChain::MinGW;
hjk's avatar
hjk committed
    else if (spec == QString::null)
        toolChains << ProjectExplorer::ToolChain::INVALID;
    else if (spec.contains("wince"))
        toolChains << ProjectExplorer::ToolChain::WINCE;
    else if (spec.contains("linux-icc"))
        toolChains << ProjectExplorer::ToolChain::LinuxICC;
#ifdef QTCREATOR_WITH_S60
    else if (spec.contains("symbian-abld"))
        toolChains << ProjectExplorer::ToolChain::GCCE << ProjectExplorer::ToolChain::WINSCW;
#endif
con's avatar
con committed
    else
        toolChains << ProjectExplorer::ToolChain::GCC;
    return toolChains;
}

ProjectExplorer::ToolChain::ToolChainType QtVersion::defaultToolchainType() const
{
    return possibleToolChainTypes().at(0);
con's avatar
con committed
}

con's avatar
con committed
#ifdef QTCREATOR_WITH_S60
QString QtVersion::mwcDirectory() const
{
    return m_mwcDirectory;
}

void QtVersion::setMwcDirectory(const QString &directory)
{
    m_mwcDirectory = directory;
    m_toolChainUpToDate = false;
}
#endif

con's avatar
con committed
QString QtVersion::mingwDirectory() const
{
    return m_mingwDirectory;
}

void QtVersion::setMingwDirectory(const QString &directory)
{
    m_mingwDirectory = directory;
    m_toolChainUpToDate = false;
con's avatar
con committed
}

QString QtVersion::msvcVersion() const
{
    return m_msvcVersion;
}

dt's avatar
dt committed
QString QtVersion::wincePlatform() const
{
//    qDebug()<<"QtVersion::wincePlatform returning"<<ProjectExplorer::CeSdkHandler::platformName(mkspecPath() + "/qmake.conf");
dt's avatar
dt committed
    return ProjectExplorer::CeSdkHandler::platformName(mkspecPath() + "/qmake.conf");
}

con's avatar
con committed
void QtVersion::setMsvcVersion(const QString &version)
{
    m_msvcVersion = version;
    m_toolChainUpToDate = false;
con's avatar
con committed
}

void QtVersion::addToEnvironment(ProjectExplorer::Environment &env) const
con's avatar
con committed
{
dt's avatar
dt committed
    env.set("QTDIR", m_path);
con's avatar
con committed
    QString qtdirbin = versionInfo().value("QT_INSTALL_BINS");
dt's avatar
dt committed
    env.prependOrSetPath(qtdirbin);
con's avatar
con committed
    // add libdir, includedir and bindir
    // or add Mingw dirs
    // or do nothing on other
    ProjectExplorer::ToolChain *tc = toolChain(defaultToolchainType());
    if (tc)
        tc->addToEnvironment(env);
con's avatar
con committed
}

int QtVersion::uniqueId() const
{
    return m_id;
}

int QtVersion::getUniqueId()
{
    return QtVersionManager::instance()->getUniqueId();
con's avatar
con committed
}

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;
}

bool QtVersion::hasDebuggingHelper() const
{
    return m_hasDebuggingHelper;
}

QString QtVersion::debuggingHelperLibrary() const
{
    QString qtInstallData = versionInfo().value("QT_INSTALL_DATA");
    if (qtInstallData.isEmpty())
        qtInstallData = path();
    return DebuggingHelperLibrary::debuggingHelperLibrary(qtInstallData, path());
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"];
}
bool QtVersion::isMSVC64Bit() const
{
        const QString make = qmakeCommand();
Daniel Molkentin's avatar
Daniel Molkentin committed
//        qDebug() << make;
        bool isAmd64 = false;
#ifdef Q_OS_WIN32
#  ifdef __GNUC__   // MinGW lacking some definitions/winbase.h
#    define SCS_64BIT_BINARY 6
#  endif   
        DWORD binaryType = 0;
        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())
        qtInstallData = path();
    ProjectExplorer::Environment env = ProjectExplorer::Environment::systemEnvironment();
    addToEnvironment(env);

    ProjectExplorer::ToolChain *tc = toolChain(defaultToolchainType());
    QString directory = DebuggingHelperLibrary::copyDebuggingHelperLibrary(qtInstallData, path());
    QString output = DebuggingHelperLibrary::buildDebuggingHelperLibrary(directory, tc->makeCommand(), qmakeCommand(), mkspec(), env);
    m_hasDebuggingHelper = !debuggingHelperLibrary().isEmpty();
    return output;
}