1// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: GPL-3.0-or-later
4
5#include "ninjabuild.h"
6
7#include "services/builder/builderservice.h"
8#include "services/project/projectservice.h"
9#include "services/option/optionmanager.h"
10
11using namespace dpfservice;
12
13class NinjaBuildPrivate
14{
15 friend class NinjaBuild;
16};
17
18NinjaBuild::NinjaBuild(QObject *parent)
19 : QObject(parent)
20 , d(new NinjaBuildPrivate())
21{
22
23}
24
25NinjaBuild::~NinjaBuild()
26{
27 if (d)
28 delete d;
29}
30
31QString NinjaBuild::build(const QString& kitName, const QString& projectPath)
32{
33 Q_UNUSED(projectPath)
34 QString buildUuid;
35 auto &ctx = dpfInstance.serviceContext();
36 BuilderService *builderService = ctx.service<BuilderService>(BuilderService::name());
37
38 if (builderService) {
39 BuildCommandInfo commandInfo;
40 commandInfo.kitName = kitName;
41 commandInfo.program = OptionManager::getInstance()->getNinjaToolPath();
42 commandInfo.arguments = QStringList("all");
43 commandInfo.workingDir = projectPath;
44
45 buildUuid = commandInfo.uuid;
46 builderService->interface.builderCommand({commandInfo}, false);
47 }
48
49 return buildUuid;
50}
51
52
53
54