1// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: GPL-3.0-or-later
4
5#include "cmakebuild.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 CMakeBuildPrivate
14{
15 friend class CMakeBuild;
16};
17
18CMakeBuild::CMakeBuild(QObject *parent)
19 : QObject(parent)
20 , d(new CMakeBuildPrivate())
21{
22
23}
24
25CMakeBuild::~CMakeBuild()
26{
27 if (d)
28 delete d;
29}
30
31QString CMakeBuild::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 ProjectService *projectService = ctx.service<ProjectService>(ProjectService::name());
38
39 if (builderService && projectService
40 && projectService->getActiveTarget) {
41 auto target = projectService->getActiveTarget(TargetType::kBuildTarget);
42 if (!target.buildCommand.isEmpty()) {
43 QStringList args = target.buildArguments << target.buildTarget;
44 args.removeAll("");
45 BuildCommandInfo commandInfo;
46 commandInfo.kitName = kitName;
47 commandInfo.program = target.buildCommand;
48 commandInfo.arguments = args;
49 commandInfo.workingDir = target.workingDir;
50
51 buildUuid = commandInfo.uuid;
52 builderService->interface.builderCommand({commandInfo}, false);
53 }
54 }
55
56 return buildUuid;
57}
58
59
60
61