aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qnx/qnxrunconfiguration.cpp
blob: fb2211ae5db9806774660b2469aad571970e602e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// Copyright (C) 2016 BlackBerry Limited. All rights reserved.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#include "qnxrunconfiguration.h"

#include "qnxconstants.h"
#include "qnxtr.h"

#include <projectexplorer/buildsystem.h>
#include <projectexplorer/deployablefile.h>
#include <projectexplorer/project.h>
#include <projectexplorer/runconfigurationaspects.h>
#include <projectexplorer/runcontrol.h>
#include <projectexplorer/target.h>

#include <remotelinux/remotelinuxenvironmentaspect.h>

#include <utils/processinterface.h>

using namespace ProjectExplorer;
using namespace RemoteLinux;
using namespace Utils;

namespace Qnx::Internal {

class QnxRunConfiguration final : public RunConfiguration
{
public:
    QnxRunConfiguration(BuildConfiguration *bc, Id id)
        : RunConfiguration(bc, id)
    {
        executable.setDeviceSelector(kit(), ExecutableAspect::RunDevice);
        executable.setLabelText(Tr::tr("Executable on device:"));
        executable.setPlaceHolderText(Tr::tr("Remote path not set"));
        executable.makeOverridable("RemoteLinux.RunConfig.AlternateRemoteExecutable",
                                   "RemoteLinux.RunConfig.UseAlternateRemoteExecutable");
        executable.setHistoryCompleter("RemoteLinux.AlternateExecutable.History");

        symbolFile.setLabelText(Tr::tr("Executable on host:"));

        environment.setDeviceSelector(kit(), EnvironmentAspect::RunDevice);

        workingDir.setEnvironment(&environment);

        qtLibraries.setSettingsKey("Qt4ProjectManager.QnxRunConfiguration.QtLibPath");
        qtLibraries.setLabelText(Tr::tr("Path to Qt libraries on device"));
        qtLibraries.setDisplayStyle(StringAspect::LineEditDisplay);

        setUpdater([this] {
            const BuildTargetInfo bti = buildTargetInfo();
            const FilePath localExecutable = bti.targetFilePath;
            const DeployableFile depFile = buildSystem()->deploymentData()
                                               .deployableForLocalFile(localExecutable);
            executable.setExecutable(FilePath::fromString(depFile.remoteFilePath()));
            symbolFile.setValue(localExecutable);
        });

        setRunnableModifier([this](ProcessRunData &r) {
            QString libPath = qtLibraries();
            if (!libPath.isEmpty()) {
                r.environment.prependOrSet("LD_LIBRARY_PATH", libPath + "/lib");
                r.environment.prependOrSet("QML_IMPORT_PATH", libPath + "/imports");
                r.environment.prependOrSet("QML2_IMPORT_PATH", libPath + "/qml");
                r.environment.prependOrSet("QT_PLUGIN_PATH", libPath + "/plugins");
                r.environment.set("QT_QPA_FONTDIR", libPath + "/lib/fonts");
            }
        });
    }

    ExecutableAspect executable{this};
    SymbolFileAspect symbolFile{this};
    RemoteLinuxEnvironmentAspect environment{this};
    ArgumentsAspect arguments{this};
    WorkingDirectoryAspect workingDir{this};
    TerminalAspect terminal{this};
    StringAspect qtLibraries{this};
};

// QnxRunConfigurationFactory

class QnxRunConfigurationFactory final : public ProjectExplorer::RunConfigurationFactory
{
public:
    QnxRunConfigurationFactory()
    {
        registerRunConfiguration<QnxRunConfiguration>(Constants::QNX_RUNCONFIG_ID);
        addSupportedTargetDeviceType(Constants::QNX_QNX_OS_TYPE);
    }
};

void setupQnxRunnning()
{
    static QnxRunConfigurationFactory theQnxRunConfigurationFactory;
    static ProcessRunnerFactory theQnxRunWorkerFactory({Constants::QNX_RUNCONFIG_ID});
}

} // Qnx::Internal