LocalQmlProfilerRunner *LocalQmlProfilerRunner::createLocalRunner(
        RunConfiguration *runConfiguration,
        const Analyzer::AnalyzerStartParameters &sp,
        QString *errorMessage,
        QmlProfilerRunControl *engine)
{
    LocalApplicationRunConfiguration *larc =
                   qobject_cast<LocalApplicationRunConfiguration *>(runConfiguration);
    QTC_ASSERT(larc, return 0);
    EnvironmentAspect *environment = runConfiguration->extraAspect<EnvironmentAspect>();
    QTC_ASSERT(environment, return 0);
    Configuration conf;
    conf.executable = larc->executable();
    conf.executableArguments = larc->commandLineArguments();
    conf.workingDirectory = larc->workingDirectory();
    conf.environment = environment->environment();

    conf.port = sp.analyzerPort;

    if (conf.executable.isEmpty()) {
        if (errorMessage)
            *errorMessage = tr("No executable file to launch.");
        return 0;
    }
    return new LocalQmlProfilerRunner(conf, engine);
}
QString DesktopQmakeRunConfiguration::workingDirectory() const
{
    EnvironmentAspect *aspect = extraAspect<EnvironmentAspect>();
    QTC_ASSERT(aspect, baseWorkingDirectory());
    return QDir::cleanPath(aspect->environment().expandVariables(
                Utils::expandMacros(baseWorkingDirectory(), macroExpander())));
}
QString CMakeRunConfiguration::workingDirectory() const
{
    EnvironmentAspect *aspect = extraAspect<EnvironmentAspect>();
    QTC_ASSERT(aspect, return QString());
    return QDir::cleanPath(aspect->environment().expandVariables(
                macroExpander()->expand(baseWorkingDirectory())));
}
LocalApplicationRunControl::LocalApplicationRunControl(RunConfiguration *rc, RunMode mode)
    : RunControl(rc, mode), m_runMode(ApplicationLauncher::Console), m_running(false)
{
    setIcon(QLatin1String(Constants::ICON_RUN_SMALL));
    EnvironmentAspect *environment = rc->extraAspect<EnvironmentAspect>();
    Utils::Environment env;
    if (environment)
        env = environment->environment();
    m_applicationLauncher.setEnvironment(env);

    connect(&m_applicationLauncher, SIGNAL(appendMessage(QString,Utils::OutputFormat)),
            this, SLOT(slotAppendMessage(QString,Utils::OutputFormat)));
    connect(&m_applicationLauncher, SIGNAL(processStarted()),
            this, SLOT(processStarted()));
    connect(&m_applicationLauncher, SIGNAL(processExited(int,QProcess::ExitStatus)),
            this, SLOT(processExited(int,QProcess::ExitStatus)));
    connect(&m_applicationLauncher, SIGNAL(bringToForegroundRequested(qint64)),
            this, SLOT(bringApplicationToForeground(qint64)));
}
void DesktopQmakeRunConfigurationWidget::environmentWasChanged()
{
    EnvironmentAspect *aspect = m_qmakeRunConfiguration->extraAspect<EnvironmentAspect>();
    QTC_ASSERT(aspect, return);
    m_workingDirectoryEdit->setEnvironment(aspect->environment());
}