File indexing completed on 2024-04-28 04:36:30
0001 /* 0002 SPDX-FileCopyrightText: 2017 Aleix Pol <aleixpol@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef KDEVPLATFORM_IRUNTIME_H 0008 #define KDEVPLATFORM_IRUNTIME_H 0009 0010 #include "interfacesexport.h" 0011 #include <QObject> 0012 #include <QString> 0013 0014 class QProcess; 0015 class KProcess; 0016 0017 namespace KDevelop 0018 { 0019 class Path; 0020 0021 /** 0022 * A runtime represents an environment we develop against 0023 * 0024 * It allows the IDE to interact with systems that differ from process where 0025 * the process we are running in. 0026 * 0027 * It allows to execute processes into them and translate the paths these runtimes 0028 * offer into ones that will be visible to our process so we can introspect the 0029 * platform we are developing for as well. 0030 */ 0031 class KDEVPLATFORMINTERFACES_EXPORT IRuntime : public QObject 0032 { 0033 Q_OBJECT 0034 public: 0035 ~IRuntime() override; 0036 0037 /** @returns a display string that identifies the runtime */ 0038 virtual QString name() const = 0; 0039 0040 /** 0041 * Adapts the @p process and starts it within the environment 0042 * 0043 * Gives an opportunity to the runtime to set up environment variables 0044 * or process the execution in any way necessary. 0045 */ 0046 virtual void startProcess(QProcess* process) const = 0; 0047 0048 /** 0049 * @see startProcess(QProcess*) 0050 */ 0051 virtual void startProcess(KProcess* process) const = 0; 0052 0053 /** 0054 * Given a @p localPath from our process's file system 0055 * @returns the path that the runtime's environment can use 0056 */ 0057 virtual Path pathInRuntime(const Path& localPath) const = 0; 0058 0059 /** 0060 * Given a @p runtimePath from the runtime 0061 * @returns the path in our file system scope that maps to the runtime's 0062 */ 0063 virtual Path pathInHost(const Path& runtimePath) const = 0; 0064 0065 /** 0066 * Analogous to QStandardPaths::findExecutable(), searches for the executable 0067 * named @p executableName in the runtime system paths. 0068 * @returns the absolute file path to the executable, or an empty string if not found. 0069 */ 0070 virtual QString findExecutable(const QString& executableName) const = 0; 0071 0072 /** 0073 * @returns the value for an environment variable in the runtime 0074 */ 0075 virtual QByteArray getenv(const QByteArray& varname) const = 0; 0076 0077 /** 0078 * @returns a path for binary directories or empty if there's no such thing. 0079 * 0080 * Some runtime systems won't be benefiting much from having custom build directories. 0081 * For such systems, the project manager will offer to initialise the build directories 0082 * there instead of asking where to create them. 0083 */ 0084 virtual Path buildPath() const = 0; 0085 0086 protected: 0087 friend class RuntimeController; 0088 0089 /** 0090 * notifies the runtime about its availability. 0091 * 0092 * This will be called exclusively from the IRuntimeController implementation. 0093 * 0094 * @see IRuntimeController::setCurrentRuntime 0095 */ 0096 virtual void setEnabled(bool enabled) = 0; 0097 0098 }; 0099 0100 } 0101 0102 #endif 0103