1 | // SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. |
2 | // |
3 | // SPDX-License-Identifier: GPL-3.0-or-later |
4 | |
5 | #include "ninjagenerator.h" |
6 | |
7 | #include "ninjabuild.h" |
8 | #include "ninjadebug.h" |
9 | #include "services/project/projectservice.h" |
10 | #include "services/option/optionmanager.h" |
11 | |
12 | #include <QFile> |
13 | |
14 | using namespace dpfservice; |
15 | |
16 | class NinjaGeneratorPrivate |
17 | { |
18 | friend class NinjaGenerator; |
19 | QSharedPointer<NinjaDebug> ninjaDebug; |
20 | }; |
21 | |
22 | NinjaGenerator::NinjaGenerator() |
23 | : d(new NinjaGeneratorPrivate()) |
24 | { |
25 | d->ninjaDebug.reset(new NinjaDebug()); |
26 | } |
27 | |
28 | NinjaGenerator::~NinjaGenerator() |
29 | { |
30 | if (d) |
31 | delete d; |
32 | } |
33 | |
34 | QString NinjaGenerator::debugger() |
35 | { |
36 | return "dap" ; |
37 | } |
38 | |
39 | bool NinjaGenerator::prepareDebug(const QMap<QString, QVariant> ¶m, QString &retMsg) |
40 | { |
41 | Q_UNUSED(param) |
42 | Q_UNUSED(retMsg) |
43 | return true; |
44 | } |
45 | |
46 | bool NinjaGenerator::requestDAPPort(const QString &uuid, const QMap<QString, QVariant> ¶m, QString &retMsg) |
47 | { |
48 | QString targetPath = param.value("targetPath" ).toString(); |
49 | QStringList arguments = param.value("arguments" ).toStringList(); |
50 | |
51 | return d->ninjaDebug->requestDAPPort(uuid, toolKitName(), targetPath, arguments, retMsg); |
52 | } |
53 | |
54 | bool NinjaGenerator::isNeedBuild() |
55 | { |
56 | return true; |
57 | } |
58 | |
59 | bool NinjaGenerator::isTargetReady() |
60 | { |
61 | return true; |
62 | } |
63 | |
64 | bool NinjaGenerator::isLaunchNotAttach() |
65 | { |
66 | return true; |
67 | } |
68 | |
69 | dap::LaunchRequest NinjaGenerator::launchDAP(const QMap<QString, QVariant> ¶m) |
70 | { |
71 | QString targetPath = param.value("targetPath" ).toString(); |
72 | QStringList arguments = param.value("arguments" ).toStringList(); |
73 | |
74 | return d->ninjaDebug->launchDAP(targetPath, arguments); |
75 | } |
76 | |
77 | QString NinjaGenerator::build(const QString &projectPath) |
78 | { |
79 | return NinjaBuild::build(toolKitName(), projectPath); |
80 | } |
81 | |
82 | QMap<QString, QVariant> NinjaGenerator::getDebugArguments(const dpfservice::ProjectInfo &projectInfo, |
83 | const QString ¤tFile) |
84 | { |
85 | Q_UNUSED(currentFile) |
86 | |
87 | QMap<QString, QVariant> param; |
88 | QString workspace = projectInfo.workspaceFolder(); |
89 | param.insert("workspace" , workspace); |
90 | QString targetPath = workspace + QDir::separator() + QFileInfo(workspace).fileName(); |
91 | param.insert("targetPath" , targetPath); |
92 | |
93 | return param; |
94 | } |
95 | |
96 | RunCommandInfo NinjaGenerator::getRunArguments(const ProjectInfo &projectInfo, const QString ¤tFile) |
97 | { |
98 | Q_UNUSED(currentFile) |
99 | |
100 | RunCommandInfo runCommandInfo; |
101 | QString workspace = projectInfo.workspaceFolder(); |
102 | QString targetPath = workspace + QDir::separator() + QFileInfo(workspace).fileName(); |
103 | runCommandInfo.program = targetPath; |
104 | runCommandInfo.arguments = projectInfo.runCustomArgs(); |
105 | runCommandInfo.workingDir = workspace; |
106 | |
107 | return runCommandInfo; |
108 | } |
109 | |