1 /****************************************************************************
2 **
3 ** Copyright (C) 2016 BlackBerry Limited. All rights reserved.
4 ** Contact: BlackBerry (qt@blackberry.com)
5 **
6 ** This file is part of Qt Creator.
7 **
8 ** Commercial License Usage
9 ** Licensees holding valid commercial Qt licenses may use this file in
10 ** accordance with the commercial license agreement provided with the
11 ** Software or, alternatively, in accordance with the terms contained in
12 ** a written agreement between you and The Qt Company. For licensing terms
13 ** and conditions see https://www.qt.io/terms-conditions. For further
14 ** information use the contact form at https://www.qt.io/contact-us.
15 **
16 ** GNU General Public License Usage
17 ** Alternatively, this file may be used under the terms of the GNU
18 ** General Public License version 3 as published by the Free Software
19 ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
20 ** included in the packaging of this file. Please review the following
21 ** information to ensure the GNU General Public License requirements will
22 ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
23 **
24 ****************************************************************************/
25 
26 #pragma once
27 
28 #include "qnxconstants.h"
29 #include "qnxutils.h"
30 #include "qnxversionnumber.h"
31 
32 #include <utils/fileutils.h>
33 #include <utils/environment.h>
34 
35 #include <projectexplorer/abi.h>
36 
37 #include <debugger/debuggeritemmanager.h>
38 
39 #include <QVariant>
40 
41 namespace ProjectExplorer
42 {
43     class Kit;
44     class ToolChain;
45 }
46 
47 namespace Qnx {
48 namespace Internal {
49 
50 class QnxToolChain;
51 class QnxQtVersion;
52 
53 class QnxConfiguration
54 {
55 public:
56     QnxConfiguration();
57     QnxConfiguration(const Utils::FilePath &sdpEnvFile);
58     QnxConfiguration(const QVariantMap &data);
59 
60     Utils::FilePath envFile() const;
61     Utils::FilePath qnxTarget() const;
62     Utils::FilePath qnxHost() const;
63     Utils::FilePath qccCompilerPath() const;
64     Utils::EnvironmentItems qnxEnv() const;
65     QnxVersionNumber version() const;
66     QVariantMap toMap() const;
67 
68     bool isValid() const;
69 
70     QString displayName() const;
71     bool activate();
72     void deactivate();
73     bool isActive() const;
74     bool canCreateKits() const;
75     Utils::FilePath sdpPath() const;
76 
77     QList<ProjectExplorer::ToolChain *> autoDetect(
78             const QList<ProjectExplorer::ToolChain *> &alreadyKnown);
79 
80 private:
81     QList<ProjectExplorer::ToolChain *> findToolChain(
82             const QList<ProjectExplorer::ToolChain *> &alreadyKnown,
83             const ProjectExplorer::Abi &abi);
84 
85     QStringList validationErrors() const;
86 
87     void setVersion(const QnxVersionNumber& version);
88 
89     void readInformation();
90 
91     void setDefaultConfiguration(const Utils::FilePath &envScript);
92 
93     Utils::EnvironmentItems qnxEnvironmentItems() const;
94 
95     QString m_configName;
96 
97     Utils::FilePath m_envFile;
98     Utils::FilePath m_qnxConfiguration;
99     Utils::FilePath m_qnxTarget;
100     Utils::FilePath m_qnxHost;
101     Utils::FilePath m_qccCompiler;
102     Utils::EnvironmentItems m_qnxEnv;
103     QnxVersionNumber m_version;
104 
105     class Target
106     {
107     public:
Target(const ProjectExplorer::Abi & abi,const Utils::FilePath & path)108         Target(const ProjectExplorer::Abi &abi, const Utils::FilePath &path)
109             : m_abi(abi), m_path(path)
110         {
111         }
112 
113         QString shortDescription() const;
114         QString cpuDir() const;
115 
116         ProjectExplorer::Abi m_abi;
117         Utils::FilePath m_path;
118         Utils::FilePath m_debuggerPath;
119     };
120 
121     QList<Target> m_targets;
122 
123     QnxQtVersion *qnxQtVersion(const Target &target) const;
124 
125     void createTools(const Target &target);
126     QVariant createDebugger(const Target &target);
127 
128     using QnxToolChainMap = std::map<const char*, QnxToolChain*>;
129 
130     QnxToolChainMap createToolChain(const Target &target);
131     void createKit(const Target &target, const QnxToolChainMap &toolChain, const QVariant &debugger);
132 
133     const Target *findTargetByDebuggerPath(const Utils::FilePath &path) const;
134 
135     void updateTargets();
136     void assignDebuggersToTargets();
137 };
138 
139 } // Internal
140 } // Qnx
141