customexecutablerunconfiguration.h 5.87 KB
Newer Older
hjk's avatar
hjk committed
1
/****************************************************************************
con's avatar
con committed
2
**
3
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
hjk's avatar
hjk committed
4
** Contact: http://www.qt-project.org/legal
con's avatar
con committed
5
**
hjk's avatar
hjk committed
6
** This file is part of Qt Creator.
con's avatar
con committed
7
**
hjk's avatar
hjk committed
8 9 10 11 12 13 14
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.  For licensing terms and
** conditions see http://qt.digia.com/licensing.  For further information
** use the contact form at http://qt.digia.com/contact-us.
15
**
16
** GNU Lesser General Public License Usage
hjk's avatar
hjk committed
17 18 19 20 21 22 23 24 25
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights.  These rights are described in the Digia Qt LGPL Exception
con's avatar
con committed
26 27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
28
****************************************************************************/
hjk's avatar
hjk committed
29

con's avatar
con committed
30 31 32
#ifndef CUSTOMEXECUTABLERUNCONFIGURATION_H
#define CUSTOMEXECUTABLERUNCONFIGURATION_H

33 34
#include "qtsupport_global.h"

35
#include <projectexplorer/localapplicationrunconfiguration.h>
36

37 38
#include <utils/environment.h>

39
#include <QVariantMap>
40

41
namespace ProjectExplorer { class Target; }
Tobias Hunger's avatar
Tobias Hunger committed
42

43 44
namespace QtSupport {
namespace Internal { class CustomExecutableConfigurationWidget; }
con's avatar
con committed
45

46 47
class CustomExecutableRunConfigurationFactory;

48
class QTSUPPORT_EXPORT CustomExecutableRunConfiguration : public ProjectExplorer::LocalApplicationRunConfiguration
con's avatar
con committed
49
{
50
    Q_OBJECT
con's avatar
con committed
51
    // the configuration widget needs to setExecutable setWorkingDirectory and setCommandLineArguments
52
    friend class Internal::CustomExecutableConfigurationWidget;
53
    friend class CustomExecutableRunConfigurationFactory;
54

con's avatar
con committed
55
public:
56
    explicit CustomExecutableRunConfiguration(ProjectExplorer::Target *parent);
con's avatar
con committed
57
    ~CustomExecutableRunConfiguration();
58 59 60 61 62

    /**
     * Returns the executable, looks in the environment for it and might even
     * ask the user if none is specified
     */
63
    QString executable() const;
64

Leena Miettinen's avatar
Leena Miettinen committed
65
    /** Returns whether this runconfiguration ever was configured with an executable
66 67 68
     */
    bool isConfigured() const;

69
    RunMode runMode() const;
70
    QString workingDirectory() const;
71
    QString commandLineArguments() const;
72
    Utils::Environment environment() const;
con's avatar
con committed
73

74
    QWidget *createConfigurationWidget();
75 76
    QString dumperLibrary() const;
    QStringList dumperLibraryLocations() const;
con's avatar
con committed
77

78
    ProjectExplorer::Abi abi() const;
79

80
    QVariantMap toMap() const;
81

82 83
    bool ensureConfigured(QString *errorMessage);

con's avatar
con committed
84 85
signals:
    void changed();
86

87
    void baseEnvironmentChanged();
88
    void userEnvironmentChangesChanged(const QList<Utils::EnvironmentItem> &diff);
89

90
protected:
91 92
    CustomExecutableRunConfiguration(ProjectExplorer::Target *parent,
                                     CustomExecutableRunConfiguration *source);
93
    virtual bool fromMap(const QVariantMap &map);
94
    QString defaultDisplayName() const;
95

96
private:
97 98
    void ctor();

99 100 101
    enum BaseEnvironmentBase { CleanEnvironmentBase = 0,
                               SystemEnvironmentBase = 1,
                               BuildEnvironmentBase = 2};
102 103
    void setBaseEnvironmentBase(BaseEnvironmentBase env);
    BaseEnvironmentBase baseEnvironmentBase() const;
104
    Utils::Environment baseEnvironment() const;
105
    QString baseEnvironmentText() const;
106 107
    void setUserEnvironmentChanges(const QList<Utils::EnvironmentItem> &diff);
    QList<Utils::EnvironmentItem> userEnvironmentChanges() const;
108

con's avatar
con committed
109
    void setExecutable(const QString &executable);
110
    QString rawExecutable() const;
111
    void setCommandLineArguments(const QString &commandLineArguments);
112
    QString rawCommandLineArguments() const;
113
    void setBaseWorkingDirectory(const QString &workingDirectory);
114
    QString baseWorkingDirectory() const;
115
    void setUserName(const QString &name);
116
    void setRunMode(ProjectExplorer::LocalApplicationRunConfiguration::RunMode runMode);
117
    bool validateExecutable(QString *executable = 0, QString *errorMessage = 0) const;
118

con's avatar
con committed
119 120
    QString m_executable;
    QString m_workingDirectory;
121
    QString m_cmdArguments;
122
    RunMode m_runMode;
123 124
    bool m_userSetName;
    QString m_userName;
125
    QList<Utils::EnvironmentItem> m_userEnvironmentChanges;
126
    BaseEnvironmentBase m_baseEnvironmentBase;
con's avatar
con committed
127 128
};

129
class CustomExecutableRunConfigurationFactory : public ProjectExplorer::IRunConfigurationFactory
con's avatar
con committed
130 131
{
    Q_OBJECT
132

con's avatar
con committed
133
public:
134 135 136
    explicit CustomExecutableRunConfigurationFactory(QObject *parent = 0);
    ~CustomExecutableRunConfigurationFactory();

137
    QList<Core::Id> availableCreationIds(ProjectExplorer::Target *parent) const;
138
    QString displayNameForId(const Core::Id id) const;
139

140 141 142 143 144
    bool canCreate(ProjectExplorer::Target *parent, const Core::Id id) const;
    bool canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const;
    bool canClone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *product) const;
    ProjectExplorer::RunConfiguration *clone(ProjectExplorer::Target *parent,
                                             ProjectExplorer::RunConfiguration *source);
Tobias Hunger's avatar
Tobias Hunger committed
145

Daniel Teske's avatar
Daniel Teske committed
146
private:
Tobias Hunger's avatar
Tobias Hunger committed
147
    bool canHandle(ProjectExplorer::Target *parent) const;
148 149

    ProjectExplorer::RunConfiguration *doCreate(ProjectExplorer::Target *parent, const Core::Id id);
150 151
    ProjectExplorer::RunConfiguration *doRestore(ProjectExplorer::Target *parent,
                                                 const QVariantMap &map);
con's avatar
con committed
152 153
};

154
} // namespace QtSupport
con's avatar
con committed
155 156

#endif // CUSTOMEXECUTABLERUNCONFIGURATION_H