Пример #1
0
Utils::Environment MsvcToolChain::readEnvironmentSetting(Utils::Environment& env) const
{
    Utils::Environment result = env;
    if (!QFileInfo::exists(m_vcvarsBat))
        return result;

    QMap<QString, QString> envPairs;
    if (!generateEnvironmentSettings(env, m_vcvarsBat, m_varsBatArg, envPairs))
        return result;

    // Now loop through and process them
    QMap<QString,QString>::const_iterator envIter;
    for (envIter = envPairs.constBegin(); envIter!=envPairs.constEnd(); ++envIter) {
        const QString expandedValue = winExpandDelayedEnvReferences(envIter.value(), env);
        if (!expandedValue.isEmpty())
            result.set(envIter.key(), expandedValue);
    }

    if (debug) {
        const QStringList newVars = result.toStringList();
        const QStringList oldVars = env.toStringList();
        QDebug nsp = qDebug().nospace();
        foreach (const QString &n, newVars) {
            if (!oldVars.contains(n))
                nsp << n << '\n';
        }
    }
    return result;
}
Пример #2
0
QList<HeaderPath> GccToolChain::systemHeaderPaths() const
{
    if (m_headerPathes.isEmpty()) {
        // Using a clean environment breaks ccache/distcc/etc.
        Utils::Environment env = Utils::Environment::systemEnvironment();
        addToEnvironment(env);
        m_headerPathes = gccHeaderPathes(m_compilerPath, env.toStringList());
    }
    return m_headerPathes;
}
Пример #3
0
QByteArray GccToolChain::predefinedMacros() const
{
    if (m_predefinedMacros.isEmpty()) {
        // Using a clean environment breaks ccache/distcc/etc.
        Utils::Environment env = Utils::Environment::systemEnvironment();
        addToEnvironment(env);
        m_predefinedMacros = gccPredefinedMacros(m_compilerPath, env.toStringList());
    }
    return m_predefinedMacros;
}
Пример #4
0
void AbstractMaemoPackageCreationStep::preparePackagingProcess(QProcess *proc,
    const Qt4BuildConfiguration *bc, const QString &workingDir)
{
    Utils::Environment env = bc->environment();
    if (bc->qmakeBuildConfiguration() & QtSupport::BaseQtVersion::DebugBuild) {
        env.appendOrSet(QLatin1String("DEB_BUILD_OPTIONS"),
            QLatin1String("nostrip"), QLatin1String(" "));
    }
    proc->setEnvironment(env.toStringList());
    proc->setWorkingDirectory(workingDir);
}
Пример #5
0
Abi GccToolChain::targetAbi() const
{
    if (!m_targetAbi.isValid()) {
        Utils::Environment env = Utils::Environment::systemEnvironment();
        addToEnvironment(env);
        m_targetAbi = guessGccAbi(m_compilerPath, env.toStringList());
        m_supports64Bit = (m_targetAbi.wordWidth() == 64);
        if (m_targetAbi.wordWidth() == 64 && m_forcedTo32Bit)
            m_targetAbi = Abi(m_targetAbi.architecture(), m_targetAbi.os(), m_targetAbi.osFlavor(),
                              m_targetAbi.binaryFormat(), 32);

        if (displayName() == typeName())
            setDisplayName(defaultDisplayName());
    }
    return m_targetAbi;
}
ClangExecutableVersion clangExecutableVersion(const QString &executable)
{
    const ClangExecutableVersion invalidVersion;

    // Sanity checks
    const QFileInfo fileInfo(executable);
    const bool isExecutableFile = fileInfo.isFile() && fileInfo.isExecutable();
    if (!isExecutableFile)
        return invalidVersion;

    // Get version output
    Utils::Environment environment = Utils::Environment::systemEnvironment();
    Utils::Environment::setupEnglishOutput(&environment);
    Utils::SynchronousProcess runner;
    runner.setEnvironment(environment.toStringList());
    runner.setTimeoutS(10);
    // We would prefer "-dumpversion", but that one returns some old version number.
    const QStringList arguments(QLatin1String(("--version")));
    const Utils::SynchronousProcessResponse response = runner.runBlocking(executable, arguments);
    if (response.result != Utils::SynchronousProcessResponse::Finished)
        return invalidVersion;
    const QString output = response.stdOut();

    // Parse version output
    const QRegularExpression re(QLatin1String("clang version (\\d+)\\.(\\d+)\\.(\\d+)"));
    const QRegularExpressionMatch reMatch = re.match(output);
    if (re.captureCount() != 3)
        return invalidVersion;

    const QString majorString = reMatch.captured(1);
    bool convertedSuccessfully = false;
    const int major = majorString.toInt(&convertedSuccessfully);
    if (!convertedSuccessfully)
        return invalidVersion;

    const QString minorString = reMatch.captured(2);
    const int minor = minorString.toInt(&convertedSuccessfully);
    if (!convertedSuccessfully)
        return invalidVersion;

    const QString patchString = reMatch.captured(3);
    const int patch = patchString.toInt(&convertedSuccessfully);
    if (!convertedSuccessfully)
        return invalidVersion;

    return ClangExecutableVersion(major, minor, patch);
}
Пример #7
0
static Utils::Environment msvcReadEnvironmentSetting(const QString &varsBat,
                                                     const QString &args,
                                                     const Utils::Environment &env)
{
    // Run the setup script and extract the variables
    Utils::Environment result = env;
    if (!QFileInfo(varsBat).exists())
        return result;

    const QString tempOutputFileName = QDir::tempPath() + QLatin1String("\\qtcreator-msvc-environment.txt");
    Utils::TempFileSaver saver(QDir::tempPath() + "\\XXXXXX.bat");
    QByteArray call = "call ";
    call += Utils::QtcProcess::quoteArg(varsBat).toLocal8Bit();
    if (!args.isEmpty()) {
        call += ' ';
        call += args.toLocal8Bit();
    }
    call += "\r\n";
    saver.write(call);
    const QByteArray redirect = "set > " + Utils::QtcProcess::quoteArg(
                QDir::toNativeSeparators(tempOutputFileName)).toLocal8Bit() + "\r\n";
    saver.write(redirect);
    if (!saver.finalize()) {
        qWarning("%s: %s", Q_FUNC_INFO, qPrintable(saver.errorString()));
        return result;
    }

    Utils::QtcProcess run;
    run.setEnvironment(env);
    const QString cmdPath = QString::fromLocal8Bit(qgetenv("COMSPEC"));
    // Windows SDK setup scripts require command line switches for environment expansion.
    QString cmdArguments = QLatin1String(" /E:ON /V:ON /c \"");
    cmdArguments += QDir::toNativeSeparators(saver.fileName());
    cmdArguments += QLatin1Char('"');
    run.setCommand(cmdPath, cmdArguments);
    if (debug)
        qDebug() << "msvcReadEnvironmentSetting: " << call << cmdPath << cmdArguments
                 << " Env: " << env.size();
    run.start();

    if (!run.waitForStarted()) {
        qWarning("%s: Unable to run '%s': %s", Q_FUNC_INFO, qPrintable(varsBat),
            qPrintable(run.errorString()));
        return result;
    }
    if (!run.waitForFinished()) {
        qWarning("%s: Timeout running '%s'", Q_FUNC_INFO, qPrintable(varsBat));
        Utils::SynchronousProcess::stopProcess(run);
        return result;
    }

    QFile varsFile(tempOutputFileName);
    if (!varsFile.open(QIODevice::ReadOnly|QIODevice::Text))
        return result;

    QRegExp regexp(QLatin1String("(\\w*)=(.*)"));
    while (!varsFile.atEnd()) {
        const QString line = QString::fromLocal8Bit(varsFile.readLine()).trimmed();
        if (regexp.exactMatch(line)) {
            const QString varName = regexp.cap(1);
            const QString expandedValue = winExpandDelayedEnvReferences(regexp.cap(2), env);
            if (!expandedValue.isEmpty())
                result.set(varName, expandedValue);
        }
    }
    varsFile.close();
    varsFile.remove();
    if (debug) {
        const QStringList newVars = result.toStringList();
        const QStringList oldVars = env.toStringList();
        QDebug nsp = qDebug().nospace();
        foreach (const QString &n, newVars) {
            if (!oldVars.contains(n))
                nsp << n << '\n';
        }
    }
    return result;
}