1// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: GPL-3.0-or-later
4
5#include "buildercore.h"
6#include "mainframe/buildmanager.h"
7
8#include "services/window/windowservice.h"
9#include "services/builder/builderservice.h"
10
11#include "base/abstractwidget.h"
12
13using namespace dpfservice;
14
15void BuilderCore::initialize()
16{
17 auto &ctx = dpfInstance.serviceContext();
18 QString errStr;
19 if (!ctx.load(BuilderService::name(), &errStr)) {
20 qCritical() << errStr;
21 abort();
22 }
23}
24
25bool BuilderCore::start()
26{
27 auto &ctx = dpfInstance.serviceContext();
28 auto windowService = ctx.service<WindowService>(WindowService::name());
29 auto builderService = ctx.service<BuilderService>(BuilderService::name());
30 if (!windowService || !builderService) {
31 qCritical() << "Failed, can't found window service or build service";
32 abort();
33 }
34
35 windowService->addContextWidget(tr("Co&mpile Output"), new AbstractWidget(BuildManager::instance()->getCompileOutputPane()), "Compile");
36 windowService->addContextWidget(tr("&Issues"), new AbstractWidget(BuildManager::instance()->getProblemOutputPane()), "Compile");
37
38 using namespace std::placeholders;
39 builderService->interface.builderCommand = std::bind(&BuildManager::handleCommand, BuildManager::instance(), _1, _2);
40 return true;
41}
42
43dpf::Plugin::ShutdownFlag BuilderCore::stop()
44{
45 return Sync;
46}
47
48