| 1 | // SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. |
|---|---|
| 2 | // |
| 3 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 4 | |
| 5 | #ifndef CMAKEASYNPARSE_H |
| 6 | #define CMAKEASYNPARSE_H |
| 7 | |
| 8 | #include "services/project/projectinfo.h" |
| 9 | |
| 10 | #include "common/common.h" |
| 11 | |
| 12 | #include <QObject> |
| 13 | #include <QtXml> |
| 14 | |
| 15 | class QStandardItem; |
| 16 | class QAction; |
| 17 | class CMakeCbpParser; |
| 18 | |
| 19 | namespace { |
| 20 | enum_def(CDT_PROJECT_KIT, QString) |
| 21 | { |
| 22 | enum_exp CBP_GENERATOR = "CodeBlocks - Unix Makefiles"; |
| 23 | enum_exp CBP_FILE = ".cbp"; |
| 24 | }; |
| 25 | |
| 26 | enum_def(CDT_CPROJECT_KEY, QString) |
| 27 | { |
| 28 | enum_exp storageModuled = "storageModule"; |
| 29 | enum_exp cconfiguration = "cconfiguration"; |
| 30 | enum_exp buildCommand = "buildCommand"; |
| 31 | enum_exp buildArguments = "buildArguments"; |
| 32 | enum_exp buildTarget = "buildTarget"; |
| 33 | enum_exp stopOnError = "stopOnError"; |
| 34 | enum_exp useDefaultCommand = "useDefaultCommand"; |
| 35 | }; |
| 36 | } //namespace |
| 37 | |
| 38 | class CmakeAsynParse : public QObject |
| 39 | { |
| 40 | Q_OBJECT |
| 41 | public: |
| 42 | template<class T> |
| 43 | struct ParseInfo |
| 44 | { |
| 45 | T result; |
| 46 | bool isNormal = true; |
| 47 | }; |
| 48 | |
| 49 | struct TargetBuild |
| 50 | { |
| 51 | QString buildName; |
| 52 | QString buildCommand; |
| 53 | QString buildArguments; |
| 54 | QString buildTarget; |
| 55 | QString stopOnError; |
| 56 | QString useDefaultCommand; |
| 57 | }; |
| 58 | |
| 59 | typedef QList<TargetBuild> TargetBuilds; |
| 60 | |
| 61 | CmakeAsynParse(); |
| 62 | virtual ~CmakeAsynParse(); |
| 63 | |
| 64 | signals: |
| 65 | void parseProjectEnd(const ParseInfo<QStandardItem *> &info); |
| 66 | void parseActionsEnd(const ParseInfo<QList<TargetBuild>> &info); |
| 67 | |
| 68 | public slots: |
| 69 | QStandardItem *parseProject(QStandardItem *rootItem, const dpfservice::ProjectInfo &info); |
| 70 | QList<TargetBuild> parseActions(const QStandardItem *item); |
| 71 | |
| 72 | private: |
| 73 | QStandardItem *findParentItem(QStandardItem *rootItem, QString &name); |
| 74 | QStandardItem *createParentItem(QStandardItem *rootItem, QString &name); |
| 75 | QStandardItem *findItem(QStandardItem *rootItem, QString &name, QString &relativePath); |
| 76 | }; |
| 77 | |
| 78 | #endif // CMAKEASYNPARSE_H |
| 79 |